pub struct Origin { /* private fields */ }Expand description
A relay origin, identified by a 62-bit varint on the wire.
Local origins are built with Origin::new or Origin::random, both of
which guarantee a non-zero id so loop detection can work. Remote peers may
still send 0; it is legal on the wire but cannot be used for loop detection.
Implementations§
Source§impl Origin
impl Origin
Sourcepub fn new(id: u64) -> Result<Self, InvalidOrigin>
pub fn new(id: u64) -> Result<Self, InvalidOrigin>
Build an origin from a stable id.
The id must be non-zero and fit in the 62-bit QUIC varint range. Wire decode accepts remote id 0, but local origins should not use it because downstream peers cannot exclude it for loop detection.
Sourcepub fn random() -> Self
pub fn random() -> Self
Generate a fresh origin with a random non-zero id. Use this for any origin that does not need a stable identity across restarts.
TEMPORARY: the wire format allows 62 bits, but older @moq/lite JS
clients decode AnnounceInterest.exclude_hop as a u53 (number) and
throw on anything > 2^53-1. To keep those clients alive against
fresh relays, we cap the random id at 53 bits. Restore to 62 bits
once the JS u62 fix has propagated to deployed bundles.
Sourcepub fn produce(self) -> Producer
pub fn produce(self) -> Producer
Consume this Origin to create a producer that carries its id, with an
unbounded cache pool. Use Info::produce to configure the pool.