Skip to main content

NetworkDevice

Trait NetworkDevice 

Source
pub trait NetworkDevice: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn receive(&self, buf: &mut [u8]) -> Result<usize, NetError>;
    fn transmit(&self, buf: &[u8]) -> Result<(), NetError>;
    fn mac_address(&self) -> [u8; 6];
    fn link_up(&self) -> bool;

    // Provided methods
    fn handle_interrupt(&self) { ... }
    fn poll(&self) { ... }
}
Expand description

Unified network device interface.

Kernel-resident drivers wrap their hardware-specific struct in a SpinLock and implement this trait with interior mutability. Future silo-hosted drivers expose the same interface via IPC.

Required Methods§

Source

fn name(&self) -> &str

Source

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

Source

fn transmit(&self, buf: &[u8]) -> Result<(), NetError>

Source

fn mac_address(&self) -> [u8; 6]

Provided Methods§

Source

fn handle_interrupt(&self)

Source

fn poll(&self)

Periodic housekeeping called from the timer path (or interrupt context). Default is a no-op; drivers that need a watchdog or buffer-reclamation cycle override this.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§