Struct PeerChannel
pub struct PeerChannel<R>where
R: Ratchet,{ /* private fields */ }Implementations§
§impl<R> PeerChannel<R>where
R: Ratchet,
impl<R> PeerChannel<R>where
R: Ratchet,
pub fn upgrade(&self, restore_udp: bool) -> Result<(), NetworkError>
pub fn upgrade(&self, restore_udp: bool) -> Result<(), NetworkError>
Re-arms this connection’s P2P path campaign; see PathControl::upgrade.
pub fn path_control(&self) -> PathControl
pub fn path_control(&self) -> PathControl
A handle that can upgrade after Self::split.
pub fn take_restored_udp(&mut self) -> Option<UnboundedReceiver<UdpChannel<R>>>
pub fn take_restored_udp(&mut self) -> Option<UnboundedReceiver<UdpChannel<R>>>
The UDP channels later recoveries restore (see PathControl::upgrade), each replacing
the one before, which ended with the route it rode. Some once, on a P2P channel.
pub fn peer_protocol_version(&self) -> Option<u32>
pub fn peer_protocol_version(&self) -> Option<u32>
The other end’s PROTOCOL_VERSION: from the connect packet on a client-server channel,
and from the peer’s key-exchange signal on a P2P channel. None when the peer (or a
server relaying for it) predates carrying it.
pub fn p2p_path(&self) -> P2pPath
pub fn p2p_path(&self) -> P2pPath
The path this connection’s traffic currently takes (direct, TURN relay, or the Citadel
server). The channel is delivered as soon as it is usable, which is over the server relay:
NAT traversal runs in the background and the path changes in place, to
P2pPath::Direct or P2pPath::Turn when a P2P route attaches and back to
P2pPath::ServerRelay if it is lost. Messages keep flowing, in order and exactly once,
across every change. Use Self::ensure_direct to wait for a P2P route, or
Self::path_changes to follow the path without polling.
pub fn ensure_direct(
&self,
) -> impl Future<Output = Result<P2pPath, NetworkError>> + Send + 'static
pub fn ensure_direct( &self, ) -> impl Future<Output = Result<P2pPath, NetworkError>> + Send + 'static
Resolves once this connection runs over a P2P route, with that route’s path
(P2pPath::Direct, or P2pPath::Turn when a TURN config was supplied); resolves
Err (it never hangs) once the background campaign has ended without one — every attempt
failed, the NATs are incompatible and no TURN config was supplied, or the connection
closed. It has no timeout of its own. If a P2P route is later lost the connection falls
back to the relay and retries a bounded number of times; a new call waits for that retry.
After the campaign gave up, Self::upgrade re-arms it.
pub fn path_changes(&self) -> Receiver<P2pPathStatus>
pub fn path_changes(&self) -> Receiver<P2pPathStatus>
A receiver that wakes on every change of this connection’s path or upgrade campaign.
pub fn p2p_relayed_both(&self) -> bool
pub fn p2p_relayed_both(&self) -> bool
On a P2pPath::Turn path, whether both peers relay through their own allocation
(relay-to-relay: two TURN servers’ egress per packet) rather than one.
pub fn p2p_path_cell(&self) -> P2pPathCell
pub fn p2p_path_cell(&self) -> P2pPathCell
A handle that keeps reporting the path after Self::split.
pub fn connection_id(&self) -> Option<Ticket>
pub fn connection_id(&self) -> Option<Ticket>
The P2P connection this channel is: the id every report of its end names
(DisconnectToken::connection_id, the same on both peers). A connection that replaced
it under the same peer CID has another, so a late report of this one’s end can be told
apart. None for a C2S channel, whose session is named by channel_id.
pub fn get_peer_cid(&self) -> u64
pub fn get_peer_cid(&self) -> u64
Gets the CID of the endpoint
pub fn get_session_cid(&self) -> u64
pub fn get_session_cid(&self) -> u64
Gets the CID of the local user
pub fn get_peer_conn_type(&self) -> Option<PeerConnectionType>
pub fn get_peer_conn_type(&self) -> Option<PeerConnectionType>
Gets the metadata of the virtual connection
pub fn split(self) -> (PeerChannelSendHalf<R>, PeerChannelRecvHalf<R>)
pub fn split(self) -> (PeerChannelSendHalf<R>, PeerChannelRecvHalf<R>)
In order to use the PeerChannel properly, split must be called in order to receive an asynchronous interface. The SendHalf implements Sink, whereas the RecvHalf implements Stream
Trait Implementations§
Auto Trait Implementations§
impl<R> !RefUnwindSafe for PeerChannel<R>
impl<R> !UnwindSafe for PeerChannel<R>
impl<R> Freeze for PeerChannel<R>
impl<R> Send for PeerChannel<R>
impl<R> Sync for PeerChannel<R>
impl<R> Unpin for PeerChannel<R>
impl<R> UnsafeUnpin for PeerChannel<R>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ContextRequirements for Twhere
T: 'static,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<'a, T> LocalContextRequirements<'a> for Twhere
T: 'a,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SyncContextRequirements for Twhere
T: 'static,
§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.