[][src]Struct sequoia_openpgp::types::CompressionLevel

pub struct CompressionLevel(_);

Compression level.

This value is used by the encoders to tune their compression strategy. The level is restricted to levels commonly used by compression libraries, 0 to 9, where 0 means no compression, 1 means fastest compression, 6 being a good default, and meaning 9 best compression.

Note that compression is dangerous when used naively. To mitigate some of these issues messages should use padding.

Examples

Write a message using the given CompressionAlgorithm:

use sequoia_openpgp as openpgp;
use std::io::Write;
use openpgp::serialize::stream::{Message, Compressor, LiteralWriter};
use openpgp::serialize::stream::padding::{Padder, padme};
use openpgp::types::{CompressionAlgorithm, CompressionLevel};

let mut sink = Vec::new();
let message = Message::new(&mut sink);
let message = Compressor::new(message)
    .algo(CompressionAlgorithm::Zlib)
    .level(CompressionLevel::fastest())
    .build()?;

let message = Padder::new(message, padme)?;

let mut message = LiteralWriter::new(message).build()?;
message.write_all(b"Hello world.")?;
message.finalize()?;

Implementations

impl CompressionLevel[src]

pub fn new(level: u8) -> Result<CompressionLevel>[src]

Creates a new compression level.

level must be in range 0..10, where 0 means no compression, 1 means fastest compression, 6 being a good default, and meaning 9 best compression.

pub fn none() -> CompressionLevel[src]

No compression.

pub fn fastest() -> CompressionLevel[src]

Fastest compression.

pub fn best() -> CompressionLevel[src]

Best compression.

Trait Implementations

impl Clone for CompressionLevel[src]

impl Copy for CompressionLevel[src]

impl Debug for CompressionLevel[src]

impl Default for CompressionLevel[src]

impl Eq for CompressionLevel[src]

impl From<CompressionLevel> for Compression[src]

impl From<CompressionLevel> for Compression[src]

impl Hash for CompressionLevel[src]

impl Ord for CompressionLevel[src]

impl PartialEq<CompressionLevel> for CompressionLevel[src]

impl PartialOrd<CompressionLevel> for CompressionLevel[src]

impl StructuralEq for CompressionLevel[src]

impl StructuralPartialEq for CompressionLevel[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.