pub struct ClientInviteDialog { /* private fields */ }Expand description
Client-side INVITE Dialog (UAC)
ClientInviteDialog represents a client-side INVITE dialog in SIP. This is used
when the local user agent acts as a User Agent Client (UAC) and initiates
an INVITE transaction to establish a session with a remote party.
§Key Features
- Session Initiation - Initiates INVITE transactions to establish calls
- In-dialog Requests - Sends UPDATE, INFO, OPTIONS within established dialogs
- Session Termination - Handles BYE and CANCEL for ending sessions
- Re-INVITE Support - Supports session modification via re-INVITE
- Authentication - Handles 401/407 authentication challenges
- State Management - Tracks dialog state transitions
§Dialog Lifecycle
- Creation - Dialog created when sending INVITE
- Early State - Receives provisional responses (1xx)
- Confirmed - Receives 2xx response and sends ACK
- Active - Can send in-dialog requests (UPDATE, INFO, etc.)
- Termination - Sends BYE or CANCEL to end session
§Examples
§Basic Call Flow
// After dialog is established:
// Send an UPDATE request
let response = dialog.update(None, Some(new_sdp_body)).await?;
// Send INFO request
let response = dialog.info(None, Some(info_body)).await?;
// End the call
dialog.bye().await?;§Session Modification
// Modify session with re-INVITE
let headers = vec![
rsip::Header::ContentType("application/sdp".into())
];
let response = dialog.reinvite(Some(headers), Some(new_sdp)).await?;
if let Some(resp) = response {
if resp.status_code == rsip::StatusCode::OK {
println!("Session modified successfully");
}
}§Thread Safety
ClientInviteDialog is thread-safe and can be cloned and shared across tasks. All operations are atomic and properly synchronized.
Implementations§
Source§impl ClientInviteDialog
impl ClientInviteDialog
Sourcepub fn id(&self) -> DialogId
pub fn id(&self) -> DialogId
Get the dialog identifier
Returns the unique DialogId that identifies this dialog instance. The DialogId consists of Call-ID, from-tag, and to-tag.
pub fn state(&self) -> DialogState
Sourcepub fn cancel_token(&self) -> &CancellationToken
pub fn cancel_token(&self) -> &CancellationToken
Get the cancellation token for this dialog
Returns a reference to the CancellationToken that can be used to cancel ongoing operations for this dialog.
Sourcepub async fn hangup(&self) -> Result<()>
pub async fn hangup(&self) -> Result<()>
Hang up the call
If the dialog is confirmed, send a BYE request to terminate the call. If the dialog is not confirmed, send a CANCEL request to cancel the call.
Sourcepub async fn bye(&self) -> Result<()>
pub async fn bye(&self) -> Result<()>
Send a BYE request to terminate the dialog
Sends a BYE request to gracefully terminate an established dialog. This should only be called for confirmed dialogs. If the dialog is not confirmed, this method returns immediately without error.
§Returns
Ok(())- BYE was sent successfully or dialog not confirmedErr(Error)- Failed to send BYE request
§Examples
// End an established call
dialog.bye().await?;Sourcepub async fn cancel(&self) -> Result<()>
pub async fn cancel(&self) -> Result<()>
Send a CANCEL request to cancel an ongoing INVITE
Sends a CANCEL request to cancel an INVITE transaction that has not yet been answered with a final response. This is used to abort call setup before the call is established.
§Returns
Ok(())- CANCEL was sent successfullyErr(Error)- Failed to send CANCEL request
§Examples
// Cancel an outgoing call before it's answered
dialog.cancel().await?;Sourcepub async fn reinvite(
&self,
headers: Option<Vec<Header>>,
body: Option<Vec<u8>>,
) -> Result<Option<Response>>
pub async fn reinvite( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>
Send a re-INVITE request to modify the session
Sends a re-INVITE request within an established dialog to modify the session parameters (e.g., change media, add/remove streams). This can only be called for confirmed dialogs.
§Parameters
headers- Optional additional headers to includebody- Optional message body (typically new SDP)
§Returns
Ok(Some(Response))- Response to the re-INVITEOk(None)- Dialog not confirmed, no request sentErr(Error)- Failed to send re-INVITE
§Examples
let new_sdp = b"v=0\r\no=- 123 456 IN IP4 192.168.1.1\r\n...";
let response = dialog.reinvite(None, Some(new_sdp.to_vec())).await?;Sourcepub async fn update(
&self,
headers: Option<Vec<Header>>,
body: Option<Vec<u8>>,
) -> Result<Option<Response>>
pub async fn update( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>
Send an UPDATE request to modify session parameters
Sends an UPDATE request within an established dialog to modify session parameters without the complexity of a re-INVITE. This is typically used for smaller session modifications.
§Parameters
headers- Optional additional headers to includebody- Optional message body (typically SDP)
§Returns
Ok(Some(Response))- Response to the UPDATEOk(None)- Dialog not confirmed, no request sentErr(Error)- Failed to send UPDATE
§Examples
let response = dialog.update(None, Some(sdp_body)).await?;Sourcepub async fn info(
&self,
headers: Option<Vec<Header>>,
body: Option<Vec<u8>>,
) -> Result<Option<Response>>
pub async fn info( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>
Send an INFO request for mid-dialog information
Sends an INFO request within an established dialog to exchange application-level information. This is commonly used for DTMF tones, but can carry any application-specific data.
§Parameters
headers- Optional additional headers to includebody- Optional message body (application-specific data)
§Returns
Ok(Some(Response))- Response to the INFOOk(None)- Dialog not confirmed, no request sentErr(Error)- Failed to send INFO
§Examples
// Send DTMF tone
let dtmf_body = b"Signal=1\r\nDuration=100\r\n";
let headers = vec![
rsip::Header::ContentType("application/dtmf-relay".into())
];
let response = dialog.info(Some(headers), Some(dtmf_body.to_vec())).await?;pub async fn options( &self, headers: Option<Vec<Header>>, body: Option<Vec<u8>>, ) -> Result<Option<Response>>
Sourcepub async fn handle(&mut self, tx: &mut Transaction) -> Result<()>
pub async fn handle(&mut self, tx: &mut Transaction) -> Result<()>
Handle incoming transaction for this dialog
Processes incoming SIP requests that are routed to this dialog. This method handles sequence number validation and dispatches to appropriate handlers based on the request method.
§Parameters
tx- The incoming transaction to handle
§Returns
Ok(())- Request handled successfullyErr(Error)- Failed to handle request
§Supported Methods
BYE- Terminates the dialogINFO- Handles information exchangeOPTIONS- Handles capability queriesUPDATE- Handles session updatesINVITE- Handles re-INVITE (when confirmed)
pub async fn process_invite( &self, tx: Transaction, ) -> Result<(DialogId, Option<Response>)>
Trait Implementations§
Source§impl Clone for ClientInviteDialog
impl Clone for ClientInviteDialog
Source§fn clone(&self) -> ClientInviteDialog
fn clone(&self) -> ClientInviteDialog
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ClientInviteDialog
impl !RefUnwindSafe for ClientInviteDialog
impl Send for ClientInviteDialog
impl Sync for ClientInviteDialog
impl Unpin for ClientInviteDialog
impl !UnwindSafe for ClientInviteDialog
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PipeAsRef for T
impl<T> PipeAsRef for T
Source§impl<T> PipeBorrow for T
impl<T> PipeBorrow for T
Source§impl<T> PipeDeref for T
impl<T> PipeDeref for T
Source§impl<T> PipeRef for T
impl<T> PipeRef for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
Source§fn tap_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
tap in debug builds, and does nothing in release builds.Source§fn tap_mut<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
Source§fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
tap_mut in debug builds, and does nothing in release builds.Source§impl<T, U> TapAsRef<U> for Twhere
U: ?Sized,
impl<T, U> TapAsRef<U> for Twhere
U: ?Sized,
Source§fn tap_ref<F, R>(self, func: F) -> Self
fn tap_ref<F, R>(self, func: F) -> Self
Source§fn tap_ref_dbg<F, R>(self, func: F) -> Self
fn tap_ref_dbg<F, R>(self, func: F) -> Self
tap_ref in debug builds, and does nothing in release builds.Source§fn tap_ref_mut<F, R>(self, func: F) -> Self
fn tap_ref_mut<F, R>(self, func: F) -> Self
Source§impl<T, U> TapBorrow<U> for Twhere
U: ?Sized,
impl<T, U> TapBorrow<U> for Twhere
U: ?Sized,
Source§fn tap_borrow<F, R>(self, func: F) -> Self
fn tap_borrow<F, R>(self, func: F) -> Self
Source§fn tap_borrow_dbg<F, R>(self, func: F) -> Self
fn tap_borrow_dbg<F, R>(self, func: F) -> Self
tap_borrow in debug builds, and does nothing in release builds.Source§fn tap_borrow_mut<F, R>(self, func: F) -> Self
fn tap_borrow_mut<F, R>(self, func: F) -> Self
Source§impl<T> TapDeref for T
impl<T> TapDeref for T
Source§fn tap_deref_dbg<F, R>(self, func: F) -> Self
fn tap_deref_dbg<F, R>(self, func: F) -> Self
tap_deref in debug builds, and does nothing in release builds.Source§fn tap_deref_mut<F, R>(self, func: F) -> Self
fn tap_deref_mut<F, R>(self, func: F) -> Self
self for modification.