Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

Database session information and state tracking.

Implementations§

Source§

impl Session

Source

pub fn new( session_id: String, server_info: AuthResponseData, config: SessionConfig, ) -> Self

Create a new session.

Source

pub fn session_id(&self) -> &str

Get the session ID.

Source

pub fn server_info(&self) -> &AuthResponseData

Get server information.

Source

pub fn config(&self) -> &SessionConfig

Get session configuration.

Source

pub async fn state(&self) -> SessionState

Get current session state.

Source

pub async fn set_state(&self, new_state: SessionState)

Set session state.

Source

pub async fn update_activity(&self)

Update last activity timestamp.

Source

pub async fn idle_duration(&self) -> Duration

Get time since last activity.

Source

pub async fn is_idle_timeout(&self) -> bool

Check if session is idle beyond timeout.

Source

pub fn increment_query_count(&self) -> u64

Increment query counter.

Source

pub fn query_count(&self) -> u64

Get total query count.

Source

pub fn in_transaction(&self) -> bool

Check if in transaction.

Source

pub async fn begin_transaction(&self) -> Result<(), ConnectionError>

Begin a transaction.

Source

pub async fn commit_transaction(&self) -> Result<(), ConnectionError>

Commit the current transaction.

Source

pub async fn rollback_transaction(&self) -> Result<(), ConnectionError>

Rollback the current transaction.

Source

pub async fn current_schema(&self) -> Option<String>

Get current schema.

Source

pub async fn set_current_schema(&self, schema: Option<String>)

Set current schema.

Source

pub async fn get_attribute(&self, key: &str) -> Option<String>

Get a session attribute.

Source

pub async fn set_attribute(&self, key: String, value: String)

Set a session attribute.

Source

pub async fn remove_attribute(&self, key: &str) -> Option<String>

Remove a session attribute.

Source

pub async fn close(&self) -> Result<(), ConnectionError>

Close the session.

Source

pub async fn is_closed(&self) -> bool

Check if session is closed.

Source

pub async fn mark_error(&self)

Mark session as having an error.

Source

pub async fn validate_ready(&self) -> Result<(), ConnectionError>

Validate session is ready for operations.

Trait Implementations§

Source§

impl Debug for Session

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.

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> 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.
Source§

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

Source§

fn vzip(self) -> V