pub struct BoundSocketMap<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> { /* private fields */ }
Expand description
A map from socket addresses to sockets.
The types of keys and IDs is determined by the SocketMapStateSpec
parameter. Each listener and connected socket stores additional state.
Listener and connected sockets are keyed independently, but share the same
address vector space. Conflicts are detected on attempted insertion of new
sockets.
Listener addresses map to listener-address-specific state, and likewise
with connected addresses. Depending on protocol (determined by the
SocketMapStateSpec
protocol), these address states can hold one or more
socket identifiers (e.g. UDP sockets with SO_REUSEPORT
set can share an
address).
Implementations§
Source§impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> BoundSocketMap<I, D, A, S>
impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> BoundSocketMap<I, D, A, S>
Source§impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S> BoundSocketMap<I, D, A, S>
impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S> BoundSocketMap<I, D, A, S>
Sourcepub fn listeners(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
pub fn listeners(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
Returns an iterator over the listeners on the socket map.
Sourcepub fn listeners_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
pub fn listeners_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Listener>where
S: SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A>,
S::ListenerAddrState: SocketMapAddrStateSpec<Id = S::ListenerId, SharingState = S::ListenerSharingState>,
Returns a mutable iterator over the listeners on the socket map.
Sourcepub fn conns(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
pub fn conns(
&self,
) -> Sockets<&SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
Returns an iterator over the connections on the socket map.
Sourcepub fn conns_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
pub fn conns_mut(
&mut self,
) -> Sockets<&mut SocketMap<AddrVec<I, D, A>, Bound<S>>, Connection>where
S: SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
S::ConnAddrState: SocketMapAddrStateSpec<Id = S::ConnId, SharingState = S::ConnSharingState>,
Returns a mutable iterator over the connections on the socket map.
Sourcepub fn get_shadower_counts(&self, addr: &AddrVec<I, D, A>) -> usize
pub fn get_shadower_counts(&self, addr: &AddrVec<I, D, A>) -> usize
Gets the number of shadower entries for addr
.
Source§impl<I, D, A, S> BoundSocketMap<I, D, A, S>where
I: BroadcastIpExt<Addr: MulticastAddress>,
D: DeviceIdentifier,
A: SocketMapAddrSpec,
S: SocketMapStateSpec + SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A> + SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
impl<I, D, A, S> BoundSocketMap<I, D, A, S>where
I: BroadcastIpExt<Addr: MulticastAddress>,
D: DeviceIdentifier,
A: SocketMapAddrSpec,
S: SocketMapStateSpec + SocketMapConflictPolicy<ListenerAddr<ListenerIpAddr<I::Addr, A::LocalIdentifier>, D>, <S as SocketMapStateSpec>::ListenerSharingState, I, D, A> + SocketMapConflictPolicy<ConnAddr<ConnIpAddr<I::Addr, A::LocalIdentifier, A::RemoteIdentifier>, D>, <S as SocketMapStateSpec>::ConnSharingState, I, D, A>,
Sourcepub fn iter_receivers(
&self,
(src_ip, src_port): (Option<SocketIpAddr<I::Addr>>, Option<A::RemoteIdentifier>),
(dst_ip, dst_port): (SocketIpAddr<I::Addr>, A::LocalIdentifier),
device: D,
broadcast: Option<I::BroadcastMarker>,
) -> Option<FoundSockets<AddrEntry<'_, I, D, A, S>, impl Iterator<Item = AddrEntry<'_, I, D, A, S>> + '_>>
pub fn iter_receivers( &self, (src_ip, src_port): (Option<SocketIpAddr<I::Addr>>, Option<A::RemoteIdentifier>), (dst_ip, dst_port): (SocketIpAddr<I::Addr>, A::LocalIdentifier), device: D, broadcast: Option<I::BroadcastMarker>, ) -> Option<FoundSockets<AddrEntry<'_, I, D, A, S>, impl Iterator<Item = AddrEntry<'_, I, D, A, S>> + '_>>
Finds the socket(s) that should receive an incoming packet.
Uses the provided addresses and receiving device to look up sockets that
should receive a matching incoming packet. Returns None
if no sockets
were found, or the results of the lookup.
Trait Implementations§
Source§impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> Default for BoundSocketMap<I, D, A, S>
impl<I: Ip, D: DeviceIdentifier, A: SocketMapAddrSpec, S: SocketMapStateSpec> Default for BoundSocketMap<I, D, A, S>
Auto Trait Implementations§
impl<I, D, A, S> Freeze for BoundSocketMap<I, D, A, S>
impl<I, D, A, S> RefUnwindSafe for BoundSocketMap<I, D, A, S>where
<A as SocketMapAddrSpec>::LocalIdentifier: RefUnwindSafe,
D: RefUnwindSafe,
<S as SocketMapStateSpec>::ListenerAddrState: RefUnwindSafe,
<S as SocketMapStateSpec>::ConnAddrState: RefUnwindSafe,
<A as SocketMapAddrSpec>::RemoteIdentifier: RefUnwindSafe,
<I as Ip>::Addr: RefUnwindSafe,
<S as SocketMapStateSpec>::AddrVecTag: RefUnwindSafe,
impl<I, D, A, S> Send for BoundSocketMap<I, D, A, S>where
<S as SocketMapStateSpec>::ListenerAddrState: Send,
<S as SocketMapStateSpec>::ConnAddrState: Send,
<S as SocketMapStateSpec>::AddrVecTag: Send,
impl<I, D, A, S> Sync for BoundSocketMap<I, D, A, S>where
<S as SocketMapStateSpec>::ListenerAddrState: Sync,
<S as SocketMapStateSpec>::ConnAddrState: Sync,
<S as SocketMapStateSpec>::AddrVecTag: Sync,
impl<I, D, A, S> Unpin for BoundSocketMap<I, D, A, S>where
<A as SocketMapAddrSpec>::LocalIdentifier: Unpin,
D: Unpin,
<S as SocketMapStateSpec>::ListenerAddrState: Unpin,
<S as SocketMapStateSpec>::ConnAddrState: Unpin,
<A as SocketMapAddrSpec>::RemoteIdentifier: Unpin,
<I as Ip>::Addr: Unpin,
<S as SocketMapStateSpec>::AddrVecTag: Unpin,
impl<I, D, A, S> UnwindSafe for BoundSocketMap<I, D, A, S>where
<A as SocketMapAddrSpec>::LocalIdentifier: UnwindSafe,
D: UnwindSafe,
<S as SocketMapStateSpec>::ListenerAddrState: UnwindSafe,
<S as SocketMapStateSpec>::ConnAddrState: UnwindSafe,
<A as SocketMapAddrSpec>::RemoteIdentifier: UnwindSafe,
<I as Ip>::Addr: UnwindSafe,
<S as SocketMapStateSpec>::AddrVecTag: RefUnwindSafe + 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
Source§impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
§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