Skip to content

Commit

Permalink
ColumnType: Add public documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorak-mmk committed Jan 27, 2025
1 parent aafdabd commit 6a7db44
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scylla-cql/src/frame/response/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,48 @@ pub struct TableSpec<'a> {
table_name: Cow<'a, str>,
}

/// A type of the column in schema metadata or in prepared statement.
///
/// In schema metadata this represents simply a column type. In prepared
/// statement this is used in two places: as a type of bind marker and as a type
/// of returned value.
///
/// Some of the variants contain a `frozen` flag. This flag is only used
/// in schema metadata. For prepared statement bind markers and result types
/// those fields will always be set to `false` (even if the DB column
/// corresponding to given marker / result type is frozen).
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ColumnType<'frame> {
/// Types that are "simple" (non-recursive).
Native(NativeType),

/// Collection types: Map, Set, and List. Those are composite types with
/// dynamic size but constant predefined element types.
Collection {
frozen: bool,
typ: CollectionType<'frame>,
},

// A composite list-like type that has a defined size and all its elements
// are of the same type. Intuitively, it can be viewed as a list with constant
// predefined size, or as a tuple which has all elements of the same type.
Vector {
typ: Box<ColumnType<'frame>>,
dimensions: u16,
},

// A C-struct-like type defined by the user.
UserDefinedType {
frozen: bool,
definition: Arc<UserDefinedType<'frame>>,
},

// A composite type with a defined size and elements of possibly different,
// but predefined, types.
Tuple(Vec<ColumnType<'frame>>),
}

/// A [ColumnType] variants that are "simple" (non-recursive).
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum NativeType {
Ascii,
Expand All @@ -91,6 +115,10 @@ pub enum NativeType {
Varint,
}

/// Collection variants of [ColumnType]. A collection is a composite type that:
/// has no predefined size, so it is possible to add and remove values to/from it.
///
/// Tuple and vector are not collections because they don't have dynamic size.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CollectionType<'frame> {
List(Box<ColumnType<'frame>>),
Expand Down

0 comments on commit 6a7db44

Please sign in to comment.