pub struct ConnHandle(/* private fields */);Expand description
Stable, process-unique connection identifier.
Connections are identified by a monotonic 64-bit counter so the id stays unique across reconnects and across transports (TCP, QUIC).
Implementations§
Source§impl ConnHandle
impl ConnHandle
Sourcepub fn raw(self) -> u64
pub fn raw(self) -> u64
Borrow the raw 64-bit id.
§Examples
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
let addr = listener.local_addr().unwrap();
let _accept = tokio::spawn(async move {
let (s, _) = listener.accept().await.unwrap();
drop(s);
});
let s = tokio::net::TcpStream::connect(addr).await.unwrap();
let transport = Box::new(TcpTransport::new(s, ConnRole::Server));
let conn = Conn::new(transport, ConnRole::Server);
assert!(conn.handle().raw() > 0);Trait Implementations§
Source§impl Clone for ConnHandle
impl Clone for ConnHandle
Source§fn clone(&self) -> ConnHandle
fn clone(&self) -> ConnHandle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConnHandle
impl Debug for ConnHandle
Source§impl Hash for ConnHandle
impl Hash for ConnHandle
Source§impl PartialEq for ConnHandle
impl PartialEq for ConnHandle
Source§fn eq(&self, other: &ConnHandle) -> bool
fn eq(&self, other: &ConnHandle) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for ConnHandle
impl Eq for ConnHandle
impl StructuralPartialEq for ConnHandle
Auto Trait Implementations§
impl Freeze for ConnHandle
impl RefUnwindSafe for ConnHandle
impl Send for ConnHandle
impl Sync for ConnHandle
impl Unpin for ConnHandle
impl UnsafeUnpin for ConnHandle
impl UnwindSafe for ConnHandle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.