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§
Provided Methods§
Sourcefn format_input(
&self,
field: &FieldMeta,
value: &ScalarValue,
) -> Result<String, String>
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.
Sourcefn format_result(
&self,
_field: &FieldMeta,
value: RowValue,
) -> Result<RowValue, String>
fn format_result( &self, _field: &FieldMeta, value: RowValue, ) -> Result<RowValue, String>
Convert one decoded result value into its public representation.
Sourcefn fingerprint(&self) -> u64
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§
impl Codec for BooleanCodec
impl Codec for DateCodec
Available on crate feature
chrono only.impl Codec for DateTimeCodec
impl Codec for EnumCodec
impl Codec for JsonValueCodec
Available on crate feature
json only.