pub struct FederationPull { /* private fields */ }Expand description
A peer server pulling one album it holds a capability for.
Implementations§
Source§impl FederationPull
impl FederationPull
Sourcepub fn new(
base_url: &str,
album_id: impl Into<String>,
token: impl Into<String>,
jti: impl Into<String>,
signer: Arc<dyn RequestSigner>,
) -> Result<Self, FederationError>
pub fn new( base_url: &str, album_id: impl Into<String>, token: impl Into<String>, jti: impl Into<String>, signer: Arc<dyn RequestSigner>, ) -> Result<Self, FederationError>
A puller against base_url, presenting token for album_id, signing every request
with signer.
jti is the token’s own identifier as the home server minted it — the key the revocation
list is checked against. It is passed in rather than parsed out of the token, because
this module holds no JWT parser and a client that read its own credential’s claims would
be trusting a value it never verified.
signer holds the key the home server pinned for this peer; a request it did not sign
is refused 401 however good the token is.
§Errors
FederationError::Transport when base_url is not a URL a client can hang paths off.
Sourcepub fn token(&self) -> String
pub fn token(&self) -> String
The token currently held, for a caller that persists it across restarts.
Sourcepub async fn poll_revocations(
&self,
) -> Result<RevocationSnapshot, FederationError>
pub async fn poll_revocations( &self, ) -> Result<RevocationSnapshot, FederationError>
Fetch the issuer’s revocation list and keep it as this puller’s snapshot.
§Errors
FederationError::Refused or FederationError::Transport; the snapshot is left
as it was, and the next Self::admit will refuse once the old one goes stale.
Sourcepub async fn admit(&self) -> Result<(), FederationError>
pub async fn admit(&self) -> Result<(), FederationError>
Refuse unless the held capability is admissible right now.
Refreshes the snapshot when the held one is past the issuer’s own bound. Every pull goes through here, so a revoked grant stops the pull rather than being discovered one refusal at a time.
§Errors
FederationError::Revoked when the issuer refuses this jti;
FederationError::ListStale when the list could not be refreshed inside its bound.
Sourcepub async fn page(
&self,
cursor: &SyncCursor,
page_size: u32,
) -> Result<SyncPage, FederationError>
pub async fn page( &self, cursor: &SyncCursor, page_size: u32, ) -> Result<SyncPage, FederationError>
Pull one page of the album this capability covers.
§Errors
As Self::admit, plus whatever the feed answered.
Sourcepub async fn blob(
&self,
hash: &str,
expected_len: u64,
) -> Result<Vec<u8>, FederationError>
pub async fn blob( &self, hash: &str, expected_len: u64, ) -> Result<Vec<u8>, FederationError>
Fetch one blob the page named, verified against its own address.
The bytes are self-verifying: crate::fetch::fetch_blob hashes what arrives and
refuses anything that is not the address asked for, so a home server cannot substitute
content for a peer any more than it can for its own client.
§Errors
As Self::admit, plus FederationError::Refused carrying the fetch’s own reason —
error.federation.scope_insufficient for a blob outside the grant’s scope among them.
Sourcepub async fn refresh(&self) -> Result<String, FederationError>
pub async fn refresh(&self) -> Result<String, FederationError>
Exchange the held capability for its successor, and pull with that from now on.
Idempotent at the server: a replay of the same predecessor answers the same successor, so a puller that crashed between the call and persisting the answer gets the same token back rather than a second grant.
§Errors
FederationError::Refused when the issuer will not continue the grant — a revoked
predecessor, a blocked peer, a spent budget, a member no longer on the roster
(error.federation.member_not_on_roster) — or FederationError::Transport.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FederationPull
impl !RefUnwindSafe for FederationPull
impl !UnwindSafe for FederationPull
impl Send for FederationPull
impl Sync for FederationPull
impl Unpin for FederationPull
impl UnsafeUnpin for FederationPull
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more