Skip to main content

CyclesAccounting

Struct CyclesAccounting 

Source
pub struct CyclesAccounting<ChargingPolicy> { /* private fields */ }
Expand description

A middleware to handle cycles accounting, i.e. verify if sufficiently many cycles are available in a request. The cost of sending the request is calculated by ic_cdk_management_canister::cost_http_request.

Implementations§

Source§

impl<ChargingPolicy> CyclesAccounting<ChargingPolicy>

Source

pub fn new(charging_policy: ChargingPolicy) -> Self

Create a new middleware given the charging policy.

Trait Implementations§

Source§

impl<ChargingPolicy: Clone> Clone for CyclesAccounting<ChargingPolicy>

Source§

fn clone(&self) -> CyclesAccounting<ChargingPolicy>

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

impl<ChargingPolicy: Debug> Debug for CyclesAccounting<ChargingPolicy>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<ChargingPolicy> Filter<HttpRequestArgs> for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: CyclesChargingPolicy,

Source§

type Error = <ChargingPolicy as CyclesChargingPolicy>::Error

Error type if the input is declared invalid.
Source§

fn filter( &mut self, request: HttpRequestArgs, ) -> Result<HttpRequestArgs, Self::Error>

Filter the input and return an error if it fails.

Auto Trait Implementations§

§

impl<ChargingPolicy> Freeze for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: Freeze,

§

impl<ChargingPolicy> RefUnwindSafe for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: RefUnwindSafe,

§

impl<ChargingPolicy> Send for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: Send,

§

impl<ChargingPolicy> Sync for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: Sync,

§

impl<ChargingPolicy> Unpin for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: Unpin,

§

impl<ChargingPolicy> UnsafeUnpin for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: UnsafeUnpin,

§

impl<ChargingPolicy> UnwindSafe for CyclesAccounting<ChargingPolicy>
where ChargingPolicy: UnwindSafe,

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<Input, F> Convert<Input> for F
where F: Filter<Input>,

Source§

type Output = Input

Converted type if the conversion succeeds.
Source§

type Error = <F as Filter<Input>>::Error

Error type if the conversion fails
Source§

fn try_convert( &mut self, response: Input, ) -> Result<<F as Convert<Input>>::Output, <F as Convert<Input>>::Error>

Try to convert an instance of the input type to the output type. The conversion may fail, in which case an error is returned.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.