pub struct TokenBucket { /* private fields */ }

Implementations§

source§

impl TokenBucket

source

pub fn new( max_cpu_tokens: u64, cur_cpu_tokens: u64, cpu_token_recharge_rate: u64, default_cpu_cost: u64, max_message_tokens: u64, cur_message_tokens: u64, message_token_recharge_rate: u64, default_message_cost: u64 ) -> Self

source

pub fn full( max_cpu_tokens: u64, cpu_token_recharge_rate: u64, default_cpu_cost: u64, max_message_tokens: u64, message_token_recharge_rate: u64, default_message_cost: u64 ) -> Self

source

pub fn empty( max_cpu_tokens: u64, cpu_token_recharge_rate: u64, default_cpu_cost: u64, max_message_tokens: u64, message_token_recharge_rate: u64, default_message_cost: u64 ) -> Self

source

pub fn set_max_throttled_counter(&mut self, max_throttled_counter: u64)

source

pub fn throttle_default(&mut self) -> ThrottleResult

source

pub fn throttle( &mut self, cpu_cost: u64, message_size_cost: u64 ) -> ThrottleResult

Trait Implementations§

source§

impl FromStr for TokenBucket

§

type Err = String

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, String>

Parses a string s to return a value of this type. Read more
source§

impl MallocSizeOf for TokenBucket

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V