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
impl TimerFactory
Sourcepub fn new(
settings: Option<TimerSettings>,
timer_manager: Arc<TimerManager>,
) -> Self
pub fn new( settings: Option<TimerSettings>, timer_manager: Arc<TimerManager>, ) -> Self
Creates a new TimerFactory.
§Arguments
settings- OptionalTimerSettingsto configure timer durations. IfNone, default settings are used.timer_manager- AnArc<TimerManager>that will manage the timers scheduled by this factory.
Sourcepub fn settings(&self) -> &TimerSettings
pub fn settings(&self) -> &TimerSettings
Returns a reference to the TimerSettings used by this factory.
Sourcepub fn timer_manager(&self) -> Arc<TimerManager>
pub fn timer_manager(&self) -> Arc<TimerManager>
Returns a clone of the Arc<TimerManager> used by this factory.
Sourcepub async fn schedule_timer_a(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_b(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_d(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_e(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_f(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_g(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_h(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_i(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_j(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_timer_k(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_invite_client_initial_timers(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_non_invite_client_initial_timers(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_invite_server_completed_timers_for_2xx(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn schedule_invite_server_confirmed_timer(
&self,
transaction_id: TransactionKey,
) -> Result<()>
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
Sourcepub async fn cancel_all_timers(
&self,
transaction_id: &TransactionKey,
) -> Result<()>
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
impl Clone for TimerFactory
Source§fn clone(&self) -> TimerFactory
fn clone(&self) -> TimerFactory
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TimerFactory
impl Debug for TimerFactory
Source§impl Default for TimerFactory
Provides default settings for TimerFactory.
Creates a factory with default TimerSettings and a new default TimerManager.
impl Default for TimerFactory
Provides default settings for TimerFactory.
Creates a factory with default TimerSettings and a new default TimerManager.