1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use facet::Facet;
// r[impl connection]
// r[impl connection.root]
declare_id!(
/// Connection ID identifying a virtual connection on a link.
///
/// Connection 0 is the root connection, established implicitly when the link is created.
/// Additional connections are opened via Connect/Accept messages.
ConnectionId, u64
);
impl ConnectionId {
/// The root connection (always exists on a link).
pub const ROOT: Self = Self(0);
/// Check if this is the root connection.
pub const fn is_root(self) -> bool {
self.0 == Self::ROOT.0
}
}
declare_id!(
/// Request ID identifying an in-flight RPC request.
///
/// Request IDs are unique within a connection and monotonically increasing.
RequestId, u64
);
declare_id!(
/// ID of a channel between two peers.
ChannelId, u64
);
impl ChannelId {
/// Reserved channel ID (not usable).
pub const RESERVED: Self = Self(0);
/// Create a new channel ID, returning None if the value is 0 (reserved).
#[inline]
pub fn new(value: u64) -> Option<Self> {
if value == 0 { None } else { Some(Self(value)) }
}
}