pub trait PcapSink {
// Required method
fn write(&mut self, data: &[u8]);
// Provided methods
fn flush(&mut self) { ... }
fn write_u16(&mut self, value: u16) { ... }
fn write_u32(&mut self, value: u32) { ... }
fn global_header(&mut self, link_type: PcapLinkType) { ... }
fn packet_header(&mut self, timestamp: Instant, length: usize) { ... }
fn packet(&mut self, timestamp: Instant, packet: &[u8]) { ... }
fn max_packet_size(&self) -> u32 { ... }
}Expand description
A packet capture sink.
Required Methods§
Provided Methods§
Sourcefn global_header(&mut self, link_type: PcapLinkType)
fn global_header(&mut self, link_type: PcapLinkType)
Write the libpcap global header into the sink.
This method may be overridden e.g. if special synchronization is necessary.
Sourcefn packet_header(&mut self, timestamp: Instant, length: usize)
fn packet_header(&mut self, timestamp: Instant, length: usize)
Write the libpcap packet header into the sink.
See also the note for global_header.
§Panics
This function panics if length is greater than [u32::MAX].
Sourcefn packet(&mut self, timestamp: Instant, packet: &[u8])
fn packet(&mut self, timestamp: Instant, packet: &[u8])
Write the libpcap packet header followed by packet data into the sink.
The default implementation truncates packets that are larger than Self::max_packet_size.
See also the note for global_header.
Sourcefn max_packet_size(&self) -> u32
fn max_packet_size(&self) -> u32
Return the maximum size for captured packets.
The captures of packets larger than this size will be truncated by default. Excessively large values may cause the software reading the captures to allocate unnecessarily large buffers.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".