Struct Savefile

Source
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

Source

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§

Source§

impl Drop for Savefile

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.