pub struct AeAddr<T> { /* private fields */ }
Expand description
A specification for an address to the target SCP: a generic network socket address which may also include an application entity title.
These addresses can be serialized and parsed
with the syntax {ae_title}@{address}
,
where the socket address is parsed according to
the expectations of the parameter type T
.
For the version of the struct in which the AE title part is mandatory,
see FullAeAddr
.
§Example
let addr: AeAddr<SocketAddrV4> = "SCP-STORAGE@127.0.0.1:104".parse()?;
assert_eq!(addr.ae_title(), Some("SCP-STORAGE"));
assert_eq!(addr.socket_addr(), &SocketAddrV4::new([127, 0, 0, 1].into(), 104));
assert_eq!(&addr.to_string(), "SCP-STORAGE@127.0.0.1:104");
// AE title can be missing
let addr: AeAddr<String> = "192.168.1.99:1045".parse()?;
assert_eq!(addr.ae_title(), None);
// but can be provided later
let full_addr: FullAeAddr<_> = addr.with_ae_title("SCP-QUERY");
assert_eq!(full_addr.ae_title(), "SCP-QUERY");
assert_eq!(&full_addr.to_string(), "SCP-QUERY@192.168.1.99:1045");
Implementations§
Source§impl<T> AeAddr<T>
impl<T> AeAddr<T>
Sourcepub fn new(ae_title: impl Into<String>, socket_addr: T) -> Self
pub fn new(ae_title: impl Into<String>, socket_addr: T) -> Self
Create an AE address from its bare constituent parts.
Sourcepub fn new_socket_addr(socket_addr: T) -> Self
pub fn new_socket_addr(socket_addr: T) -> Self
Create an address with a missing AE title.
Sourcepub fn ae_title(&self) -> Option<&str>
pub fn ae_title(&self) -> Option<&str>
Retrieve the application entity title portion, if present.
Sourcepub fn socket_addr(&self) -> &T
pub fn socket_addr(&self) -> &T
Retrieve the socket address portion.
Sourcepub fn with_ae_title(self, ae_title: impl Into<String>) -> FullAeAddr<T>
pub fn with_ae_title(self, ae_title: impl Into<String>) -> FullAeAddr<T>
Create a new address with the full application entity target, discarding any potentially existing AE title.
Sourcepub fn with_default_ae_title(self, ae_title: impl Into<String>) -> FullAeAddr<T>
pub fn with_default_ae_title(self, ae_title: impl Into<String>) -> FullAeAddr<T>
Create a new address with the full application entity target, using the given AE title if it is missing.
Sourcepub fn into_parts(self) -> (Option<String>, T)
pub fn into_parts(self) -> (Option<String>, T)
Convert the address into its constituent parts.
Trait Implementations§
Source§impl<T> From<FullAeAddr<T>> for AeAddr<T>
impl<T> From<FullAeAddr<T>> for AeAddr<T>
Source§fn from(full: FullAeAddr<T>) -> Self
fn from(full: FullAeAddr<T>) -> Self
Source§impl From<SocketAddr> for AeAddr<SocketAddr>
This conversion provides a socket address without an AE title.
impl From<SocketAddr> for AeAddr<SocketAddr>
This conversion provides a socket address without an AE title.
Source§fn from(socket_addr: SocketAddr) -> Self
fn from(socket_addr: SocketAddr) -> Self
Source§impl From<SocketAddrV4> for AeAddr<SocketAddrV4>
This conversion provides an IPv4 socket address without an AE title.
impl From<SocketAddrV4> for AeAddr<SocketAddrV4>
This conversion provides an IPv4 socket address without an AE title.
Source§fn from(socket_addr: SocketAddrV4) -> Self
fn from(socket_addr: SocketAddrV4) -> Self
Source§impl From<SocketAddrV6> for AeAddr<SocketAddrV6>
This conversion provides an IPv6 socket address without an AE title.
impl From<SocketAddrV6> for AeAddr<SocketAddrV6>
This conversion provides an IPv6 socket address without an AE title.
Source§fn from(socket_addr: SocketAddrV6) -> Self
fn from(socket_addr: SocketAddrV6) -> Self
Source§impl<T> ToSocketAddrs for AeAddr<T>where
T: ToSocketAddrs,
impl<T> ToSocketAddrs for AeAddr<T>where
T: ToSocketAddrs,
Source§type Iter = <T as ToSocketAddrs>::Iter
type Iter = <T as ToSocketAddrs>::Iter
Source§fn to_socket_addrs(&self) -> Result<Self::Iter>
fn to_socket_addrs(&self) -> Result<Self::Iter>
SocketAddr
s. Read moreimpl<T: Eq> Eq for AeAddr<T>
impl<T> StructuralPartialEq for AeAddr<T>
Auto Trait Implementations§
impl<T> Freeze for AeAddr<T>where
T: Freeze,
impl<T> RefUnwindSafe for AeAddr<T>where
T: RefUnwindSafe,
impl<T> Send for AeAddr<T>where
T: Send,
impl<T> Sync for AeAddr<T>where
T: Sync,
impl<T> Unpin for AeAddr<T>where
T: Unpin,
impl<T> UnwindSafe for AeAddr<T>where
T: 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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