CqlSession

Struct CqlSession 

Source
pub struct CqlSession {
    driver: ScyllaDriver,
    current_keyspace: Option<String>,
    pub connection_display: String,
    pub cluster_name: Option<String>,
    pub cql_version: Option<String>,
    pub release_version: Option<String>,
    pub scylla_version: Option<String>,
}
Expand description

High-level CQL session managing driver state and user preferences.

Fields§

§driver: ScyllaDriver§current_keyspace: Option<String>

Current keyspace (updated on USE commands).

§connection_display: String

Display name for the connection (host:port).

§cluster_name: Option<String>

Cluster name retrieved after connecting.

§cql_version: Option<String>

CQL version from the connected node.

§release_version: Option<String>

Release version of the connected node.

§scylla_version: Option<String>

ScyllaDB version (None if connected to Apache Cassandra).

Implementations§

Source§

impl CqlSession

Source

pub async fn connect(config: &MergedConfig) -> Result<Self>

Create a new session by connecting using the merged configuration.

Source

pub async fn execute(&mut self, query: &str) -> Result<CqlResult>

Execute a CQL statement. Handles USE keyspace commands specially.

Source

pub async fn execute_query(&self, query: &str) -> Result<CqlResult>

Execute a raw CQL query without USE interception.

Used by DESCRIBE and other internal commands that need to query system tables directly.

Source

pub async fn execute_paged( &self, query: &str, page_size: i32, ) -> Result<CqlResult>

Execute a CQL statement with paging.

Source

pub async fn prepare(&self, query: &str) -> Result<PreparedId>

Prepare a CQL statement.

Source

pub async fn execute_prepared( &self, id: &PreparedId, values: &[CqlValue], ) -> Result<CqlResult>

Execute a previously prepared statement with typed bound values.

Source

pub async fn use_keyspace(&mut self, keyspace: &str) -> Result<()>

Switch to a different keyspace.

Source

pub fn current_keyspace(&self) -> Option<&str>

Get the current keyspace.

Source

pub fn get_consistency(&self) -> Consistency

Get the current consistency level.

Source

pub fn set_consistency(&self, consistency: Consistency)

Set the consistency level.

Source

pub fn set_consistency_str(&self, level: &str) -> Result<()>

Set the consistency level from a string. Returns error if invalid.

Source

pub fn get_serial_consistency(&self) -> Option<Consistency>

Get the current serial consistency level.

Source

pub fn set_serial_consistency(&self, consistency: Option<Consistency>)

Set the serial consistency level.

Source

pub fn set_serial_consistency_str(&self, level: &str) -> Result<()>

Set the serial consistency level from a string. Returns error if invalid.

Source

pub fn set_tracing(&self, enabled: bool)

Enable or disable tracing.

Source

pub fn is_tracing_enabled(&self) -> bool

Check if tracing is enabled.

Source

pub fn last_trace_id(&self) -> Option<Uuid>

Get the last tracing session ID.

Source

pub async fn get_trace_session( &self, trace_id: Uuid, ) -> Result<Option<TracingSession>>

Retrieve tracing session data.

Source

pub async fn get_keyspaces(&self) -> Result<Vec<KeyspaceMetadata>>

Get metadata for all keyspaces.

Source

pub async fn get_tables(&self, keyspace: &str) -> Result<Vec<TableMetadata>>

Get metadata for tables in a keyspace.

Source

pub async fn get_table_metadata( &self, keyspace: &str, table: &str, ) -> Result<Option<TableMetadata>>

Get metadata for a specific table.

Source

pub async fn get_udts(&self, keyspace: &str) -> Result<Vec<UdtMetadata>>

Get metadata for all user-defined types in a keyspace.

Source

pub async fn get_functions( &self, keyspace: &str, ) -> Result<Vec<FunctionMetadata>>

Get metadata for all user-defined functions in a keyspace.

Source

pub async fn get_aggregates( &self, keyspace: &str, ) -> Result<Vec<AggregateMetadata>>

Get metadata for all user-defined aggregates in a keyspace.

Source

pub async fn is_connected(&self) -> bool

Check if the connection is still alive.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,