From 96dedcc4c63556e069e2f5a04d95e986064b287b Mon Sep 17 00:00:00 2001 From: bdbai Date: Tue, 24 Aug 2021 16:07:19 +0800 Subject: [PATCH] Expose underlying device from PcapWriter --- src/phy/pcap_writer.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/phy/pcap_writer.rs b/src/phy/pcap_writer.rs index 03fee45..a1a629b 100644 --- a/src/phy/pcap_writer.rs +++ b/src/phy/pcap_writer.rs @@ -143,6 +143,21 @@ impl Device<'a>, S: PcapSink + Clone> PcapWriter { sink.global_header(link_type); PcapWriter { lower, sink, mode } } + + /// Get a reference to the underlying device. + /// + /// Even if the device offers reading through a standard reference, it is inadvisable to + /// directly read from the device as doing so will circumvent the packet capture. + pub fn get_ref(&self) -> &D { + &self.lower + } + + /// Get a mutable reference to the underlying device. + /// + /// It is inadvisable to directly read from the device as doing so will circumvent the packet capture. + pub fn get_mut(&mut self) -> &mut D { + &mut self.lower + } } impl<'a, D, S> Device<'a> for PcapWriter