Skip to main content

DatagramBoundStateContext

Trait DatagramBoundStateContext 

Source
pub trait DatagramBoundStateContext<I: IpExt + DualStackIpExt, BC: DatagramBindingsTypes, S: DatagramSocketSpec>: DeviceIdContext<AnyDevice> {
    type IpSocketsCtx<'a>: TransportIpContext<I, BC> + CoreTxMetadataContext<TxMetadata<I, Self::WeakDeviceId, S>, BC> + MulticastMembershipHandler<I, BC> + DeviceIdContext<AnyDevice, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId>;
    type DualStackContext: DualStackDatagramBoundStateContext<I, BC, S, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId>;
    type NonDualStackContext: NonDualStackDatagramBoundStateContext<I, BC, S, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId>;

    // Required methods
    fn with_bound_sockets<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>, &BoundDatagramSocketMap<I, <Self as DeviceIdContext<AnyDevice>>::WeakDeviceId, S>) -> O>(
        &mut self,
        cb: F,
    ) -> O;
    fn with_bound_sockets_mut<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>, &mut BoundDatagramSocketMap<I, <Self as DeviceIdContext<AnyDevice>>::WeakDeviceId, S>) -> O>(
        &mut self,
        cb: F,
    ) -> O;
    fn dual_stack_context(
        &self,
    ) -> MaybeDualStack<&Self::DualStackContext, &Self::NonDualStackContext>;
    fn dual_stack_context_mut(
        &mut self,
    ) -> MaybeDualStack<&mut Self::DualStackContext, &mut Self::NonDualStackContext>;
    fn with_transport_context<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>) -> O>(
        &mut self,
        cb: F,
    ) -> O;
}
Expand description

The core context providing access to bound datagram sockets.

Required Associated Types§

Source

type IpSocketsCtx<'a>: TransportIpContext<I, BC> + CoreTxMetadataContext<TxMetadata<I, Self::WeakDeviceId, S>, BC> + MulticastMembershipHandler<I, BC> + DeviceIdContext<AnyDevice, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId>

The core context passed to the callback provided to methods.

Source

type DualStackContext: DualStackDatagramBoundStateContext<I, BC, S, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId>

Context for dual-stack socket state access.

This type type provides access, via an implementation of the DualStackDatagramBoundStateContext trait, to state necessary for implementing dual-stack socket operations. While a type must always be provided, implementations of DatagramBoundStateContext for socket types that don’t support dual-stack operation (like ICMP and raw IP sockets, and UDPv4) can use the [UninstantiableDualStackContext] type, which is uninstantiable.

Source

type NonDualStackContext: NonDualStackDatagramBoundStateContext<I, BC, S, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId>

Context for single-stack socket access.

This type provides access, via an implementation of the NonDualStackDatagramBoundStateContext trait, to functionality necessary to implement sockets that do not support dual-stack operation.

Required Methods§

Source

fn with_bound_sockets<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>, &BoundDatagramSocketMap<I, <Self as DeviceIdContext<AnyDevice>>::WeakDeviceId, S>) -> O>( &mut self, cb: F, ) -> O

Calls the function with an immutable reference to the datagram sockets.

Source

fn with_bound_sockets_mut<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>, &mut BoundDatagramSocketMap<I, <Self as DeviceIdContext<AnyDevice>>::WeakDeviceId, S>) -> O>( &mut self, cb: F, ) -> O

Calls the function with a mutable reference to the datagram sockets.

Source

fn dual_stack_context( &self, ) -> MaybeDualStack<&Self::DualStackContext, &Self::NonDualStackContext>

Provides access to either the dual-stack or non-dual-stack context.

For socket types that don’t support dual-stack operation (like ICMP, raw IP sockets, and UDPv4), this method should always return a reference to the non-dual-stack context to allow the caller to access non-dual-stack state. Otherwise it should provide an instance of the DualStackContext, which can be used by the caller to access dual-stack state.

Source

fn dual_stack_context_mut( &mut self, ) -> MaybeDualStack<&mut Self::DualStackContext, &mut Self::NonDualStackContext>

The same as [dual_stack_context], but provides mutable references.

Source

fn with_transport_context<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>) -> O>( &mut self, cb: F, ) -> O

Calls the function with only the inner context.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§