Skip to main content

Codec

Trait Codec 

Source
pub trait Codec:
    Send
    + Sync
    + Debug {
    // Required methods
    fn name(&self) -> &'static str;
    fn supports(&self, field: &FieldMeta) -> bool;
    fn parse(
        &self,
        field: &FieldMeta,
        input: &str,
    ) -> Result<ScalarValue, String>;

    // Provided methods
    fn format_input(
        &self,
        field: &FieldMeta,
        value: &ScalarValue,
    ) -> Result<String, String> { ... }
    fn format_result(
        &self,
        _field: &FieldMeta,
        value: RowValue,
    ) -> Result<RowValue, String> { ... }
    fn fingerprint(&self) -> u64 { ... }
}
Expand description

A server-owned input/result conversion codec.

Required Methods§

Source

fn name(&self) -> &'static str

Stable name used in schema and policy fingerprints.

Source

fn supports(&self, field: &FieldMeta) -> bool

Whether this codec handles the field.

Source

fn parse(&self, field: &FieldMeta, input: &str) -> Result<ScalarValue, String>

Convert one external value into the field’s validated query value.

Provided Methods§

Source

fn format_input( &self, field: &FieldMeta, value: &ScalarValue, ) -> Result<String, String>

Canonical RPC representation. Encoders verify that parsing this text recovers the original database value; lossy codecs must override it.

Source

fn format_result( &self, _field: &FieldMeta, value: RowValue, ) -> Result<RowValue, String>

Convert one decoded result value into its public representation.

Source

fn fingerprint(&self) -> u64

Stable identity including codec configuration.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Codec for BooleanCodec

Source§

impl Codec for DateCodec

Available on crate feature chrono only.
Source§

impl Codec for DateTimeCodec

Source§

impl Codec for EnumCodec

Source§

impl Codec for JsonValueCodec

Available on crate feature json only.
Source§

impl Codec for ListResultCodec

Source§

impl Codec for ScalarTextCodec

Source§

impl Codec for StringCodec

Source§

impl Codec for TimeCodec

Source§

impl Codec for TimestampCodec