pub struct SessionConfig { /* private fields */ }Expand description
Configuration used to create a Session.
The configuration separates static credentials from runtime concerns such as timeouts and token refresh behavior. This keeps all I/O settings in one location and avoids hidden defaults spread across modules.
§Example
use comdirect_rest_api::{Session, SessionConfig};
let config = SessionConfig::new("client-id", "client-secret", "username", "pin")
.with_base_url("https://api.comdirect.de")
.with_request_timeout(std::time::Duration::from_secs(20))
.with_refresh_buffer(std::time::Duration::from_secs(90));
let session = Session::from_config(config)?;
session.try_restore("persisted-refresh-token").await?;Implementations§
Source§impl SessionConfig
impl SessionConfig
Sourcepub fn new(
client_id: impl Into<String>,
client_secret: impl Into<String>,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn new( client_id: impl Into<String>, client_secret: impl Into<String>, username: impl Into<String>, password: impl Into<String>, ) -> Self
Creates configuration with production defaults.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Overrides the API base URL.
Sourcepub fn with_request_timeout(self, request_timeout: Duration) -> Self
pub fn with_request_timeout(self, request_timeout: Duration) -> Self
Overrides the request timeout used for all HTTP calls.
Sourcepub fn with_refresh_buffer(self, refresh_buffer: Duration) -> Self
pub fn with_refresh_buffer(self, refresh_buffer: Duration) -> Self
Configures how early token refresh should happen before expiry.
Trait Implementations§
Source§impl Clone for SessionConfig
impl Clone for SessionConfig
Source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SessionConfig
impl RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl UnsafeUnpin for SessionConfig
impl UnwindSafe for SessionConfig
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