Skip to content

Commit

Permalink
Merge pull request #878 from piodul/docstrings-and-tests
Browse files Browse the repository at this point in the history
serialize: add more tests and docstrings
  • Loading branch information
piodul authored Dec 14, 2023
2 parents 969d37e + 7cf355b commit 10b49ef
Show file tree
Hide file tree
Showing 6 changed files with 808 additions and 61 deletions.
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

0 comments on commit 10b49ef

Please sign in to comment.