netstack3_udp

Trait StateContext

Source
pub trait StateContext<I: IpExt, BC: UdpBindingsContext<I, Self::DeviceId>>: DeviceIdContext<AnyDevice> {
    type SocketStateCtx<'a>: BoundStateContext<I, BC> + DeviceIdContext<AnyDevice, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId> + UdpStateContext;

    // Required methods
    fn with_all_sockets_mut<O, F: FnOnce(&mut UdpSocketSet<I, Self::WeakDeviceId, BC>) -> O>(
        &mut self,
        cb: F,
    ) -> O;
    fn with_all_sockets<O, F: FnOnce(&UdpSocketSet<I, Self::WeakDeviceId, BC>) -> O>(
        &mut self,
        cb: F,
    ) -> O;
    fn with_bound_state_context<O, F: FnOnce(&mut Self::SocketStateCtx<'_>) -> O>(
        &mut self,
        cb: F,
    ) -> O;
    fn with_socket_state<O, F: FnOnce(&mut Self::SocketStateCtx<'_>, &UdpSocketState<I, Self::WeakDeviceId, BC>) -> O>(
        &mut self,
        id: &UdpSocketId<I, Self::WeakDeviceId, BC>,
        cb: F,
    ) -> O;
    fn with_socket_state_mut<O, F: FnOnce(&mut Self::SocketStateCtx<'_>, &mut UdpSocketState<I, Self::WeakDeviceId, BC>) -> O>(
        &mut self,
        id: &UdpSocketId<I, Self::WeakDeviceId, BC>,
        cb: F,
    ) -> O;
    fn should_send_port_unreachable(&mut self) -> bool;
    fn for_each_socket<F: FnMut(&mut Self::SocketStateCtx<'_>, &UdpSocketId<I, Self::WeakDeviceId, BC>, &UdpSocketState<I, Self::WeakDeviceId, BC>)>(
        &mut self,
        cb: F,
    );
}
Expand description

Core context abstracting state access to UDP state.

Required Associated Types§

Source

type SocketStateCtx<'a>: BoundStateContext<I, BC> + DeviceIdContext<AnyDevice, DeviceId = Self::DeviceId, WeakDeviceId = Self::WeakDeviceId> + UdpStateContext

The core context passed to the callback.

Required Methods§

Source

fn with_all_sockets_mut<O, F: FnOnce(&mut UdpSocketSet<I, Self::WeakDeviceId, BC>) -> O>( &mut self, cb: F, ) -> O

Calls the function with mutable access to the set with all UDP sockets.

Source

fn with_all_sockets<O, F: FnOnce(&UdpSocketSet<I, Self::WeakDeviceId, BC>) -> O>( &mut self, cb: F, ) -> O

Calls the function with immutable access to the set with all UDP sockets.

Source

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

Calls the function without access to UDP socket state.

Source

fn with_socket_state<O, F: FnOnce(&mut Self::SocketStateCtx<'_>, &UdpSocketState<I, Self::WeakDeviceId, BC>) -> O>( &mut self, id: &UdpSocketId<I, Self::WeakDeviceId, BC>, cb: F, ) -> O

Calls the function with an immutable reference to the given socket’s state.

Source

fn with_socket_state_mut<O, F: FnOnce(&mut Self::SocketStateCtx<'_>, &mut UdpSocketState<I, Self::WeakDeviceId, BC>) -> O>( &mut self, id: &UdpSocketId<I, Self::WeakDeviceId, BC>, cb: F, ) -> O

Calls the function with a mutable reference to the given socket’s state.

Source

fn should_send_port_unreachable(&mut self) -> bool

Returns true if UDP may send a port unreachable ICMP error message.

Source

fn for_each_socket<F: FnMut(&mut Self::SocketStateCtx<'_>, &UdpSocketId<I, Self::WeakDeviceId, BC>, &UdpSocketState<I, Self::WeakDeviceId, BC>)>( &mut self, cb: F, )

Call f with each socket’s state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§