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§
Sourceconst SCHEMA: &'static [OptionField]
const SCHEMA: &'static [OptionField]
Static schema listing every option key this struct consumes, with its declared kind, default, and help text.
Required Methods§
Sourcefn apply(&mut self, key: &str, value: &OptionValue) -> Result<()>
fn apply(&mut self, key: &str, value: &OptionValue) -> Result<()>
Write one coerced value into the struct. key is guaranteed to
be present in SCHEMA and value to match the
declared OptionKind when called via parse_options.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".