pub enum Compression {
Plaintext,
Gzip,
Zstd,
Lzma,
}Expand description
Compression formats supported for descriptor downloads.
Directory servers can compress responses to reduce bandwidth usage. Clients advertise which formats they support, and the server uses the best mutually supported format.
§Compression Comparison
| Format | Compression | Speed | Support |
|---|---|---|---|
| Plaintext | None | Fastest | Universal |
| Gzip | Good | Fast | Universal |
| Zstd | Better | Faster | Modern Tor |
| Lzma | Best | Slower | Modern Tor |
§Example
use stem_rs::descriptor::remote::Compression;
let formats = [Compression::Zstd, Compression::Gzip, Compression::Plaintext];
for fmt in &formats {
println!("Encoding: {}", fmt.encoding());
}Variants§
Plaintext
No compression (identity encoding).
Data is transferred as-is without any compression. Always supported but uses the most bandwidth.
Gzip
Gzip compression (RFC 1952).
Good compression ratio with fast decompression. Universally supported by all Tor versions.
Zstd
Zstandard compression.
Better compression ratio than gzip with faster decompression. Supported by modern Tor versions (0.3.1+).
Lzma
LZMA compression.
Best compression ratio but slower decompression. Supported by modern Tor versions.
Implementations§
Source§impl Compression
impl Compression
Sourcepub fn encoding(&self) -> &'static str
pub fn encoding(&self) -> &'static str
Returns the HTTP Accept-Encoding value for this compression format.
This is the string used in HTTP headers to indicate support for this compression format.
§Returns
The encoding name as used in HTTP headers.
§Example
use stem_rs::descriptor::remote::Compression;
assert_eq!(Compression::Gzip.encoding(), "gzip");
assert_eq!(Compression::Plaintext.encoding(), "identity");Trait Implementations§
Source§impl Clone for Compression
impl Clone for Compression
Source§fn clone(&self) -> Compression
fn clone(&self) -> Compression
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more