8
8
//! use `.open()` on a `Device`. You can obtain the "default" device using
9
9
//! `Device::lookup()`, or you can obtain the device(s) you need via `Device::list()`.
10
10
//!
11
- //! ```ignore
11
+ //! ```no_run
12
12
//! use pcap::Device;
13
13
//!
14
- //! fn main() {
15
- //! let mut cap = Device::lookup().unwrap().open().unwrap();
14
+ //! let mut cap = Device::lookup().unwrap().unwrap().open().unwrap();
16
15
//!
17
- //! while let Ok(packet) = cap.next_packet() {
18
- //! println!("received packet! {:?}", packet);
19
- //! }
16
+ //! while let Ok(packet) = cap.next_packet() {
17
+ //! println!("received packet! {:?}", packet);
20
18
//! }
19
+ //!
21
20
//! ```
22
21
//!
23
22
//! `Capture`'s `.next_packet()` will produce a `Packet` which can be dereferenced to access the
30
29
//! proceed to configure the capture handle. When you're finished, run `.open()` on it to
31
30
//! turn it into a `Capture<Active>`.
32
31
//!
33
- //! ```ignore
34
- //! use pcap::{Device,Capture};
32
+ //! ```no_run
33
+ //! use pcap::{Device, Capture};
35
34
//!
36
- //! fn main() {
37
- //! let main_device = Device::lookup().unwrap();
38
- //! let mut cap = Capture::from_device(main_device).unwrap()
39
- //! .promisc(true)
40
- //! .snaplen(5000)
41
- //! .open().unwrap();
35
+ //! let main_device = Device::lookup().unwrap().unwrap();
36
+ //! let mut cap = Capture::from_device(main_device).unwrap()
37
+ //! .promisc(true)
38
+ //! .snaplen(5000)
39
+ //! .open().unwrap();
42
40
//!
43
- //! while let Ok(packet) = cap.next_packet() {
44
- //! println!("received packet! {:?}", packet);
45
- //! }
41
+ //! while let Ok(packet) = cap.next_packet() {
42
+ //! println!("received packet! {:?}", packet);
46
43
//! }
47
44
//! ```
48
45
//!
@@ -806,8 +803,9 @@ impl State for Dead {}
806
803
///
807
804
/// # Example:
808
805
///
809
- /// ```ignore
810
- /// let cap = Capture::from_device(Device::lookup().unwrap()) // open the "default" interface
806
+ /// ```no_run
807
+ /// # use pcap::{Capture, Device};
808
+ /// let mut cap = Capture::from_device(Device::lookup().unwrap().unwrap()) // open the "default" interface
811
809
/// .unwrap() // assume the device exists and we are authorized to open it
812
810
/// .open() // activate the handle
813
811
/// .unwrap(); // assume activation worked
@@ -1290,7 +1288,7 @@ impl<T: Activated + ?Sized> Capture<T> {
1290
1288
/// compiled using `pcap_compile()`. `optimize` controls whether optimization on the resulting
1291
1289
/// code is performed
1292
1290
///
1293
- /// See http://biot.com/capstats/bpf.html for more information about this syntax.
1291
+ /// See < http://biot.com/capstats/bpf.html> for more information about this syntax.
1294
1292
pub fn filter ( & mut self , program : & str , optimize : bool ) -> Result < ( ) , Error > {
1295
1293
let program = CString :: new ( program) ?;
1296
1294
unsafe {
@@ -1312,7 +1310,7 @@ impl<T: Activated + ?Sized> Capture<T> {
1312
1310
/// Get capture statistics about this capture. The values represent packet statistics from the
1313
1311
/// start of the run to the time of the call.
1314
1312
///
1315
- /// See https://www.tcpdump.org/manpages/pcap_stats.3pcap.html for per-platform caveats about
1313
+ /// See < https://www.tcpdump.org/manpages/pcap_stats.3pcap.html> for per-platform caveats about
1316
1314
/// how packet statistics are calculated.
1317
1315
pub fn stats ( & mut self ) -> Result < Stat , Error > {
1318
1316
unsafe {
0 commit comments