pub struct DeviceApi<D, C>(/* private fields */);Expand description
The device API.
Implementations§
Source§impl<D, C> DeviceApi<D, C>where
D: Device + DeviceStateSpec + DeviceReceiveFrameSpec,
C: ContextPair,
C::CoreContext: DeviceApiCoreContext<D, C::BindingsContext>,
C::BindingsContext: DeviceApiBindingsContext,
impl<D, C> DeviceApi<D, C>where
D: Device + DeviceStateSpec + DeviceReceiveFrameSpec,
C: ContextPair,
C::CoreContext: DeviceApiCoreContext<D, C::BindingsContext>,
C::BindingsContext: DeviceApiBindingsContext,
Sourcepub fn add_device(
&mut self,
bindings_id: <C::BindingsContext as DeviceLayerStateTypes>::DeviceIdentifier,
properties: D::CreationProperties,
metric: RawMetric,
external_state: D::External<C::BindingsContext>,
) -> <C::CoreContext as DeviceIdContext<D>>::DeviceIdwhere
C::CoreContext: DeviceApiIpLayerCoreContext<D, C::BindingsContext>,
pub fn add_device(
&mut self,
bindings_id: <C::BindingsContext as DeviceLayerStateTypes>::DeviceIdentifier,
properties: D::CreationProperties,
metric: RawMetric,
external_state: D::External<C::BindingsContext>,
) -> <C::CoreContext as DeviceIdContext<D>>::DeviceIdwhere
C::CoreContext: DeviceApiIpLayerCoreContext<D, C::BindingsContext>,
Adds a new device to the stack and returns its identifier.
§Panics
Panics if more than 1 loopback device is added to the stack.
Sourcepub fn add_device_with_default_state(
&mut self,
properties: D::CreationProperties,
metric: RawMetric,
) -> <C::CoreContext as DeviceIdContext<D>>::DeviceIdwhere
<C::BindingsContext as DeviceLayerStateTypes>::DeviceIdentifier: Default,
D::External<C::BindingsContext>: Default,
C::CoreContext: DeviceApiIpLayerCoreContext<D, C::BindingsContext>,
pub fn add_device_with_default_state(
&mut self,
properties: D::CreationProperties,
metric: RawMetric,
) -> <C::CoreContext as DeviceIdContext<D>>::DeviceIdwhere
<C::BindingsContext as DeviceLayerStateTypes>::DeviceIdentifier: Default,
D::External<C::BindingsContext>: Default,
C::CoreContext: DeviceApiIpLayerCoreContext<D, C::BindingsContext>,
Like DeviceApi::add_device but using default values for
bindings_id and external_state.
This is provided as a convenience method for tests with faked bindings contexts that have simple implementations for bindings state.
Sourcepub fn remove_device(
&mut self,
device: BaseDeviceId<D, C::BindingsContext>,
) -> RemoveResourceResultWithContext<D::External<C::BindingsContext>, C::BindingsContext>where
BaseDeviceId<D, C::BindingsContext>: Into<DeviceId<C::BindingsContext>>,
C::CoreContext: IpDeviceConfigurationContext<Ipv4, C::BindingsContext> + Ipv6DeviceConfigurationContext<C::BindingsContext> + DeviceIdContext<AnyDevice, DeviceId = DeviceId<C::BindingsContext>>,
C::BindingsContext: IpDeviceBindingsContext<Ipv4, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId> + IpDeviceBindingsContext<Ipv6, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>,
pub fn remove_device(
&mut self,
device: BaseDeviceId<D, C::BindingsContext>,
) -> RemoveResourceResultWithContext<D::External<C::BindingsContext>, C::BindingsContext>where
BaseDeviceId<D, C::BindingsContext>: Into<DeviceId<C::BindingsContext>>,
C::CoreContext: IpDeviceConfigurationContext<Ipv4, C::BindingsContext> + Ipv6DeviceConfigurationContext<C::BindingsContext> + DeviceIdContext<AnyDevice, DeviceId = DeviceId<C::BindingsContext>>,
C::BindingsContext: IpDeviceBindingsContext<Ipv4, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId> + IpDeviceBindingsContext<Ipv6, <C::CoreContext as DeviceIdContext<AnyDevice>>::DeviceId>,
Removes device from the stack.
If the return value is RemoveDeviceResult::Removed the device is
immediately removed from the stack, otherwise
RemoveDeviceResult::Deferred indicates that the device was marked for
destruction but there are still references to it. It carries a
ReferenceReceiver from the bindings context that can be awaited on
until removal is complete.
§Panics
Panics if the device is not currently in the stack.
Sourcepub fn receive_frame<B: BufferMut + Debug>(
&mut self,
meta: D::FrameMetadata<BaseDeviceId<D, C::BindingsContext>>,
frame: B,
)
pub fn receive_frame<B: BufferMut + Debug>( &mut self, meta: D::FrameMetadata<BaseDeviceId<D, C::BindingsContext>>, frame: B, )
Receive a device layer frame from the network.
Sourcepub fn apply_configuration(
&mut self,
pending: PendingDeviceConfigurationUpdate<'_, BaseDeviceId<D, C::BindingsContext>>,
) -> DeviceConfigurationUpdate
pub fn apply_configuration( &mut self, pending: PendingDeviceConfigurationUpdate<'_, BaseDeviceId<D, C::BindingsContext>>, ) -> DeviceConfigurationUpdate
Applies the configuration and returns a DeviceConfigurationUpdate
with the previous values for all configurations for all Some fields.
Note that even if the previous value matched the requested value, it is
still populated in the returned DeviceConfigurationUpdate.
Sourcepub fn new_configuration_update<'a>(
&mut self,
device: &'a BaseDeviceId<D, C::BindingsContext>,
config: DeviceConfigurationUpdate,
) -> Result<PendingDeviceConfigurationUpdate<'a, BaseDeviceId<D, C::BindingsContext>>, DeviceConfigurationUpdateError>
pub fn new_configuration_update<'a>( &mut self, device: &'a BaseDeviceId<D, C::BindingsContext>, config: DeviceConfigurationUpdate, ) -> Result<PendingDeviceConfigurationUpdate<'a, BaseDeviceId<D, C::BindingsContext>>, DeviceConfigurationUpdateError>
Creates a new device configuration update for the given device.
This method only validates that config is valid for device.
[DeviceApi::apply] must be called to apply the configuration.
Sourcepub fn get_configuration(
&mut self,
device: &BaseDeviceId<D, C::BindingsContext>,
) -> DeviceConfiguration
pub fn get_configuration( &mut self, device: &BaseDeviceId<D, C::BindingsContext>, ) -> DeviceConfiguration
Returns a snapshot of the given device’s configuration.
Sourcepub fn get_counters<'a>(
&'a mut self,
device: &'a BaseDeviceId<D, C::BindingsContext>,
) -> &'a DeviceCounters
pub fn get_counters<'a>( &'a mut self, device: &'a BaseDeviceId<D, C::BindingsContext>, ) -> &'a DeviceCounters
Returns a borrow to the DeviceCounters structure for device.
Sourcepub fn inspect<N: Inspector>(
&mut self,
device: &BaseDeviceId<D, C::BindingsContext>,
inspector: &mut N,
)
pub fn inspect<N: Inspector>( &mut self, device: &BaseDeviceId<D, C::BindingsContext>, inspector: &mut N, )
Exports state for device into inspector.
Trait Implementations§
Auto Trait Implementations§
impl<D, C> Freeze for DeviceApi<D, C>where
C: Freeze,
impl<D, C> RefUnwindSafe for DeviceApi<D, C>where
C: RefUnwindSafe,
D: RefUnwindSafe,
impl<D, C> Send for DeviceApi<D, C>
impl<D, C> Sync for DeviceApi<D, C>
impl<D, C> Unpin for DeviceApi<D, C>
impl<D, C> UnwindSafe for DeviceApi<D, C>where
C: UnwindSafe,
D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more