Trait scylla_cql::types::serialize::value::SerializeValue
source · pub trait SerializeValue {
// Required method
fn serialize<'b>(
&self,
typ: &ColumnType<'_>,
writer: CellWriter<'b>,
) -> Result<WrittenCellProof<'b>, SerializationError>;
}
Expand description
A type that can be serialized and sent along with a CQL statement.
This is a low-level trait that is exposed to the specifics to the CQL protocol and usually does not have to be implemented directly. See the chapter on “Query Values” in the driver docs for information about how this trait is supposed to be used.
Required Methods§
sourcefn serialize<'b>(
&self,
typ: &ColumnType<'_>,
writer: CellWriter<'b>,
) -> Result<WrittenCellProof<'b>, SerializationError>
fn serialize<'b>( &self, typ: &ColumnType<'_>, writer: CellWriter<'b>, ) -> Result<WrittenCellProof<'b>, SerializationError>
Serializes the value to given CQL type.
The value should produce a [value]
, according to the CQL protocol
specification,
containing the serialized value. See section 6 of the document on how
the contents of the [value]
should look like.
The value produced should match the type provided by typ
. If the
value cannot be serialized to that type, an error should be returned.
The CellWriter
provided to the method ensures that the value produced
will be properly framed (i.e. incorrectly written value should not
cause the rest of the request to be misinterpreted), but otherwise
the implementor of the trait is responsible for producing the value
in a correct format.