Struct TimerFactory

Source
pub struct TimerFactory { /* private fields */ }
Expand description

A factory for creating and scheduling SIP timers based on RFC 3261.

TimerFactory abstracts the details of individual timer durations and types, providing methods to schedule specific timers (e.g., Timer A, Timer B) or common combinations of timers for different transaction states. It relies on a TimerSettings instance for duration configurations and a TimerManager instance to handle the actual timer operations (start, stop).

§RFC 3261 Compliance

This factory makes it easy to create timers that comply with RFC 3261 Section 17, which specifies timer behavior for different transaction types:

  • Section 17.1.1: INVITE Client Transaction
  • Section 17.1.2: Non-INVITE Client Transaction
  • Section 17.2.1: INVITE Server Transaction
  • Section 17.2.2: Non-INVITE Server Transaction

Implementations§

Source§

impl TimerFactory

Source

pub fn new( settings: Option<TimerSettings>, timer_manager: Arc<TimerManager>, ) -> Self

Creates a new TimerFactory.

§Arguments
  • settings - Optional TimerSettings to configure timer durations. If None, default settings are used.
  • timer_manager - An Arc<TimerManager> that will manage the timers scheduled by this factory.
Source

pub fn settings(&self) -> &TimerSettings

Returns a reference to the TimerSettings used by this factory.

Source

pub fn timer_manager(&self) -> Arc<TimerManager>

Returns a clone of the Arc<TimerManager> used by this factory.

Source

pub async fn schedule_timer_a( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer A for an INVITE client transaction (initial retransmission timer). Uses settings.t1 for duration and TimerType::A.

§RFC 3261 Context

Timer A controls the retransmission interval for INVITE requests over unreliable transports. It starts at T1 seconds and doubles after each retransmission. See RFC 3261 Section 17.1.1.2 for details.

§Arguments
  • transaction_id - The transaction key for the INVITE client transaction
Source

pub async fn schedule_timer_b( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer B for an INVITE client transaction (transaction timeout). Uses settings.transaction_timeout for duration and TimerType::B.

§RFC 3261 Context

Timer B determines how long an INVITE client transaction will continue to retry (retransmit) before timing out. The recommended value is 64*T1. See RFC 3261 Section 17.1.1.2 for details.

§Arguments
  • transaction_id - The transaction key for the INVITE client transaction
Source

pub async fn schedule_timer_d( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer D for an INVITE client transaction (wait for response retransmissions). Uses settings.wait_time_d for duration and TimerType::D.

§RFC 3261 Context

Timer D defines how long an INVITE client transaction in the Completed state should wait to receive retransmitted responses (min. 32 seconds for UDP). See RFC 3261 Section 17.1.1.2 for details.

§Arguments
  • transaction_id - The transaction key for the INVITE client transaction
Source

pub async fn schedule_timer_e( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer E for a non-INVITE client transaction (initial retransmission timer). Uses settings.t1 for duration and TimerType::E.

§RFC 3261 Context

Timer E controls the retransmission interval for non-INVITE requests. Like Timer A, it starts at T1 and doubles after each retransmission up to T2. See RFC 3261 Section 17.1.2.2 for details.

§Arguments
  • transaction_id - The transaction key for the non-INVITE client transaction
Source

pub async fn schedule_timer_f( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer F for a non-INVITE client transaction (transaction timeout). Uses settings.transaction_timeout for duration and TimerType::F.

§RFC 3261 Context

Timer F determines how long a non-INVITE client transaction will continue to retry before timing out. The recommended value is 64*T1. See RFC 3261 Section 17.1.2.2 for details.

§Arguments
  • transaction_id - The transaction key for the non-INVITE client transaction
Source

pub async fn schedule_timer_g( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer G for an INVITE server transaction (2xx response retransmission). Uses settings.t1 for duration and TimerType::G.

§RFC 3261 Context

Timer G controls the retransmission interval for INVITE responses. It starts at T1 and doubles with each retransmission up to T2. See RFC 3261 Section 17.2.1 for details.

§Arguments
  • transaction_id - The transaction key for the INVITE server transaction
Source

pub async fn schedule_timer_h( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer H for an INVITE server transaction (wait for ACK after 2xx). Uses settings.wait_time_h for duration and TimerType::H.

§RFC 3261 Context

Timer H limits how long an INVITE server transaction will retransmit the final response. If no ACK is received when Timer H fires, the transaction terminates anyway. Typically 64*T1. See RFC 3261 Section 17.2.1 for details.

§Arguments
  • transaction_id - The transaction key for the INVITE server transaction
Source

pub async fn schedule_timer_i( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer I for an INVITE server transaction (wait in Confirmed state after ACK). Uses settings.wait_time_i for duration and TimerType::I.

§RFC 3261 Context

Timer I determines how long an INVITE server transaction stays in the Confirmed state after receiving an ACK, to absorb any retransmitted ACKs. For reliable transports, this can be 0. For UDP, it’s typically T4 (5 seconds). See RFC 3261 Section 17.2.1 for details.

§Arguments
  • transaction_id - The transaction key for the INVITE server transaction
Source

pub async fn schedule_timer_j( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer J for a non-INVITE server transaction (wait for request retransmissions). Uses settings.wait_time_j for duration and TimerType::J.

§RFC 3261 Context

Timer J determines how long a non-INVITE server transaction stays in the Completed state, waiting for request retransmissions. For UDP, this is typically 64*T1 (32 seconds). For reliable transports, it can be 0. See RFC 3261 Section 17.2.2 for details.

§Arguments
  • transaction_id - The transaction key for the non-INVITE server transaction
Source

pub async fn schedule_timer_k( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer K for a non-INVITE client transaction (wait for response retransmissions). Uses settings.wait_time_k for duration and TimerType::K.

§RFC 3261 Context

Timer K determines how long a non-INVITE client transaction stays in the Completed state, waiting for response retransmissions. For UDP, this is typically T4 (5 seconds). For reliable transports, it can be 0. See RFC 3261 Section 17.1.2.2 for details.

§Arguments
  • transaction_id - The transaction key for the non-INVITE client transaction
Source

pub async fn schedule_invite_client_initial_timers( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules the initial set of timers (A and B) for an INVITE client transaction.

§RFC 3261 Context

When an INVITE client transaction is initiated, it needs both:

  • Timer A for controlling retransmissions (starting at T1)
  • Timer B for overall transaction timeout (64*T1)

This method is typically called when the transaction enters the Calling state after sending the initial INVITE request.

§Arguments
  • transaction_id - The transaction key for the INVITE client transaction
Source

pub async fn schedule_non_invite_client_initial_timers( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules the initial set of timers (E and F) for a non-INVITE client transaction.

§RFC 3261 Context

When a non-INVITE client transaction is initiated, it needs both:

  • Timer E for controlling retransmissions (starting at T1)
  • Timer F for overall transaction timeout (64*T1)

This method is typically called when the transaction enters the Trying state after sending the initial non-INVITE request.

§Arguments
  • transaction_id - The transaction key for the non-INVITE client transaction
Source

pub async fn schedule_invite_server_completed_timers_for_2xx( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules timers (G and H) for an INVITE server transaction that has sent a 2xx final response and is awaiting an ACK.

§RFC 3261 Context

When an INVITE server transaction sends a final response in the Completed state, it needs:

  • Timer G for controlling response retransmissions
  • Timer H as a failsafe in case no ACK is received
§Arguments
  • transaction_id - The transaction key for the INVITE server transaction
Source

pub async fn schedule_invite_server_confirmed_timer( &self, transaction_id: TransactionKey, ) -> Result<()>

Schedules Timer I for an INVITE server transaction that has received an ACK for its 2xx response.

§RFC 3261 Context

When an INVITE server transaction receives an ACK in the Completed state, it transitions to the Confirmed state and starts Timer I. When Timer I expires, the transaction terminates.

§Arguments
  • transaction_id - The transaction key for the INVITE server transaction
Source

pub async fn cancel_all_timers( &self, transaction_id: &TransactionKey, ) -> Result<()>

Cancels all active timers associated with the given transaction_id. Delegates to TimerManager::unregister_transaction.

§RFC 3261 Context

When a transaction is terminated (either normally or abnormally), all of its timers should be cancelled to prevent resource leaks and unnecessary timer events.

§Arguments
  • transaction_id - The transaction key for which to cancel all timers

Trait Implementations§

Source§

impl Clone for TimerFactory

Source§

fn clone(&self) -> TimerFactory

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TimerFactory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimerFactory

Provides default settings for TimerFactory. Creates a factory with default TimerSettings and a new default TimerManager.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,