pub trait SourceEncodingDetails:
Any
+ Send
+ Sync {
// Required method
fn source_generic_quality(&self) -> Option<f32>;
// Provided method
fn is_lossless(&self) -> bool { ... }
}Expand description
Codec-agnostic interface for source encoding properties.
Implemented by each codec’s probe/detect type to provide both a
generic quality number and codec-specific details. The generic
quality uses the same 0.0–100.0 scale as
EncoderConfig::with_generic_quality().
§Downcasting
Use codec_details::<T>() to access the concrete probe type for
codec-specific fields:
if let Some(jpeg) = details.codec_details::<zenjpeg::detect::JpegProbe>() {
println!("Encoder: {:?}", jpeg.encoder);
}Required Methods§
Sourcefn source_generic_quality(&self) -> Option<f32>
fn source_generic_quality(&self) -> Option<f32>
Estimated source quality on the generic 0.0–100.0 scale.
Returns None for lossless formats (PNG, lossless WebP) or when
quality cannot be determined from the bitstream headers.
The value is approximate (±5) — different encoders map quality parameters differently, so the reverse-engineered value may not exactly match the original setting.
Provided Methods§
Sourcefn is_lossless(&self) -> bool
fn is_lossless(&self) -> bool
Whether the source encoding is lossless.
True for PNG, lossless WebP, lossless JPEG 2000, etc.
When true, source_generic_quality() typically returns None.
Implementations§
Source§impl dyn SourceEncodingDetails
impl dyn SourceEncodingDetails
Sourcepub fn codec_details<T: SourceEncodingDetails + 'static>(&self) -> Option<&T>
pub fn codec_details<T: SourceEncodingDetails + 'static>(&self) -> Option<&T>
Downcast to a concrete codec probe type.
Returns Some(&T) if the underlying type matches, None otherwise.
use zenwebp::detect::WebPProbe;
if let Some(webp) = details.codec_details::<WebPProbe>() {
println!("Lossy: {:?}", webp.bitstream);
}Source§impl dyn SourceEncodingDetails + Send
impl dyn SourceEncodingDetails + Send
Sourcepub fn codec_details<T: SourceEncodingDetails + 'static>(&self) -> Option<&T>
pub fn codec_details<T: SourceEncodingDetails + 'static>(&self) -> Option<&T>
Downcast to a concrete codec probe type.
Source§impl dyn SourceEncodingDetails + Send + Sync
impl dyn SourceEncodingDetails + Send + Sync
Sourcepub fn codec_details<T: SourceEncodingDetails + 'static>(&self) -> Option<&T>
pub fn codec_details<T: SourceEncodingDetails + 'static>(&self) -> Option<&T>
Downcast to a concrete codec probe type.