Skip to main content

CodecOptionsStruct

Trait CodecOptionsStruct 

Source
pub trait CodecOptionsStruct: Default + 'static {
    const SCHEMA: &'static [OptionField];

    // Required method
    fn apply(&mut self, key: &str, value: &OptionValue) -> Result<()>;
}
Expand description

Trait implemented by each codec’s typed options struct.

Typical hand-written implementation:

impl CodecOptionsStruct for PngEncoderOptions {
    const SCHEMA: &'static [OptionField] = &[
        OptionField {
            name: "interlace",
            kind: OptionKind::Bool,
            default: OptionValue::Bool(false),
            help: "Adam7 interlaced encode",
        },
    ];
    fn apply(&mut self, key: &str, v: &OptionValue) -> Result<()> {
        match key {
            "interlace" => self.interlace = v.as_bool()?,
            _ => unreachable!("guarded by SCHEMA"),
        }
        Ok(())
    }
}

Required Associated Constants§

Source

const SCHEMA: &'static [OptionField]

Required Methods§

Source

fn apply(&mut self, key: &str, value: &OptionValue) -> Result<()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§