pub struct ConnectionId(/* private fields */);Expand description
Which connection an event is about.
Process-wide and monotonic, so a Closed can be matched to the
Connected that opened the same socket — which is the only reason
it exists. Without it a close event says “a connection ended” and a
caller holding several has no way to learn which.
ConnectionId::UNWATCHED is what an event carries when there was no
id to mint for it — because nobody is watching, or because there is no
connection. See that constant.
Implementations§
Source§impl ConnectionId
impl ConnectionId
Sourcepub const UNWATCHED: ConnectionId
pub const UNWATCHED: ConnectionId
The id an event carries when no id was minted for it.
Two things produce it, and a reader can only ever meet the second:
- Nobody is watching.
Hooks::WATCHINGisfalse, so a transport that owns connections leaves the counter alone rather than paying an atomic per connection for nobody. That const’s own question is whether anything reads these events, so a build producing this value for this reason has, by its own declaration, no reader for the event carrying it. - There is no connection to name.
hclient-fetchandhclient-wasiown none — the Fetch Standard exposes no connection object, and there is no connection resource anywhere inwasi:http@0.3.0— so their one event,Head, carries this.
To a hook that reads events it therefore means exactly one thing,
this event names no connection, and that is something a portable
hook can act on rather than a gap it has to guess at: it is the
only id ConnectionId::next never returns, so looking it up in
a table of live connections cannot hit one.
§The name is a producer, not the meaning
There is deliberately no second constant meaning this event names
no connection, distinct from nobody is watching: the two would
differ only in a build whose events nobody reads, so no caller
decision turns on the difference — this workspace’s test for
whether a distinction earns a name of its own. UNWATCHED names
one of the two producers, and any spelling would name one or the
other; read it as the ambient this event names no connection.
Sourcepub fn next() -> Self
pub fn next() -> Self
The next id. Relaxed: this counter orders nothing, it only has
to hand out distinct numbers.
It starts at 1, and that is load bearing rather than tidy: it is
what makes UNWATCHED mean this event names no
connection rather than this event names connection zero.
crates/hclient-core/tests/shape.rs pins it.
Trait Implementations§
Source§impl Clone for ConnectionId
impl Clone for ConnectionId
Source§fn clone(&self) -> ConnectionId
fn clone(&self) -> ConnectionId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more