pub struct ConnectionStrategy { /* private fields */ }Expand description
Connection strategy state machine
Manages the progression through connection methods from fastest (direct) to most reliable (relay).
Implementations§
Source§impl ConnectionStrategy
impl ConnectionStrategy
Sourcepub fn new(config: StrategyConfig) -> Self
pub fn new(config: StrategyConfig) -> Self
Create a new connection strategy with the given configuration
Sourcepub fn current_stage(&self) -> &ConnectionStage
pub fn current_stage(&self) -> &ConnectionStage
Get the current stage
Sourcepub fn config(&self) -> &StrategyConfig
pub fn config(&self) -> &StrategyConfig
Get the configuration
Sourcepub fn ipv4_timeout(&self) -> Duration
pub fn ipv4_timeout(&self) -> Duration
Get the IPv4 timeout
Sourcepub fn ipv6_timeout(&self) -> Duration
pub fn ipv6_timeout(&self) -> Duration
Get the IPv6 timeout
Sourcepub fn holepunch_timeout(&self) -> Duration
pub fn holepunch_timeout(&self) -> Duration
Get the hole-punch timeout
Sourcepub fn relay_timeout(&self) -> Duration
pub fn relay_timeout(&self) -> Duration
Get the relay timeout
Sourcepub fn transition_to_ipv6(&mut self, error: impl Into<String>)
pub fn transition_to_ipv6(&mut self, error: impl Into<String>)
Record an error and transition to IPv6 stage
Sourcepub fn transition_to_holepunch(&mut self, error: impl Into<String>)
pub fn transition_to_holepunch(&mut self, error: impl Into<String>)
Record an error and transition to hole-punching stage
Sourcepub fn record_holepunch_error(&mut self, round: u32, error: impl Into<String>)
pub fn record_holepunch_error(&mut self, round: u32, error: impl Into<String>)
Record a hole-punch error and either retry or transition to relay
Sourcepub fn should_retry_holepunch(&self) -> bool
pub fn should_retry_holepunch(&self) -> bool
Check if we should retry hole-punching
Sourcepub fn increment_round(&mut self)
pub fn increment_round(&mut self)
Increment the hole-punch round
Sourcepub fn transition_to_relay(&mut self, error: impl Into<String>)
pub fn transition_to_relay(&mut self, error: impl Into<String>)
Transition to relay stage
Sourcepub fn transition_to_failed(&mut self, error: impl Into<String>)
pub fn transition_to_failed(&mut self, error: impl Into<String>)
Transition to failed state
Sourcepub fn mark_connected(&mut self, method: ConnectionMethod)
pub fn mark_connected(&mut self, method: ConnectionMethod)
Mark connection as successful via the specified method
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if the strategy has reached a terminal state
Sourcepub fn errors(&self) -> &[ConnectionAttemptError]
pub fn errors(&self) -> &[ConnectionAttemptError]
Get all recorded errors
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConnectionStrategy
impl RefUnwindSafe for ConnectionStrategy
impl Send for ConnectionStrategy
impl Sync for ConnectionStrategy
impl Unpin for ConnectionStrategy
impl UnwindSafe for ConnectionStrategy
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