Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialize: add more tests and docstrings #878

Merged
merged 7 commits into from
Dec 14, 2023
Merged
1 change: 1 addition & 0 deletions scylla-cql/src/frame/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct ValueTooBig;
pub struct ValueOverflow;

/// Represents an unset value
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Unset;

/// Represents an counter value
Expand Down
23 changes: 23 additions & 0 deletions scylla-cql/src/types/serialize/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#![warn(missing_docs)]

//! Types and traits related to serialization of values to the CQL format.

use std::{error::Error, fmt::Display, sync::Arc};

use thiserror::Error;
Expand All @@ -7,6 +11,25 @@ pub mod value;
pub mod writers;

pub use writers::{CellValueBuilder, CellWriter, RowWriter};

/// An error indicating that a failure happened during serialization.
///
/// The error is type-erased so that the crate users can define their own
/// serialization impls and their errors. As for the impls defined or generated
/// by the driver itself, the following errors can be returned:
///
/// - [`row::BuiltinSerializationError`] is returned when serialization of
/// one of types with an impl built into the driver fails. It is also returned
/// from impls generated by the `SerializeRow` macro.
/// - [`value::BuiltinSerializationError`] is analogous to the above but is
/// returned from [`SerializeCql::serialize`](value::SerializeCql::serialize)
/// instead both in the case of builtin impls and impls generated by the
/// `SerializeCql` macro. It won't be returned by the `Session` directly,
/// but it might be nested in the [`row::BuiltinSerializationError`].
/// - [`row::ValueListToSerializeRowAdapterError`] is returned in case when
/// a list of named values encoded with the legacy `ValueList` trait is passed
/// as an argument to the statement, and rewriting it using the new
/// `SerializeRow` interface fails.
#[derive(Debug, Clone, Error)]
pub struct SerializationError(Arc<dyn Error + Send + Sync>);

Expand Down
Loading