Skip to main content

Route

Struct Route 

Source
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 stream

Clones 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

Source

pub fn broadcast(&self) -> &Producer

The broadcast this route owns, to fill with tracks.

Source

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.

Source

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.

Source

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.

Source

pub fn is_announced(&self) -> bool

Whether the route is visible.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Route

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Route

§

impl RefUnwindSafe for Route

§

impl Send for Route

§

impl Sync for Route

§

impl Unpin for Route

§

impl UnsafeUnpin for Route

§

impl UnwindSafe for Route

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more