Struct sip2::Connection
source · pub struct Connection { /* private fields */ }
Expand description
Manages a TCP connection to a SIP server and handles message sending and receiving.
Implementations§
source§impl Connection
impl Connection
sourcepub fn new(sip_host: &str) -> Result<Self, Error>
pub fn new(sip_host: &str) -> Result<Self, Error>
Creates a new SIP client and opens the TCP connection to the server
sip_host
- SIP server host/ip and port- E.g. “127.0.0.1:6001”
use sip2::Connection;
assert_eq!(Connection::new("JUNK0+..-*z$@").is_err(), true);
sourcepub fn from_stream(tcp_stream: TcpStream) -> Self
pub fn from_stream(tcp_stream: TcpStream) -> Self
Create a new SIP connection from an existing TCP stream.
sourcepub fn set_log_prefix(&mut self, prefix: impl Into<String>)
pub fn set_log_prefix(&mut self, prefix: impl Into<String>)
Add a string that will be prepended to all log:: calls where a self exists.
sourcepub fn disconnect(&self) -> Result<(), Error>
pub fn disconnect(&self) -> Result<(), Error>
Shutdown the TCP connection with the SIP server.
sourcepub fn send_with_timeout(
&mut self,
msg: &Message,
timeout: u64,
) -> Result<(), Error>
pub fn send_with_timeout( &mut self, msg: &Message, timeout: u64, ) -> Result<(), Error>
Send a message with a write timeout.
Returns Err() if the send/write times out. Clears the TCP socket timeout upon completion.
sourcepub fn recv(&mut self) -> Result<Message, Error>
pub fn recv(&mut self) -> Result<Message, Error>
Receive a SIP response.
Blocks until a response is received.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
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