Skip to main content

Codec

Trait Codec 

Source
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§

Source

fn format(&self) -> Format

The registry entry.

Source

fn matches(&self, file: &[u8]) -> bool

True when file starts the way this format’s files start; what detect reads.

Source

fn generate(&self, spec: &PanelSpec, chip: &ChipLibrary) -> Result<Encoded>

The file for spec and its chip library.

§Errors

Fails on a spec or library the format cannot hold.

Source

fn inspect(&self, file: &[u8]) -> Result<Vec<String>>

One line per record of file, as rxp config info lists them.

§Errors

Fails when file is not in the format.

Provided Methods§

Source

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".

Implementors§