pub struct SipAddr {
pub type: Option<Transport>,
pub addr: HostWithPort,
}Expand description
SIP Address
SipAddr represents a SIP network address that combines a host/port
with an optional transport protocol. It provides a unified way to
handle SIP addressing across different transport types.
§Fields
r#type- Optional transport protocol (UDP, TCP, TLS, WS, WSS)addr- Host and port information
§Transport Types
UDP- User Datagram Protocol (unreliable)TCP- Transmission Control Protocol (reliable)TLS- Transport Layer Security over TCP (reliable, encrypted)WS- WebSocket (reliable)WSS- WebSocket Secure (reliable, encrypted)
§Examples
use rsipstack::transport::SipAddr;
use rsipstack::sip::{HostWithPort, Transport};
use std::net::SocketAddr;
// Create from socket address
let socket_addr: SocketAddr = "192.168.1.100:5060".parse().unwrap();
let sip_addr = SipAddr::from(socket_addr);
// Create with specific transport
let sip_addr = SipAddr::new(
Transport::Tcp,
HostWithPort::try_from("example.com:5060").unwrap()
);
// Convert to socket address (for IP addresses)
if let Ok(socket_addr) = sip_addr.get_socketaddr() {
println!("Socket address: {}", socket_addr);
}§Usage in SIP
SipAddr is used throughout the stack for:
- Via header processing
- Contact header handling
- Route and Record-Route processing
- Transport layer addressing
- Connection management
§Conversion
SipAddr can be converted to/from:
SocketAddr(for IP addresses only)rsipstack::sip::Uri(SIP URI format)rsipstack::sip::HostWithPort(host/port only)
Fields§
§type: Option<Transport>§addr: HostWithPortImplementations§
Source§impl SipAddr
impl SipAddr
pub fn new(transport: Transport, addr: HostWithPort) -> Self
pub fn get_socketaddr(&self) -> Result<SocketAddr>
Trait Implementations§
impl Eq for SipAddr
Source§impl From<HostWithPort> for SipAddr
impl From<HostWithPort> for SipAddr
Source§fn from(host_with_port: HostWithPort) -> Self
fn from(host_with_port: HostWithPort) -> Self
Converts to this type from the input type.
Source§impl From<SipAddr> for HostWithPort
impl From<SipAddr> for HostWithPort
Source§impl From<SocketAddr> for SipAddr
impl From<SocketAddr> for SipAddr
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for SipAddr
Auto Trait Implementations§
impl Freeze for SipAddr
impl RefUnwindSafe for SipAddr
impl Send for SipAddr
impl Sync for SipAddr
impl Unpin for SipAddr
impl UnsafeUnpin for SipAddr
impl UnwindSafe for SipAddr
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
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>
Converts
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>
Converts
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