pub struct SessionState {
pub namespace: Option<String>,
pub database: Option<String>,
pub token: Option<String>,
pub scope: Option<String>,
pub params: HashMap<String, Value>,
}Expand description
Session state management for SurrealDB connections
Fields§
§namespace: Option<String>Current namespace
database: Option<String>Current database
token: Option<String>Authentication token
scope: Option<String>Current scope (for record-level authentication)
params: HashMap<String, Value>Session parameters set via let
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn set_namespace(&mut self, namespace: Option<String>)
pub fn set_namespace(&mut self, namespace: Option<String>)
Set the namespace
Sourcepub fn set_database(&mut self, database: Option<String>)
pub fn set_database(&mut self, database: Option<String>)
Set the database
Sourcepub fn unset_param(&mut self, key: &str)
pub fn unset_param(&mut self, key: &str)
Remove a session parameter
Sourcepub fn clear_params(&mut self)
pub fn clear_params(&mut self)
Clear all session parameters
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if authenticated (has a token)
Sourcepub fn get_target(&self) -> (Option<&String>, Option<&String>)
pub fn get_target(&self) -> (Option<&String>, Option<&String>)
Get the current namespace/database pair as a tuple
Sourcepub fn set_target(
&mut self,
namespace: Option<String>,
database: Option<String>,
)
pub fn set_target( &mut self, namespace: Option<String>, database: Option<String>, )
Set both namespace and database at once
Sourcepub fn clear_auth(&mut self)
pub fn clear_auth(&mut self)
Clear all authentication data
Sourcepub fn merge_params(&mut self, params: HashMap<String, Value>)
pub fn merge_params(&mut self, params: HashMap<String, Value>)
Merge parameters from another map
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionState
impl Debug for SessionState
Source§impl Default for SessionState
impl Default for SessionState
Source§fn default() -> SessionState
fn default() -> SessionState
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SessionState
impl RefUnwindSafe for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl UnsafeUnpin for SessionState
impl UnwindSafe for SessionState
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
Mutably borrows from an owned value. Read more