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: StringDisplay 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
impl CqlSession
Sourcepub async fn connect(config: &MergedConfig) -> Result<Self>
pub async fn connect(config: &MergedConfig) -> Result<Self>
Create a new session by connecting using the merged configuration.
Sourcepub async fn execute(&mut self, query: &str) -> Result<CqlResult>
pub async fn execute(&mut self, query: &str) -> Result<CqlResult>
Execute a CQL statement. Handles USE keyspace commands specially.
Sourcepub async fn execute_query(&self, query: &str) -> Result<CqlResult>
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.
Sourcepub async fn execute_paged(
&self,
query: &str,
page_size: i32,
) -> Result<CqlResult>
pub async fn execute_paged( &self, query: &str, page_size: i32, ) -> Result<CqlResult>
Execute a CQL statement with paging.
Sourcepub async fn prepare(&self, query: &str) -> Result<PreparedId>
pub async fn prepare(&self, query: &str) -> Result<PreparedId>
Prepare a CQL statement.
Sourcepub async fn execute_prepared(
&self,
id: &PreparedId,
values: &[CqlValue],
) -> Result<CqlResult>
pub async fn execute_prepared( &self, id: &PreparedId, values: &[CqlValue], ) -> Result<CqlResult>
Execute a previously prepared statement with typed bound values.
Sourcepub async fn use_keyspace(&mut self, keyspace: &str) -> Result<()>
pub async fn use_keyspace(&mut self, keyspace: &str) -> Result<()>
Switch to a different keyspace.
Sourcepub fn current_keyspace(&self) -> Option<&str>
pub fn current_keyspace(&self) -> Option<&str>
Get the current keyspace.
Sourcepub fn get_consistency(&self) -> Consistency
pub fn get_consistency(&self) -> Consistency
Get the current consistency level.
Sourcepub fn set_consistency(&self, consistency: Consistency)
pub fn set_consistency(&self, consistency: Consistency)
Set the consistency level.
Sourcepub fn set_consistency_str(&self, level: &str) -> Result<()>
pub fn set_consistency_str(&self, level: &str) -> Result<()>
Set the consistency level from a string. Returns error if invalid.
Sourcepub fn get_serial_consistency(&self) -> Option<Consistency>
pub fn get_serial_consistency(&self) -> Option<Consistency>
Get the current serial consistency level.
Sourcepub fn set_serial_consistency(&self, consistency: Option<Consistency>)
pub fn set_serial_consistency(&self, consistency: Option<Consistency>)
Set the serial consistency level.
Sourcepub fn set_serial_consistency_str(&self, level: &str) -> Result<()>
pub fn set_serial_consistency_str(&self, level: &str) -> Result<()>
Set the serial consistency level from a string. Returns error if invalid.
Sourcepub fn set_tracing(&self, enabled: bool)
pub fn set_tracing(&self, enabled: bool)
Enable or disable tracing.
Sourcepub fn is_tracing_enabled(&self) -> bool
pub fn is_tracing_enabled(&self) -> bool
Check if tracing is enabled.
Sourcepub fn last_trace_id(&self) -> Option<Uuid>
pub fn last_trace_id(&self) -> Option<Uuid>
Get the last tracing session ID.
Sourcepub async fn get_trace_session(
&self,
trace_id: Uuid,
) -> Result<Option<TracingSession>>
pub async fn get_trace_session( &self, trace_id: Uuid, ) -> Result<Option<TracingSession>>
Retrieve tracing session data.
Sourcepub async fn get_keyspaces(&self) -> Result<Vec<KeyspaceMetadata>>
pub async fn get_keyspaces(&self) -> Result<Vec<KeyspaceMetadata>>
Get metadata for all keyspaces.
Sourcepub async fn get_tables(&self, keyspace: &str) -> Result<Vec<TableMetadata>>
pub async fn get_tables(&self, keyspace: &str) -> Result<Vec<TableMetadata>>
Get metadata for tables in a keyspace.
Sourcepub async fn get_table_metadata(
&self,
keyspace: &str,
table: &str,
) -> Result<Option<TableMetadata>>
pub async fn get_table_metadata( &self, keyspace: &str, table: &str, ) -> Result<Option<TableMetadata>>
Get metadata for a specific table.
Sourcepub async fn get_udts(&self, keyspace: &str) -> Result<Vec<UdtMetadata>>
pub async fn get_udts(&self, keyspace: &str) -> Result<Vec<UdtMetadata>>
Get metadata for all user-defined types in a keyspace.
Sourcepub async fn get_functions(
&self,
keyspace: &str,
) -> Result<Vec<FunctionMetadata>>
pub async fn get_functions( &self, keyspace: &str, ) -> Result<Vec<FunctionMetadata>>
Get metadata for all user-defined functions in a keyspace.
Sourcepub async fn get_aggregates(
&self,
keyspace: &str,
) -> Result<Vec<AggregateMetadata>>
pub async fn get_aggregates( &self, keyspace: &str, ) -> Result<Vec<AggregateMetadata>>
Get metadata for all user-defined aggregates in a keyspace.
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if the connection is still alive.
Auto Trait Implementations§
impl !Freeze for CqlSession
impl !RefUnwindSafe for CqlSession
impl Send for CqlSession
impl Sync for CqlSession
impl Unpin for CqlSession
impl !UnwindSafe for CqlSession
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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