pub trait NetDevice: Send + Sync {
// Required methods
fn send(&self, packet: &[u8]) -> Result<(), NetDeviceError>;
fn receive(&self, buf: &mut [u8]) -> Result<usize, NetDeviceError>;
fn device_id(&self) -> usize;
fn mtu(&self) -> usize;
fn name(&self) -> &str;
fn mac_address(&self) -> [u8; 6];
}Expand description
网络设备接口
Required Methods§
Sourcefn send(&self, packet: &[u8]) -> Result<(), NetDeviceError>
fn send(&self, packet: &[u8]) -> Result<(), NetDeviceError>
发送数据包
Sourcefn receive(&self, buf: &mut [u8]) -> Result<usize, NetDeviceError>
fn receive(&self, buf: &mut [u8]) -> Result<usize, NetDeviceError>
接收数据包
Sourcefn mac_address(&self) -> [u8; 6]
fn mac_address(&self) -> [u8; 6]
获取MAC地址