pub struct Claim { /* private fields */ }Expand description
A prefix route on an origin: a claim that every path beneath a prefix can be served, answering each request as it arrives.
Created by Producer::claim. Requests arrive on Self::poll_requested; answer
each by serving a broadcast already held or by creating the path’s own Route.
Clones share one claim. Dropping the last clone retracts it and refuses the requests
still waiting. The claim keeps the origin’s Driver running.
Implementations§
Source§impl Claim
impl Claim
Sourcepub fn identity(&self) -> Identity
pub fn identity(&self) -> Identity
The stream this claim serves, minted when it was created unless
RouteOptions::with_identity named one.
Unnamed, it can change: the claim moves to a fresh identity each time an answer
holding its current one ends. See Producer::claim.
Sourcepub fn announce(&self) -> Result<(), Error>
pub fn announce(&self) -> Result<(), Error>
Make the claim visible, or keep it so. Idempotent. Visible to local consumers before it returns.
Fails with Error::Closed once the origin’s Driver was dropped.
Sourcepub fn withdraw(&self)
pub fn withdraw(&self)
Hide the claim from everyone, local and remote alike, keeping its identity:
Self::announce brings it back. Requests beneath it fail with
Error::Unroutable meanwhile. Idempotent.
Sourcepub fn is_announced(&self) -> bool
pub fn is_announced(&self) -> bool
Whether the claim 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 claim: lower wins among routes covering the same prefix and anonymity. A visible claim 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 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 origin’s Driver was dropped.
Sourcepub fn poll_requested(&self, waiter: &Waiter) -> Poll<Option<Request>>
pub fn poll_requested(&self, waiter: &Waiter) -> Poll<Option<Request>>
The next path a consumer requests beneath this claim, as a Request to answer.
Takes &self so a handler can answer from one task while another re-prices the
claim; concurrent callers each receive distinct requests. Returns None once the
claim is retracted or the origin’s Driver was dropped, so handler loops end.
Sourcepub async fn requested(&self) -> Option<Request>
pub async fn requested(&self) -> Option<Request>
The next path a consumer requests beneath this claim, as a Request to answer.
Takes &self so a handler can answer from one task while another re-prices the
claim; concurrent callers each receive distinct requests. Returns None once the
claim is retracted or the origin’s Driver was dropped, so handler loops end.
Awaits poll_requested.