VirtioNetDevice

Struct VirtioNetDevice 

Source
pub struct VirtioNetDevice<T: Transport + Send + Sync> {
    virtio_net: SpinLock<Option<Box<VirtIONet<VirtIOHal, T, 256>>>>,
    device_id: usize,
    name: &'static str,
    mac: [u8; 6],
    mtu: usize,
}
Expand description

使用 virtio-drivers 0.12.0 实现的 Virtio 网络设备

Fields§

§virtio_net: SpinLock<Option<Box<VirtIONet<VirtIOHal, T, 256>>>>§device_id: usize§name: &'static str§mac: [u8; 6]§mtu: usize

Implementations§

Source§

impl<T: Transport + Send + Sync> VirtioNetDevice<T>

Source

pub fn new(transport: T, device_id: usize) -> Result<Arc<Self>, NetDeviceError>

创建新的 Virtio 网络设备实例

§参数
  • transport - VirtIO 设备传输层
  • device_id - 设备标识符

Trait Implementations§

Source§

impl<T: Transport + Send + Sync> NetDevice for VirtioNetDevice<T>

Source§

fn send(&self, packet: &[u8]) -> Result<(), NetDeviceError>

发送数据包

Source§

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

接收数据包

Source§

fn device_id(&self) -> usize

获取设备标识符

Source§

fn mtu(&self) -> usize

获取最大传输单元(MTU)

Source§

fn name(&self) -> &str

获取设备名称

Source§

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

获取MAC地址

Auto Trait Implementations§

§

impl<T> !Freeze for VirtioNetDevice<T>

§

impl<T> !RefUnwindSafe for VirtioNetDevice<T>

§

impl<T> Send for VirtioNetDevice<T>

§

impl<T> Sync for VirtioNetDevice<T>

§

impl<T> Unpin for VirtioNetDevice<T>

§

impl<T> UnwindSafe for VirtioNetDevice<T>
where T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.