pub trait Format {
type In: ?Sized;
type Out;
type Buffer: ToSql + FromSql;
type SerializeError: Error;
type DeserializeError: Error;
// Required methods
fn sql_type() -> &'static str;
fn serialize(
target: &Self::In,
) -> Result<Self::Buffer, Self::SerializeError>;
fn deserialize(
data: &Self::Buffer,
) -> Result<Self::Out, Self::DeserializeError>;
}Expand description
The trait that tells collections how to serialize and deserialize their
types.
Serializers are typically built on Serde, but aren’t required to be. For
instance, Ipv4Addr can be directly stored and loaded as a SQLite INTEGER
using the From Trait, and Parse can be used for types that implement
Display and FromStr.
Required Associated Types§
Sourcetype In: ?Sized
type In: ?Sized
The type that is passed into function calls, for insertion, checking, etc. This type is serialized.
Sourcetype Buffer: ToSql + FromSql
type Buffer: ToSql + FromSql
An owned buffer, for serialization and deserialization. This is not exposed to the user.
type SerializeError: Error
type DeserializeError: Error
Required Methods§
Sourcefn sql_type() -> &'static str
fn sql_type() -> &'static str
The column type. This is not a constant, because you might want to query the SQLite version to select the best type for the version (for instance, selecting ANY for a STRICT table only where it’s available, and BLOB otherwise).
Sourcefn serialize(target: &Self::In) -> Result<Self::Buffer, Self::SerializeError>
fn serialize(target: &Self::In) -> Result<Self::Buffer, Self::SerializeError>
Serialize a borrowed target into a buffer.
Sourcefn deserialize(data: &Self::Buffer) -> Result<Self::Out, Self::DeserializeError>
fn deserialize(data: &Self::Buffer) -> Result<Self::Out, Self::DeserializeError>
Deserialize a target from a borrowed buffer.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.