pub struct Route { /* private fields */ }Expand description
An exact route on an origin: one path, owning the broadcast published there.
On the publishing side ownership runs origin → route → broadcast → track → group →
frame. Created by Producer::route, or by Request::route to answer a request
with the path’s own route. A prefix served on demand is a Claim instead.
A route mints its identity when it is created and keeps it for its lifetime, across
withdraw, announce and reconnects, since it
owns the same broadcast and its keys continue. A new run is a new route.
use moq_net::origin::RouteOptions;
// Fill the catalog before readers can find it.
let route = origin.route("live/alice", RouteOptions::hidden())?;
let _catalog = route.broadcast().create_track("catalog.json", None).ok_or(moq_net::Error::Duplicate)?;
route.announce()?; // visible now, same identity
route.set_cost(5)?; // re-prices in place
route.withdraw(); // hidden; announce() again continues the same streamClones share one route. Dropping the last clone retracts it, and so does closing
its broadcast. The broadcast lives on for the subscriptions already on it for as
long as another of its producer handles does. The route keeps the origin’s
Driver running, so a publisher can drop every Producer and keep serving.
Implementations§
Source§impl Route
impl Route
Sourcepub fn identity(&self) -> Identity
pub fn identity(&self) -> Identity
The stream this route serves, minted when it was created unless
RouteOptions::with_identity named one.
A job’s route (Request::route) naming none takes its claim’s current one when it
first announces, or when this reads it first. Read before announcing, it is the one
the job announces under, and Self::announce fails with Error::Unroutable once
the claim has moved past it.
Sourcepub fn announce(&self) -> Result<(), Error>
pub fn announce(&self) -> Result<(), Error>
Make the route visible, or keep it so. Idempotent.
Visible to local consumers before it returns. A job’s route (Request::route)
also answers the requesters waiting on its path.
Fails with Error::Closed once the route’s broadcast closed or the origin’s
Driver was dropped, and with Error::Unroutable, announcing nothing, when a
job’s request was released or its claim retracted meanwhile, or when the job read
its identity and its claim has moved past it since: that route
can never announce. In that last case the request goes back to the claim’s handler,
its requesters still waiting.
Sourcepub fn withdraw(&self)
pub fn withdraw(&self)
Hide the route from everyone, local and remote alike, keeping its broadcast and
identity: Self::announce brings the same stream back. Requests for the path
fail with Error::Unroutable meanwhile, while tracks already in flight carry
on to their own end. Idempotent.
Sourcepub fn is_announced(&self) -> bool
pub fn is_announced(&self) -> bool
Whether the route is visible.
Sourcepub fn set_cost(&self, cost: impl Into<Cost>) -> Result<(), Error>
pub fn set_cost(&self, cost: impl Into<Cost>) -> Result<(), Error>
Re-price the route: lower wins among routes covering the same prefix and anonymity. A visible route changes in place, as an update to its readers; a hidden one keeps the price for when it next announces.
Fails with Error::Closed once the route’s broadcast closed or the origin’s
Driver was dropped.
Sourcepub fn set_auth(&self, auth: Option<Credential>) -> Result<(), Error>
pub fn set_auth(&self, auth: Option<Credential>) -> Result<(), Error>
Swap the credential the advertising request carries; see RouteOptions::with_auth.
None advertises under the session’s scope.
Fails with Error::Closed once the route’s broadcast closed or the origin’s
Driver was dropped.