Trait netstack3_udp::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.

Object Safety§

This trait is not object safe.

Implementors§