Struct vapcore_light::net::request_credits::FlowParams [−][src]
Handles costs, recharge, limits of request credits.
Implementations
impl FlowParams
[src]
pub fn new(limit: U256, costs: CostTable, recharge: U256) -> Self
[src]
Create new flow parameters from a request cost table, credit limit, and (minimum) rate of recharge.
pub fn from_request_times<F: Fn(Kind) -> Duration>(
request_time: F,
load_share: f64,
max_stored: Duration
) -> Self
[src]
request_time: F,
load_share: f64,
max_stored: Duration
) -> Self
Create new flow parameters from , proportion of total capacity which should be given to a peer, and stored capacity a peer can accumulate.
pub fn free() -> Self
[src]
Create effectively infinite flow params.
pub fn limit(&self) -> &U256
[src]
Get a reference to the credit limit.
pub fn cost_table(&self) -> &CostTable
[src]
Get a reference to the cost table.
pub fn base_cost(&self) -> U256
[src]
Get the base cost of a request.
pub fn recharge_rate(&self) -> &U256
[src]
Get a reference to the recharge rate.
pub fn compute_cost(&self, request: &Request) -> Option<U256>
[src]
Compute the actual cost of a request, given the kind of request and number of requests made.
pub fn compute_cost_multi(&self, requests: &[Request]) -> Option<U256>
[src]
Compute the cost of a set of requests. This is the base cost plus the cost of each individual request.
pub fn create_credits(&self) -> Credits
[src]
Create initial credits.
pub fn recharge(&self, credits: &mut Credits)
[src]
Recharge the given credits based on time passed since last update.
pub fn refund(&self, credits: &mut Credits, refund_amount: U256)
[src]
Refund some credits which were previously deducted. Does not update the recharge timestamp.
Trait Implementations
impl Clone for FlowParams
[src]
fn clone(&self) -> FlowParams
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for FlowParams
[src]
impl Default for FlowParams
[src]
impl PartialEq<FlowParams> for FlowParams
[src]
fn eq(&self, other: &FlowParams) -> bool
[src]
fn ne(&self, other: &FlowParams) -> bool
[src]
impl StructuralPartialEq for FlowParams
[src]
Auto Trait Implementations
impl RefUnwindSafe for FlowParams
impl Send for FlowParams
impl Sync for FlowParams
impl Unpin for FlowParams
impl UnwindSafe for FlowParams
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> MaybeDebug for T where
T: Debug,
[src]
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,
[src]
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,
[src]
T: Debug,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,