pub struct SipAgent { /* private fields */ }Expand description
A SIP user agent server: binds a UDP SIP port and yields incoming calls.
Implementations§
Source§impl SipAgent
impl SipAgent
Sourcepub async fn bind(addr: SocketAddr) -> Result<SipAgent, SipError>
pub async fn bind(addr: SocketAddr) -> Result<SipAgent, SipError>
Bind the SIP signalling port (conventionally 5060/udp) and start the endpoint’s serve loop in the background.
Sourcepub async fn next_call(&mut self) -> Option<IncomingCall>
pub async fn next_call(&mut self) -> Option<IncomingCall>
Wait for the next incoming call. In-dialog requests (BYE, re-INVITE,
ACK) and non-call methods are handled internally; only new INVITEs
surface. Returns None once the agent is shut down.
Sourcepub async fn register(
&self,
account: SipAccount,
) -> Result<SipRegistration, SipError>
pub async fn register( &self, account: SipAccount, ) -> Result<SipRegistration, SipError>
Register this agent with a registrar, so calls to the account’s address reach it.
The first REGISTER (answering a digest challenge with the account’s
credentials) happens before this returns, so a wrong password or an
unreachable registrar fails here. After that, the returned
SipRegistration refreshes the binding at three quarters of the
granted lifetime, and retries after a failure, until it is
unregistered or the agent shuts down.
let agent = SipAgent::bind("0.0.0.0:5060".parse()?).await?;
let registration = agent
.register(SipAccount::new("sip:pbx.example.com", "agent", "secret"))
.await?;
// ... take calls with agent.next_call() ...
registration.unregister().await?;Auto Trait Implementations§
impl Freeze for SipAgent
impl !RefUnwindSafe for SipAgent
impl Send for SipAgent
impl Sync for SipAgent
impl Unpin for SipAgent
impl !UnwindSafe for SipAgent
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].