pub enum Address {
Udp(SocketAddr),
Tcp(SocketAddr),
Btp(BtAddr),
}Expand description
An enum representing a network address for all supported protocols by the Matter specification (UDP, TCP and BTP).
Variants§
Implementations§
Source§impl Address
impl Address
pub const fn new() -> Address
pub const fn is_reliable(&self) -> bool
pub const fn is_udp(&self) -> bool
pub const fn is_tcp(&self) -> bool
pub const fn is_btp(&self) -> bool
Sourcepub fn canonical(self) -> Address
pub fn canonical(self) -> Address
Return this address with its IP canonicalized: an IPv4-mapped IPv6
address (::ffff:a.b.c.d) is rewritten to its true IPv4 form, leaving
genuine IPv4 / IPv6 / BTP addresses unchanged.
This matters because a dual-stack IPv6 socket reports an IPv4 peer’s
packets to recv_from in IPv4-mapped form, whereas the same peer is
usually sent to (and stored on the session) as a plain V4 address.
Address derives PartialEq/Eq over the SocketAddr (family
included), so without canonicalization V4(x) and V6(::ffff:x) would
compare unequal and session lookup by peer address would fail (PASE then
reports “PAKE session not found”).
This is used only when comparing a session’s peer address against a
received one (see Session::is_for_rx / is_pase_for_addr); the address
stored on the session is left untouched so it still routes replies to the
exact address the peer was reached at.
pub const fn udp(self) -> Option<SocketAddr>
pub const fn tcp(self) -> Option<SocketAddr>
pub const fn btp(self) -> Option<BtAddr>
Trait Implementations§
impl Copy for Address
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnsafeUnpin for Address
impl UnwindSafe for Address
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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