Skip to content

Commit

Permalink
Move scylla-cql/frame/value.rs to scylla-cql/value.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorak-mmk committed Jan 31, 2025
1 parent 9fc9069 commit 62fa3a8
Show file tree
Hide file tree
Showing 25 changed files with 50 additions and 51 deletions.
2 changes: 1 addition & 1 deletion docs/source/data-types/counter.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use futures::TryStreamExt;
use scylla::frame::value::Counter;
use scylla::value::Counter;

// Add to counter value
let to_add: Counter = Counter(100);
Expand Down
4 changes: 2 additions & 2 deletions docs/source/data-types/date.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Internally [date](https://docs.scylladb.com/stable/cql/types.html#dates) is repr

## CqlDate

Without any extra features enabled, only `frame::value::CqlDate` is available. It's an
Without any extra features enabled, only `value::CqlDate` is available. It's an
[`u32`](https://doc.rust-lang.org/std/primitive.u32.html) wrapper and it matches the internal date representation.

However, for most use cases other types are more practical. See following sections for `chrono` and `time`.
Expand All @@ -18,7 +18,7 @@ However, for most use cases other types are more practical. See following sectio
# use scylla::client::session::Session;
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use scylla::frame::value::CqlDate;
use scylla::value::CqlDate;
use futures::TryStreamExt;

// 1970-01-08
Expand Down
2 changes: 1 addition & 1 deletion docs/source/data-types/decimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Without any feature flags, the user can interact with `decimal` type by making u
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use futures::TryStreamExt;
use scylla::frame::value::CqlDecimal;
use scylla::value::CqlDecimal;
use std::str::FromStr;

// Insert a decimal (123.456) into the table
Expand Down
2 changes: 1 addition & 1 deletion docs/source/data-types/duration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use futures::TryStreamExt;
use scylla::frame::value::CqlDuration;
use scylla::value::CqlDuration;

// Insert some duration into the table
let to_insert: CqlDuration = CqlDuration { months: 1, days: 2, nanoseconds: 3 };
Expand Down
4 changes: 2 additions & 2 deletions docs/source/data-types/time.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ midnight. It can't be negative or exceed `86399999999999` (23:59:59.999999999).

## CqlTime

Without any extra features enabled, only `frame::value::CqlTime` is available. It's an
Without any extra features enabled, only `value::CqlTime` is available. It's an
[`i64`](https://doc.rust-lang.org/std/primitive.i64.html) wrapper and it matches the internal time representation.

However, for most use cases other types are more practical. See following sections for `chrono` and `time`.
Expand All @@ -18,7 +18,7 @@ However, for most use cases other types are more practical. See following sectio
# use scylla::client::session::Session;
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use scylla::frame::value::CqlTime;
use scylla::value::CqlTime;
use futures::TryStreamExt;

// 64 seconds since midnight
Expand Down
4 changes: 2 additions & 2 deletions docs/source/data-types/timestamp.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Internally [timestamp](https://docs.scylladb.com/stable/cql/types.html#timestamp

## CqlTimestamp

Without any extra features enabled, only `frame::value::CqlTimestamp` is available. It's an
Without any extra features enabled, only `value::CqlTimestamp` is available. It's an
[`i64`](https://doc.rust-lang.org/std/primitive.i64.html) wrapper and it matches the internal time representation. It's
the only type that supports full range of values that database accepts.

Expand All @@ -19,7 +19,7 @@ However, for most use cases other types are more practical. See following sectio
# use scylla::client::session::Session;
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use scylla::frame::value::CqlTimestamp;
use scylla::value::CqlTimestamp;
use futures::TryStreamExt;

// 64 seconds since unix epoch, 1970-01-01 00:01:04
Expand Down
4 changes: 2 additions & 2 deletions docs/source/data-types/timeuuid.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Also, `value::CqlTimeuuid` is a wrapper for `uuid::Uuid` with custom ordering lo
# use std::str::FromStr;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use futures::TryStreamExt;
use scylla::frame::value::CqlTimeuuid;
use scylla::value::CqlTimeuuid;

// Insert some timeuuid into the table
let to_insert: CqlTimeuuid = CqlTimeuuid::from_str("8e14e760-7fa8-11eb-bc66-000000000001")?;
Expand Down Expand Up @@ -51,7 +51,7 @@ and now you're gonna be able to use the `uuid::v1` features:
# use std::error::Error;
# use std::str::FromStr;
use futures::TryStreamExt;
use scylla::frame::value::CqlTimeuuid;
use scylla::value::CqlTimeuuid;
use uuid::Uuid;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {

Expand Down
2 changes: 1 addition & 1 deletion docs/source/migration-guides/0.11-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Before 0.11, the driver couldn't do this kind of type checking. For example, in
```rust,ignore
# extern crate scylla;
# extern crate bytes;
# use scylla::frame::value::{SerializedResult, SerializeValuesError};
# use scylla::value::{SerializedResult, SerializeValuesError};
# use bytes::BufMut;
pub trait ValueList {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/queries/values.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Using `Unset` results in better performance:
# use scylla::client::session::Session;
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use scylla::frame::value::{MaybeUnset, Unset};
use scylla::value::{MaybeUnset, Unset};

// Inserting a null results in suboptimal performance
let null_i32: Option<i32> = None;
Expand Down
2 changes: 1 addition & 1 deletion examples/cql-time-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use futures::{StreamExt as _, TryStreamExt as _};
use scylla::client::session::Session;
use scylla::client::session_builder::SessionBuilder;
use scylla::frame::response::result::CqlValue;
use scylla::frame::value::{CqlDate, CqlTime, CqlTimestamp};
use scylla::value::{CqlDate, CqlTime, CqlTimestamp};
use std::env;

#[tokio::main]
Expand Down
20 changes: 9 additions & 11 deletions scylla-cql/src/deserialize/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ use std::fmt::Display;
use thiserror::Error;

use super::{make_error_replace_rust_name, DeserializationError, FrameSlice, TypeCheckError};
use crate::frame::{frame_errors::LowLevelDeserializationError, value::CqlVarintBorrowed};
use crate::frame::{response::result::CollectionType, types};
use crate::frame::{
response::result::UserDefinedType,
value::{
Counter, CqlDate, CqlDecimal, CqlDuration, CqlTime, CqlTimestamp, CqlTimeuuid, CqlVarint,
},
};
use crate::frame::{
response::result::{deser_cql_value, ColumnType, CqlValue, NativeType},
value::CqlDecimalBorrowed,
use crate::frame::frame_errors::LowLevelDeserializationError;
use crate::frame::response::result::CollectionType;
use crate::frame::response::result::UserDefinedType;
use crate::frame::response::result::{deser_cql_value, ColumnType, CqlValue, NativeType};
use crate::frame::types;
use crate::value::CqlVarintBorrowed;
use crate::value::{
Counter, CqlDate, CqlDecimal, CqlDecimalBorrowed, CqlDuration, CqlTime, CqlTimestamp,
CqlTimeuuid, CqlVarint,
};

/// A type that can be deserialized from a column value inside a row that was
Expand Down
6 changes: 3 additions & 3 deletions scylla-cql/src/deserialize/value_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use crate::deserialize::{DeserializationError, FrameSlice, TypeCheckError};
use crate::frame::response::result::{
CollectionType, ColumnType, CqlValue, NativeType, UserDefinedType,
};
use crate::frame::value::{
use crate::serialize::value::SerializeValue;
use crate::serialize::CellWriter;
use crate::value::{
Counter, CqlDate, CqlDecimal, CqlDecimalBorrowed, CqlDuration, CqlTime, CqlTimestamp,
CqlTimeuuid, CqlVarint, CqlVarintBorrowed,
};
use crate::serialize::value::SerializeValue;
use crate::serialize::CellWriter;

use super::{
mk_deser_err, BuiltinDeserializationError, BuiltinDeserializationErrorKind,
Expand Down
1 change: 0 additions & 1 deletion scylla-cql/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub mod request;
pub mod response;
pub mod server_event_type;
pub mod types;
pub mod value;

use bytes::{Buf, BufMut, Bytes};
use frame_errors::{
Expand Down
4 changes: 2 additions & 2 deletions scylla-cql/src/frame/response/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::frame::frame_errors::{
use crate::frame::request::query::PagingStateResponse;
use crate::frame::response::event::SchemaChangeEvent;
use crate::frame::types;
use crate::frame::value::{
use crate::value::{
Counter, CqlDate, CqlDecimal, CqlDuration, CqlTime, CqlTimestamp, CqlTimeuuid, CqlVarint,
};
use bytes::{Buf, Bytes};
Expand Down Expand Up @@ -1766,8 +1766,8 @@ mod tests {
use super::NativeType::{self, *};
use super::{CollectionType, UserDefinedType};
use crate as scylla;
use crate::frame::value::{Counter, CqlDate, CqlDuration, CqlTime, CqlTimestamp, CqlTimeuuid};
use crate::serialize::CellWriter;
use crate::value::{Counter, CqlDate, CqlDuration, CqlTime, CqlTimestamp, CqlTimeuuid};
use scylla::frame::response::result::{ColumnType, CqlValue};
use std::str::FromStr;
use std::sync::Arc;
Expand Down
2 changes: 2 additions & 0 deletions scylla-cql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub mod macros {
pub mod deserialize;
pub mod serialize;

pub mod value;

pub use crate::frame::types::Consistency;

#[doc(hidden)]
Expand Down
2 changes: 1 addition & 1 deletion scylla-cql/src/serialize/row_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::frame::response::result::{
CollectionType, ColumnSpec, ColumnType, NativeType, TableSpec,
};
use crate::frame::types::RawValue;
use crate::frame::value::MaybeUnset;
use crate::macros::SerializeRow;
use crate::serialize::row::{
BuiltinSerializationError, BuiltinSerializationErrorKind, BuiltinTypeCheckError,
Expand All @@ -18,6 +17,7 @@ use crate::serialize::value::{
};
use crate::serialize::writers::WrittenCellProof;
use crate::serialize::{CellWriter, RowWriter, SerializationError};
use crate::value::MaybeUnset;

use assert_matches::assert_matches;

Expand Down
4 changes: 2 additions & 2 deletions scylla-cql/src/serialize/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ use uuid::Uuid;

use crate::frame::response::result::{CollectionType, ColumnType, CqlValue, NativeType};
use crate::frame::types::vint_encode;
use crate::frame::value::{
use crate::value::{
Counter, CqlDate, CqlDecimal, CqlDecimalBorrowed, CqlDuration, CqlTime, CqlTimestamp,
CqlTimeuuid, CqlVarint, CqlVarintBorrowed, MaybeUnset, Unset,
};

#[cfg(feature = "chrono-04")]
use crate::frame::value::ValueOverflow;
use crate::value::ValueOverflow;

use super::writers::WrittenCellProof;
use super::{CellWriter, SerializationError};
Expand Down
6 changes: 3 additions & 3 deletions scylla-cql/src/serialize/value_tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::frame::response::result::{
CollectionType, ColumnType, CqlValue, NativeType, UserDefinedType,
};
use crate::frame::value::{
Counter, CqlDate, CqlDuration, CqlTime, CqlTimestamp, CqlTimeuuid, CqlVarint, MaybeUnset, Unset,
};
use crate::macros::SerializeValue;
use crate::serialize::value::{
BuiltinSerializationError, BuiltinSerializationErrorKind, BuiltinTypeCheckError,
Expand All @@ -12,6 +9,9 @@ use crate::serialize::value::{
TupleTypeCheckErrorKind, UdtSerializationErrorKind, UdtTypeCheckErrorKind,
};
use crate::serialize::{CellWriter, SerializationError};
use crate::value::{
Counter, CqlDate, CqlDuration, CqlTime, CqlTimestamp, CqlTimeuuid, CqlVarint, MaybeUnset, Unset,
};

use std::collections::hash_map::DefaultHasher;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
Expand Down
4 changes: 2 additions & 2 deletions scylla-cql/src/frame/value.rs → scylla-cql/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl<V: AsVarintSlice> AsNormalizedVarintSlice for V {
/// # Example
///
/// ```rust
/// # use scylla_cql::frame::value::CqlVarint;
/// # use scylla_cql::value::CqlVarint;
/// let non_normalized_bytes = vec![0x00, 0x01];
/// let normalized_bytes = vec![0x01];
/// assert_eq!(
Expand All @@ -364,7 +364,7 @@ impl std::hash::Hash for CqlVarint {
/// # Example
///
/// ```rust
/// # use scylla_cql::frame::value::CqlVarintBorrowed;
/// # use scylla_cql::value::CqlVarintBorrowed;
/// let non_normalized_bytes = &[0x00, 0x01];
/// let normalized_bytes = &[0x01];
/// assert_eq!(
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/client/session_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use futures::{FutureExt, StreamExt as _, TryStreamExt};
use itertools::Itertools;
use scylla_cql::frame::request::query::{PagingState, PagingStateResponse};
use scylla_cql::frame::response::result::Row;
use scylla_cql::frame::value::CqlVarint;
use scylla_cql::serialize::row::{SerializeRow, SerializedValues};
use scylla_cql::serialize::value::SerializeValue;
use scylla_cql::value::CqlVarint;
use std::collections::{BTreeMap, HashMap};
use std::collections::{BTreeSet, HashSet};
use std::sync::atomic::{AtomicBool, Ordering};
Expand Down Expand Up @@ -383,7 +383,7 @@ async fn test_prepared_statement() {

#[tokio::test]
async fn test_counter_batch() {
use crate::frame::value::Counter;
use crate::value::Counter;
use scylla_cql::frame::request::batch::BatchType;

setup_tracing();
Expand Down
4 changes: 3 additions & 1 deletion scylla/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ pub mod macros;
#[doc(inline)]
pub use macros::*;

pub use scylla_cql::value;

pub mod frame {
pub use scylla_cql::frame::{frame_errors, value, Authenticator, Compression};
pub use scylla_cql::frame::{frame_errors, Authenticator, Compression};
pub(crate) use scylla_cql::frame::{
parse_response_body_extensions, protocol_features, read_response_frame, request,
server_event_type, FrameParams, SerializedRequest,
Expand Down
4 changes: 2 additions & 2 deletions scylla/src/observability/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::frame::value::CqlTimestamp;
use crate::value::CqlTimestamp;
use itertools::Itertools;
use scylla_cql::frame::value::CqlTimeuuid;
use scylla_cql::value::CqlTimeuuid;
use scylla_macros::DeserializeRow;
use std::collections::HashMap;
use std::net::IpAddr;
Expand Down
8 changes: 3 additions & 5 deletions scylla/src/utils/pretty.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use chrono::{LocalResult, TimeZone, Utc};
use scylla_cql::frame::{
response::result::CqlValue,
value::{CqlDate, CqlTime, CqlTimestamp},
};
use scylla_cql::frame::response::result::CqlValue;
use scylla_cql::value::{CqlDate, CqlTime, CqlTimestamp};

use std::borrow::Borrow;
use std::fmt::{Display, LowerHex, UpperHex};
Expand Down Expand Up @@ -234,7 +232,7 @@ mod tests {
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};

use scylla_cql::frame::response::result::CqlValue;
use scylla_cql::frame::value::{CqlDate, CqlDecimal, CqlDuration, CqlTime, CqlTimestamp};
use scylla_cql::value::{CqlDate, CqlDecimal, CqlDuration, CqlTime, CqlTimestamp};

use crate::test_utils::setup_tracing;
use crate::utils::pretty::CqlValueDisplayer;
Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/cql_types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use itertools::Itertools;
use scylla::client::session::Session;
use scylla::frame::response::result::CqlValue;
use scylla::frame::value::{Counter, CqlDate, CqlTime, CqlTimestamp, CqlTimeuuid, CqlVarint};
use scylla::serialize::value::SerializeValue;
use scylla::value::{Counter, CqlDate, CqlTime, CqlTimestamp, CqlTimeuuid, CqlVarint};
use scylla::{DeserializeValue, SerializeValue};
use std::cmp::PartialEq;
use std::fmt::Debug;
Expand Down
2 changes: 1 addition & 1 deletion scylla/tests/integration/cql_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use assert_matches::assert_matches;

use scylla::client::session::Session;
use scylla::frame::response::result::CqlValue;
use scylla::frame::value::CqlDuration;
use scylla::value::CqlDuration;

use crate::utils::{create_new_session_builder, setup_tracing, unique_keyspace_name, PerformDDL};

Expand Down

0 comments on commit 62fa3a8

Please sign in to comment.