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 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 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
.