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 sink::GlobalRateLimitedSink that implements futures::Sink. * 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 ;).

Modulesยง

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

Structsยง

DirectionState ๐Ÿ”’
Rate-limiting state for a single direction.
GlobalRateLimitedConn
An AsyncRead and AsyncWrite wrapper that rate limits each direction of a single bidirectional byte stream.
GlobalRateLimitedReader
An AsyncRead wrapper that acquires bandwidth before yielding bytes.
GlobalRateLimitedSink
A Sink wrapper that acquires bandwidth before forwarding each item.
GlobalRateLimitedWriter
An AsyncWrite wrapper that acquires bandwidth before writing bytes.

Enumsยง

GlobalRateLimitedError
Error returned by the rate limiters in this module.

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.