pub struct BandwidthControllerRequestSender { /* private fields */ }Implementations§
Source§impl BandwidthControllerRequestSender
impl BandwidthControllerRequestSender
pub fn new(command_tx: UnboundedSender<BandwidthControllerRequest>) -> Self
pub async fn get_ecash_ticket( &self, ticket_type: TicketType, gateway_id: PublicKey, tickets_to_spend: u32, spend_time: OffsetDateTime, ) -> Result<Option<PreparedCredential>, BandwidthControllerError>
pub async fn get_upgrade_mode_token( &self, ) -> Result<Option<String>, BandwidthControllerError>
pub async fn attempt_revert_spending( &self, metadata: PreparedCredentialMetadata, ) -> Result<bool, BandwidthControllerError>
Sourcepub async fn set_credential_fetcher(
&self,
credential_fetcher: Arc<impl CredentialFetcher + 'static>,
) -> Result<(), BandwidthControllerError>
pub async fn set_credential_fetcher( &self, credential_fetcher: Arc<impl CredentialFetcher + 'static>, ) -> Result<(), BandwidthControllerError>
Installs the credential fetcher; the controller immediately restocks any low types.
Sourcepub async fn unset_credential_fetcher(
&self,
) -> Result<(), BandwidthControllerError>
pub async fn unset_credential_fetcher( &self, ) -> Result<(), BandwidthControllerError>
Removes the credential fetcher; no further automatic restocking happens until one is set.
Sourcepub async fn set_public_data_fetcher(
&self,
public_data_fetcher: Arc<impl CredentialPublicDataFetcher + 'static>,
) -> Result<(), BandwidthControllerError>
pub async fn set_public_data_fetcher( &self, public_data_fetcher: Arc<impl CredentialPublicDataFetcher + 'static>, ) -> Result<(), BandwidthControllerError>
Installs the global-data fetcher used to retrieve missing ecash signing materials.
Sourcepub async fn unset_public_data_fetcher(
&self,
) -> Result<(), BandwidthControllerError>
pub async fn unset_public_data_fetcher( &self, ) -> Result<(), BandwidthControllerError>
Removes the global-data fetcher.
Sourcepub async fn reset(&self) -> Result<(), BandwidthControllerError>
pub async fn reset(&self) -> Result<(), BandwidthControllerError>
Cancels in-flight fetches, drops the fetcher, clears stored credentials, and fails any parked readiness waiters. Used to fully de-provision the controller.
Sourcepub async fn clear_emergency_credentials(
&self,
) -> Result<(), BandwidthControllerError>
pub async fn clear_emergency_credentials( &self, ) -> Result<(), BandwidthControllerError>
Removes stored emergency (upgrade-mode) credentials, leaving ticketbooks intact.
Sourcepub async fn get_available_ticketbooks(
&self,
) -> Result<AvailableTicketbooks, BandwidthControllerError>
pub async fn get_available_ticketbooks( &self, ) -> Result<AvailableTicketbooks, BandwidthControllerError>
Returns the currently stored ticketbooks.
Sourcepub async fn restock_ticketbooks(
&self,
types: Vec<TicketType>,
) -> Result<(), BandwidthControllerError>
pub async fn restock_ticketbooks( &self, types: Vec<TicketType>, ) -> Result<(), BandwidthControllerError>
Kicks off a background restock for the given ticket types
Returns once the restock is scheduled - it does not wait for the fetches to finish
(use Self::wait_for_ticketbooks for that).
Not to be used lightly: the automatic triggers (ticket handout, timer, fetcher install) already keep every type stocked. This is a manual safety valve, not a routine call.
Sourcepub async fn restock_all_ticketbooks(
&self,
) -> Result<(), BandwidthControllerError>
pub async fn restock_all_ticketbooks( &self, ) -> Result<(), BandwidthControllerError>
Kicks off a background restock for every ticket type running low or about to expire. Returns once the restock is scheduled, not once the fetches finish.
Sourcepub async fn wait_for_ticketbooks(
&self,
types: Vec<TicketType>,
) -> Result<(), BandwidthControllerError>
pub async fn wait_for_ticketbooks( &self, types: Vec<TicketType>, ) -> Result<(), BandwidthControllerError>
Resolves once every listed type is usable (stocked or covered by upgrade mode). Errors if a required type is neither stocked nor being fetched; otherwise waits while the unsatisfied ones are still in flight.
Trait Implementations§
Source§impl BandwidthTicketProvider for BandwidthControllerRequestSender
impl BandwidthTicketProvider for BandwidthControllerRequestSender
fn get_ecash_ticket<'life0, 'async_trait>(
&'life0 self,
ticket_type: TicketType,
gateway_id: PublicKey,
tickets_to_spend: u32,
spend_time: OffsetDateTime,
) -> Pin<Box<dyn Future<Output = Result<Option<PreparedCredential>, BandwidthControllerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_upgrade_mode_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, BandwidthControllerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn attempt_revert_spending<'life0, 'async_trait>(
&'life0 self,
metadata: PreparedCredentialMetadata,
) -> Pin<Box<dyn Future<Output = Result<bool, BandwidthControllerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl Clone for BandwidthControllerRequestSender
impl Clone for BandwidthControllerRequestSender
Source§fn clone(&self) -> BandwidthControllerRequestSender
fn clone(&self) -> BandwidthControllerRequestSender
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BandwidthControllerRequestSender
impl RefUnwindSafe for BandwidthControllerRequestSender
impl Send for BandwidthControllerRequestSender
impl Sync for BandwidthControllerRequestSender
impl Unpin for BandwidthControllerRequestSender
impl UnsafeUnpin for BandwidthControllerRequestSender
impl UnwindSafe for BandwidthControllerRequestSender
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> Deprecatable for T
impl<T> Deprecatable for T
fn deprecate(self) -> Deprecated<Self>where
Self: Sized,
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 moreSource§impl<T> OptionalSet for T
impl<T> OptionalSet for T
Source§fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
Some), the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_validated_optional<F, T, V, E>(
self,
f: F,
value: Option<T>,
validate: V,
) -> Result<Self, E>
fn with_validated_optional<F, T, V, E>( self, f: F, value: Option<T>, validate: V, ) -> Result<Self, E>
Some) it is validated and then the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the FromStr implementation and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.Source§fn with_optional_custom_env<F, T, G>(
self,
f: F,
val: Option<T>,
env_var: &str,
parser: G,
) -> Self
fn with_optional_custom_env<F, T, G>( self, f: F, val: Option<T>, env_var: &str, parser: G, ) -> Self
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the provided parser and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.