pub struct SnowflakeSession { /* private fields */ }Expand description
A live, authenticated Snowflake session.
Holds the session and master tokens behind a mutex so a query (reading the
session token) and a heartbeat/renew can interleave. query runs SQL;
renew swaps in a fresh session token via the master token; heartbeat
keeps the master token alive so renewal can continue indefinitely.
Implementations§
Source§impl SnowflakeSession
impl SnowflakeSession
Sourcepub fn abort_handle(&self) -> AbortHandle
pub fn abort_handle(&self) -> AbortHandle
A cloneable AbortHandle for this session’s in-flight statement.
The returned handle shares the session’s in-flight slot, so it can cancel whatever statement is running even after the session is checked out of a pool (moved out of the pool’s slot).
Sourcepub fn session_expiring_within(&self, within: TimeDelta) -> bool
pub fn session_expiring_within(&self, within: TimeDelta) -> bool
Whether the session token expires within within from now.
Sourcepub fn master_expires_at(&self) -> DateTime<Utc>
pub fn master_expires_at(&self) -> DateTime<Utc>
When the master token currently expires (renewal must happen before this,
kept alive by heartbeat).
Sourcepub async fn query(&self, sql: &str) -> Result<Vec<Row>>
pub async fn query(&self, sql: &str) -> Result<Vec<Row>>
Runs SQL and returns the result rows.
§Errors
Error::SessionExpired when the session token is no longer valid (renew
or re-authenticate), or a transport/server/protocol error.
Sourcepub async fn query_multi(&self, sql: &str) -> Result<Vec<Vec<Row>>>
pub async fn query_multi(&self, sql: &str) -> Result<Vec<Vec<Row>>>
Runs SQL that may contain multiple ;-separated statements, returning
one row set per statement (in submission order).
A single-statement submission takes the same path as query
and yields a one-element vector. When the SQL parses to more than one
statement it is submitted with MULTI_STATEMENT_COUNT = 0 (“any count”):
the server then returns a comma-separated list of child resultIds in
place of inline rows, and each child result is fetched from the
/queries/{id}/result endpoint.
§Errors
As query.
Sourcepub async fn renew(&self) -> Result<()>
pub async fn renew(&self) -> Result<()>
Renews the session token using the master token, extending the session.
§Errors
Error::SessionExpired when the master token has itself expired (a full
re-authentication is then required), or a transport/server error.
Auto Trait Implementations§
impl !Freeze for SnowflakeSession
impl !RefUnwindSafe for SnowflakeSession
impl !UnwindSafe for SnowflakeSession
impl Send for SnowflakeSession
impl Sync for SnowflakeSession
impl Unpin for SnowflakeSession
impl UnsafeUnpin for SnowflakeSession
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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