pub struct Quality(/* private fields */);
Expand description
Quality level of the brotli compression
Quality::best()
represents the best available quality that maximizes the
compression ratio at the cost of run-time speed. Quality::worst()
represents the worst available quality that maximizes speed at the expense
of compression ratio.
Implementations§
Source§impl Quality
impl Quality
Sourcepub const fn new(level: u8) -> Result<Quality, SetParameterError>
pub const fn new(level: u8) -> Result<Quality, SetParameterError>
Attempts to create a new brotli compression quality.
The range of valid qualities is from 0 to 11 inclusive, where 0 is the worst possible quality and 11 is the best possible quality.
§Errors
An Err
will be returned if the level
is out of the range of valid
qualities.
§Examples
use brotlic::Quality;
let worst_quality = Quality::new(0)?;
let best_quality = Quality::new(11)?;
assert_eq!(worst_quality, Quality::worst());
assert_eq!(best_quality, Quality::best());
Sourcepub const unsafe fn new_unchecked(level: u8) -> Quality
pub const unsafe fn new_unchecked(level: u8) -> Quality
Creates a new brotli compression quality without checking whether the
integer represents a valid quality. The range of valid qualities is from
0 to 11 inclusive, where 0 is the worst possible quality and 11 is the
best possible quality. Using any level
outside of this range will
result in undefined behaviour.
§Safety
The level
must be between 0 and 11.
§Examples
use brotlic::Quality;
// SAFETY: 5 is within the range of valid qualities from 0 to 11
let quality = unsafe { Quality::new_unchecked(5) };
assert_eq!(quality.level(), 5);
Sourcepub const fn best() -> Quality
pub const fn best() -> Quality
The highest quality for brotli compression.
This quality yields maximum compression ratio at the expense of run-time speed. It’s currently set to 11.
§Examples
use brotlic::Quality;
let best_quality = Quality::new(11)?;
assert_eq!(best_quality, Quality::best());
Sourcepub const fn default() -> Quality
pub const fn default() -> Quality
The default quality to use for brotli compression.
This is set to the best possible quality 11.
§Examples
use brotlic::Quality;
let default_quality = Quality::new(11)?;
assert_eq!(default_quality, Quality::default());
Sourcepub const fn worst() -> Quality
pub const fn worst() -> Quality
The worst quality to use for brotli compression.
This quality yields the worst compression ratio while offering the highest run-time speed. It’s currently set to 0.
§Examples
use brotlic::Quality;
let worst_quality = Quality::new(0)?;
assert_eq!(worst_quality, Quality::worst());