Skip to content

Commit

Permalink
Further simplify scalar conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
aldanor committed Mar 18, 2017
1 parent 6962617 commit 94c2a10
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl Capture<Offline> {
/// Takes an additional precision argument specifying the time stamp precision desired.
pub fn from_file_with_precision<P: AsRef<Path>>(path: P, precision: Precision) -> Result<Capture<Offline>, Error> {
Capture::new_raw(path.as_ref().to_str(), |path, err| unsafe {
raw::pcap_open_offline_with_tstamp_precision(path, precision as u8 as _, err)
raw::pcap_open_offline_with_tstamp_precision(path, precision as _, err)
})
}

Expand All @@ -432,7 +432,7 @@ impl Capture<Offline> {
pub fn from_raw_fd_with_precision(fd: RawFd, precision: Precision) -> Result<Capture<Offline>, Error> {
open_raw_fd(fd, b'r')
.and_then(|file| Capture::new_raw(None, |_, err| unsafe {
raw::pcap_fopen_offline_with_tstamp_precision(file, precision as u8 as _, err)
raw::pcap_fopen_offline_with_tstamp_precision(file, precision as _, err)
}))
}
}
Expand Down Expand Up @@ -487,20 +487,20 @@ impl Capture<Inactive> {
/// Set the time stamp type to be used by a capture device.
#[cfg(not(windows))]
pub fn tstamp_type(self, tstamp_type: TimestampType) -> Capture<Inactive> {
unsafe { raw::pcap_set_tstamp_type(*self.handle, tstamp_type as u8 as _) };
unsafe { raw::pcap_set_tstamp_type(*self.handle, tstamp_type as _) };
self
}

/// Set promiscuous mode on or off. By default, this is off.
pub fn promisc(self, to: bool) -> Capture<Inactive> {
unsafe { raw::pcap_set_promisc(*self.handle, if to {1} else {0}) };
unsafe { raw::pcap_set_promisc(*self.handle, to as _) };
self
}

/// Set rfmon mode on or off. The default is maintained by pcap.
#[cfg(not(windows))]
pub fn rfmon(self, to: bool) -> Capture<Inactive> {
unsafe { raw::pcap_set_rfmon(*self.handle, to as u8 as _) };
unsafe { raw::pcap_set_rfmon(*self.handle, to as _) };
self
}

Expand All @@ -515,7 +515,7 @@ impl Capture<Inactive> {
/// Set the time stamp precision returned in captures.
#[cfg(not(windows))]
pub fn precision(self, precision: Precision) -> Capture<Inactive> {
unsafe { raw::pcap_set_tstamp_precision(*self.handle, precision as u8 as _) };
unsafe { raw::pcap_set_tstamp_precision(*self.handle, precision as _) };
self
}

Expand Down

0 comments on commit 94c2a10

Please sign in to comment.