Skip to main content

Codec

Trait Codec 

Source
pub trait Codec: Send + Sync {
    // Required methods
    fn mime_type(&self) -> &str;
    fn encode_grid(&self, grid: &HGrid) -> Result<String, CodecError>;
    fn decode_grid(&self, input: &str) -> Result<HGrid, CodecError>;
    fn encode_scalar(&self, val: &Kind) -> Result<String, CodecError>;
    fn decode_scalar(&self, input: &str) -> Result<Kind, CodecError>;
}
Expand description

Trait for Haystack wire format codecs.

Required Methods§

Source

fn mime_type(&self) -> &str

The MIME type for this codec (e.g. "text/zinc").

Source

fn encode_grid(&self, grid: &HGrid) -> Result<String, CodecError>

Encode an HGrid to a string.

Source

fn decode_grid(&self, input: &str) -> Result<HGrid, CodecError>

Decode a string to an HGrid.

Source

fn encode_scalar(&self, val: &Kind) -> Result<String, CodecError>

Encode a single scalar Kind value to a string.

Source

fn decode_scalar(&self, input: &str) -> Result<Kind, CodecError>

Decode a string to a single scalar Kind value.

Implementors§