Skip to main content

Device

Trait Device 

Source
pub trait Device {
    // Required methods
    fn kind(&self) -> DeviceKind;
    fn read_frame(&mut self, buf: &mut [u8]) -> Result<usize>;
    fn write_frame(&mut self, frame: &[u8]) -> Result<usize>;
}
Expand description

A tunnel endpoint that yields and accepts inner frames. Implemented in M4.

Required Methods§

Source

fn kind(&self) -> DeviceKind

Whether this is an L3 (TUN) or L2 (TAP) device.

Source

fn read_frame(&mut self, buf: &mut [u8]) -> Result<usize>

Read one inner frame into buf, returning its length.

Source

fn write_frame(&mut self, frame: &[u8]) -> Result<usize>

Write one inner frame, returning the number of bytes written.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§