pub struct Connection {
pub nettype: NetType,
pub addrtype: AddrType,
pub connection_address: String,
}Expand description
Connection data for the session or media.
See RFC 8866 Section 5.7 for more details.
Fields§
§nettype: NetTypeType of network for this connection.
addrtype: AddrTypeType of the connection_address.
connection_address: StringConnection address.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn from_ip_addr(connection_address: impl Into<IpAddr>) -> Self
pub fn from_ip_addr(connection_address: impl Into<IpAddr>) -> Self
Construct a Connection with the specified IP connection_address
Sourcepub fn from_ip_addr_ttl(
connection_address: impl Into<IpAddr>,
ttl: Option<u8>,
) -> Self
pub fn from_ip_addr_ttl( connection_address: impl Into<IpAddr>, ttl: Option<u8>, ) -> Self
Construct a Connection with the specified IP connection_address
and IPv4 multicast time-to-live in address/ttl notation
(RFC 8866 Section 5.7)
The time-to-live is only defined for IPv4 multicast sessions and is ignored for IPv6 addresses.
Sourcepub fn new(
nettype: NetType,
addrtype: AddrType,
connection_address: impl ToString,
) -> Self
pub fn new( nettype: NetType, addrtype: AddrType, connection_address: impl ToString, ) -> Self
Construct a Connection
See also Connection::from_ip_addr
Sourcepub fn set_connection_ip_address(
&mut self,
connection_address: impl Into<IpAddr>,
)
pub fn set_connection_ip_address( &mut self, connection_address: impl Into<IpAddr>, )
Sets the connection_address & addrtype of self from the specified IpAddr
Sourcepub fn try_parse_connection_ip_address(&self) -> Result<IpAddr, &str>
👎Deprecated since 0.3.1: use Connection::try_address instead
pub fn try_parse_connection_ip_address(&self) -> Result<IpAddr, &str>
use Connection::try_address instead
Tries to parse the connection_address String of self as IpAddr
An optional time-to-live suffix in address/ttl notation
(RFC 8866 Section 5.7)
is ignored, see Connection::try_address.
Returns the Ok with the parsed IpAddr or Err with the string address
if parsing failed.
Sourcepub fn try_address(&self) -> Result<ConnectionAddress, ConnectionAddressError>
pub fn try_address(&self) -> Result<ConnectionAddress, ConnectionAddressError>
Parses the connection_address into its components
(RFC 8866 Section 5.7)
The address must parse as an IpAddr; an IPv4 multicast
time-to-live and a number-of-addresses suffix must parse as numbers.
A time-to-live is only defined for “IP4”, for “IP6” the only suffix
is the address count.
Returns the parsed ConnectionAddress or a ConnectionAddressError
for the first invalid component.
Sourcepub fn is_multicast(&self) -> bool
pub fn is_multicast(&self) -> bool
Whether the connection_address is an IP multicast address
Returns false if the address cannot be parsed as an IpAddr, see
Connection::try_is_multicast for a variant with the error.
Sourcepub fn try_is_multicast(&self) -> Result<bool, ConnectionAddressError>
pub fn try_is_multicast(&self) -> Result<bool, ConnectionAddressError>
Like Connection::is_multicast but returns the parse error instead
of false if the address cannot be parsed. Only the address itself
is considered, invalid TTL or address-count suffixes do not error.