pub struct Savefile { /* private fields */ }
Expand description
Abstraction for writing pcap savefiles, which can be read afterwards via Capture::from_file()
.
Implementations§
Source§impl Savefile
impl Savefile
Sourcepub fn write<'a>(&mut self, packet: &'a Packet<'a>)
pub fn write<'a>(&mut self, packet: &'a Packet<'a>)
Examples found in repository?
examples/savefile.rs (line 20)
5fn main() {
6 {
7 // open capture from default device
8 let mut cap = Capture::from_device(Device::lookup().unwrap()).unwrap().open().unwrap();
9
10 // open savefile using the capture
11 let mut savefile = cap.savefile("test.pcap").unwrap();
12
13 // get a packet from the interface
14 let p = cap.next().unwrap();
15
16 // print the packet out
17 println!("packet received on network: {:?}", p);
18
19 // write the packet to the savefile
20 savefile.write(&p);
21 }
22
23 // open a new capture from the test.pcap file we wrote to above
24 let mut cap = Capture::from_file("test.pcap").unwrap();
25
26 // get a packet
27 let p = cap.next().unwrap();
28
29 // print that packet out -- it should be the same as the one we printed above
30 println!("packet obtained from file: {:?}", p);
31}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Savefile
impl RefUnwindSafe for Savefile
impl Send for Savefile
impl Sync for Savefile
impl Unpin for Savefile
impl UnwindSafe for Savefile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more