INNER CODE UNIT · Rust

new

domcyrus/rustnet · crates/rustnet-capture/src/lib.rs:550

    pub fn new(capture: Capture<Active>) -> Self {
        let idle_wait = capture_wait::CaptureWait::new(&capture);
        Self { capture, idle_wait }
    }

    /// Read the next packet, returning `None` after a bounded idle delay when
    /// no packet is available. Captures supplied directly must be nonblocking.
    pub fn next_packet(&mut self) -> Result<Option<CapturedPacket>> {
        match self.capture.next_packet() {
            Ok(packet) => {
                self.idle_wait.packet_received();
                let ts = packet.header.ts;
                Ok(Some(CapturedPacket {
                    data: packet.data.to_vec(),
                    timestamp: timeval_to_system_time(ts.tv_sec, ts.tv_usec),
                    original_len: packet.header.len,
                }))
            }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…