pub struct TransportManager { /* private fields */ }Expand description
Keeps track of transport mode per peer and routes packets across the best available path.
Implementations§
Source§impl TransportManager
impl TransportManager
pub fn new() -> Self
pub fn with_policy(policy: FailoverPolicy) -> Self
Sourcepub fn mode_for(&self, peer: Uuid) -> TransportMode
pub fn mode_for(&self, peer: Uuid) -> TransportMode
Returns the active mode for the peer (defaults to Direct).
Sourcepub fn switch_mode(
&self,
peer: Uuid,
new_mode: TransportMode,
reason: ModeSwitchReason,
) -> Option<ModeSwitchSignal>
pub fn switch_mode( &self, peer: Uuid, new_mode: TransportMode, reason: ModeSwitchReason, ) -> Option<ModeSwitchSignal>
Forces a mode change and returns a signal to broadcast, if the mode actually changed.
Sourcepub fn route<D: TransportDispatcher>(
&self,
peer: Uuid,
packet: TransportPacket,
dispatcher: &D,
) -> Result<RouteOutcome, TransportError>
pub fn route<D: TransportDispatcher>( &self, peer: Uuid, packet: TransportPacket, dispatcher: &D, ) -> Result<RouteOutcome, TransportError>
Route a packet according to the current transport mode. If P2P is unavailable, the packet is transparently retried via relay and a mode switch signal is returned.
Sourcepub fn maybe_retry_p2p(&self, peer: Uuid) -> Option<ModeSwitchSignal>
pub fn maybe_retry_p2p(&self, peer: Uuid) -> Option<ModeSwitchSignal>
Attempt a background recovery back to P2P when backoff has elapsed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransportManager
impl !RefUnwindSafe for TransportManager
impl Send for TransportManager
impl Sync for TransportManager
impl Unpin for TransportManager
impl UnsafeUnpin for TransportManager
impl UnwindSafe for TransportManager
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