pub trait Codec: Sync {
// Required methods
fn format(&self) -> Format;
fn matches(&self, file: &[u8]) -> bool;
fn generate(&self, spec: &PanelSpec, chip: &ChipLibrary) -> Result<Encoded>;
fn inspect(&self, file: &[u8]) -> Result<Vec<String>>;
// Provided method
fn import(
&self,
file: &[u8],
chips: ChipLookup<'_>,
) -> Result<(PanelSpec, Vec<String>)> { ... }
}Expand description
One vendor’s configuration format: a panel spec in, the card’s file out, and that file read back.
RcvbpCodec is the Colorlight implementation; a second vendor
implements this in its own crate (docs/cards.md) and adds it to
codecs.
Required Methods§
Sourcefn matches(&self, file: &[u8]) -> bool
fn matches(&self, file: &[u8]) -> bool
True when file starts the way this format’s files start; what
detect reads.
Provided Methods§
Sourcefn import(
&self,
file: &[u8],
chips: ChipLookup<'_>,
) -> Result<(PanelSpec, Vec<String>)>
fn import( &self, file: &[u8], chips: ChipLookup<'_>, ) -> Result<(PanelSpec, Vec<String>)>
The spec that regenerates file, with chips mapping a chip id to
a library, and the fields it could not recover by name. Implemented
when Format::import says so.
§Errors
Fails when file is not in the format, or the codec cannot import.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".