Skip to main content

Decoder

Trait Decoder 

Source
pub trait Decoder {
    // Required methods
    fn kind(&self) -> SymbologyKind;
    fn decode(&self, modules: &BitMatrix) -> Result<String>;
}
Expand description

Recovers a payload from a module grid.

The mirror of Symbology: an encoder turns a payload into a BitMatrix, a decoder turns one back. Scanner works against this trait rather than against a concrete symbology, which is what keeps the scanning side of the crate on the same seam as the rendering side.

Required Methods§

Source

fn kind(&self) -> SymbologyKind

Which symbology this decodes.

Source

fn decode(&self, modules: &BitMatrix) -> Result<String>

Decode modules, which must hold the symbol alone, with no quiet zone.

§Errors

Returns Error::Decode if the grid has the wrong shape for this symbology, or if the module pattern is not a valid symbol.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Decoder for Code128

Available on crate feature code128 only.