pub struct CredentialSlot { /* private fields */ }Expand description
A delegated fetch’s voucher credential, which the application can swap at any time. Clones share one slot.
A source provider reads Self::current when it builds a lane, and puts
its key and capability in the lane’s PoolContext. After a
Self::swap, the fetch ends every live lane on the old key at its next
voucher boundary, paid for what it received, and opens new lanes under the
new credential. A registered signer’s terms are write-once on chain, so a
new capability names a new signer key.
Implementations§
Source§impl CredentialSlot
impl CredentialSlot
Sourcepub fn new(
signer: Arc<PrivateKeySigner>,
capability: SignedCapability,
) -> Result<Self, CredentialMismatch>
pub fn new( signer: Arc<PrivateKeySigner>, capability: SignedCapability, ) -> Result<Self, CredentialMismatch>
A slot that holds capability for signer, with the
CREDENTIAL_SWAP_WAIT wait.
§Errors
CredentialMismatch when the capability names another signer.
Sourcepub fn with_swap_wait(self, wait: Duration) -> Self
pub fn with_swap_wait(self, wait: Duration) -> Self
Wait wait for a swap at the exhausted candidate set. The slot and
every clone of it share the wait.
Sourcepub fn record_spend(&self, signer: Address, spent: U256)
pub fn record_spend(&self, signer: Address, spent: U256)
Record that earlier fetches signed spent micro-USDC of vouchers under
signer, across every lane the application’s local records hold for
it, at any provider. The fetch counts it toward the capability’s spend
for the running-low signal and the FundingNeeded cause, on top of
what its own lanes sign past their recorded priors. One key’s record
is held at a time; a key with no record counts from zero.
Sourcepub fn swap(
&self,
signer: Arc<PrivateKeySigner>,
capability: SignedCapability,
) -> Result<(), CredentialMismatch>
pub fn swap( &self, signer: Arc<PrivateKeySigner>, capability: SignedCapability, ) -> Result<(), CredentialMismatch>
Put capability for signer in the slot. Every fetch that holds the
slot retires its lanes on the old key and goes on under this one.
§Errors
CredentialMismatch when the capability names another signer. The
slot keeps its credential.
Sourcepub fn current(&self) -> Credential
pub fn current(&self) -> Credential
The credential a new lane signs under.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
How many swaps the slot has taken.
Sourcepub fn swap_wait(&self) -> Duration
pub fn swap_wait(&self) -> Duration
How long a fetch at the exhausted candidate set waits for a swap.
Sourcepub fn funding_events(&self) -> Receiver<Option<FundingEvent>>
pub fn funding_events(&self) -> Receiver<Option<FundingEvent>>
The fetch’s funding signal: the latest FundingEvent, or None
while the credential covers the work. The value changes when the
signal changes.
Trait Implementations§
Source§impl Clone for CredentialSlot
impl Clone for CredentialSlot
Auto Trait Implementations§
impl !RefUnwindSafe for CredentialSlot
impl !UnwindSafe for CredentialSlot
impl Freeze for CredentialSlot
impl Send for CredentialSlot
impl Sync for CredentialSlot
impl Unpin for CredentialSlot
impl UnsafeUnpin for CredentialSlot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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