Struct htb::HTB

source · []
pub struct HTB<T> {
    pub unit_cost: usize,
    /* private fields */
}
Expand description

Hierarchical Token Bucket structure

You can advance time for HTB structure using advance and advance_ns and examine/alter internal state using peek/take.

When several buckets are feeding from a single parent earlier one gets a priority

Fields

unit_cost: usize

Normalized unit cost

Implementations

Create HTB for a given bucket configuration

Buckets should be given in depth first search traversal order:

  • root with parent set to None
  • higher priority child of the root
  • followed by high priority child of the child, if any, etc.
  • followed by the next child

Advance time by number of nanoseconds

Updates internal structure, see also advance

Performance

Update cost is O(N) where N is number of buckets

Advance time by Duration

Updates internal structure, see also advance_ns

Check if there’s at least one token available at index T

See also peek_n

Check if there’s at least cnt tokens available at index T

See also peek

Consume a single token from T

See also take_n

Consume cnt tokens from T

See also take

Trait Implementations

Formats the value using the given formatter. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.