pub struct Session {
pub account_id: String,
pub client_id: String,
pub lightstreamer_endpoint: String,
pub cst: Option<String>,
pub x_security_token: Option<String>,
pub oauth_token: Option<OAuthToken>,
pub api_version: u8,
pub expires_at: u64,
}Expand description
Session information for authenticated requests
Fields§
§account_id: StringAccount ID
client_id: StringClient ID (for OAuth)
lightstreamer_endpoint: StringLightstreamer endpoint
cst: Option<String>CST token (API v2)
x_security_token: Option<String>X-SECURITY-TOKEN (API v2)
oauth_token: Option<OAuthToken>OAuth token (API v3)
api_version: u8API version used
expires_at: u64Unix timestamp when session expires (seconds since epoch)
- OAuth (v3): expires in 30 seconds
- API v2: expires in 6 hours (21600 seconds)
Implementations§
Source§impl Session
impl Session
Sourcepub fn is_expired(&self, margin_seconds: Option<u64>) -> bool
pub fn is_expired(&self, margin_seconds: Option<u64>) -> bool
Sourcepub fn seconds_until_expiry(&self) -> u64
pub fn seconds_until_expiry(&self) -> u64
Gets the number of seconds until session expires
§Returns
- Positive number if session is still valid
- Negative number if session is already expired
Sourcepub fn needs_token_refresh(&self, margin_seconds: Option<u64>) -> bool
pub fn needs_token_refresh(&self, margin_seconds: Option<u64>) -> bool
Checks if OAuth token needs refresh (alias for is_expired for backwards compatibility)
§Arguments
margin_seconds- Safety margin in seconds (default: 60 = 1 minute)
Sourcepub fn get_websocket_info(&self) -> WebsocketInfo
pub fn get_websocket_info(&self) -> WebsocketInfo
Extracts WebSocket connection information from the session
§Returns
WebsocketInfocontaining endpoint and authentication tokens
Trait Implementations§
Source§impl From<SessionResponse> for Session
impl From<SessionResponse> for Session
Source§fn from(v: SessionResponse) -> Self
fn from(v: SessionResponse) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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>
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 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>
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