Skip to main content

Module global_rate_limit

Module global_rate_limit 

Source
Expand description

Rate limiter objects backed by a shared crate::bw_pool::BandwidthPool making them global as in sharable accross multiple thread/tasks.

Available in this module is: * A writer::GlobalRateLimitedWriter that implements futures::AsyncWrite. * A reader::GlobalRateLimitedReader that implements futures::AsyncRead. * A conn::GlobalRateLimitedConn that implements both futures::AsyncRead and futures::AsyncWrite, rate limiting each direction independently.

Please read carefully each submodule documentation before using. These can be tricky to operate without a license ;).

Re-exportsยง

pub use conn::GlobalRateLimitedConn;
pub use reader::GlobalRateLimitedReader;
pub use writer::GlobalRateLimitedWriter;
use std::io::Error; ๐Ÿ”’
use std::num::NonZero; ๐Ÿ”’
use std::task::Context; ๐Ÿ”’
use std::task::Poll; ๐Ÿ”’
use std::task::ready; ๐Ÿ”’
use crate::bw_pool::BandwidthAcquirer; ๐Ÿ”’
use crate::bw_pool::Permit; ๐Ÿ”’

Modulesยง

conn ๐Ÿ”’
A rate limited async duplex connection.
reader ๐Ÿ”’
A rate limited async reader.
writer ๐Ÿ”’
A rate limited async writer.

Structsยง

DirectionState ๐Ÿ”’
Rate-limiting state for a single direction.

Functionsยง

to_u64 ๐Ÿ”’
Convert a usize to u64. Infallible on every platform we support.
to_usize ๐Ÿ”’
Convert a u64 to usize. Panics if the value exceeds usize::MAX.