pub struct Config {
pub api_url: String,
pub token: Option<String>,
pub timeout: Duration,
pub max_retries: u32,
pub user_agent: String,
pub verify_ssl: bool,
}
Expand description
Configuration for the Zero Trust SDK
Fields§
§api_url: String
API base URL
token: Option<String>
Authentication token (JWT)
timeout: Duration
Request timeout duration
max_retries: u32
Maximum retry attempts
user_agent: String
User agent string
verify_ssl: bool
Whether to verify SSL certificates
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_token<S: Into<String>>(self, token: S) -> Self
pub fn with_token<S: Into<String>>(self, token: S) -> Self
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Sourcepub fn with_user_agent<S: Into<String>>(self, user_agent: S) -> Self
pub fn with_user_agent<S: Into<String>>(self, user_agent: S) -> Self
Sourcepub fn disable_ssl_verification(self) -> Self
pub fn disable_ssl_verification(self) -> Self
Disable SSL verification (for testing only)
§Examples
use zero_trust_sdk::Config;
let config = Config::new("https://api.zerotrust.com")
.unwrap()
.disable_ssl_verification();
Sourcepub fn from_env() -> Result<Self>
pub fn from_env() -> Result<Self>
Load configuration from environment variables
Environment variables:
ZEROTRUST_API_URL
- API base URLZEROTRUST_TOKEN
- Authentication tokenZEROTRUST_TIMEOUT
- Request timeout in secondsZEROTRUST_MAX_RETRIES
- Maximum retry attempts
§Examples
use zero_trust_sdk::Config;
// Set environment variable: ZEROTRUST_API_URL=https://api.zerotrust.com
let config = Config::from_env().unwrap();
Sourcepub fn save_to_file(&self, path: &Path) -> Result<()>
pub fn save_to_file(&self, path: &Path) -> Result<()>
Sourcepub fn default_config_path() -> Result<PathBuf>
pub fn default_config_path() -> Result<PathBuf>
Get the default config file path
Returns ~/.config/zerotrust/config.toml
on Unix systems
or %APPDATA%/zerotrust/config.toml
on Windows
Sourcepub fn load_default() -> Result<Self>
pub fn load_default() -> Result<Self>
Load configuration from the default config file path
§Examples
use zero_trust_sdk::Config;
let config = Config::load_default().unwrap();
Sourcepub fn save_default(&self) -> Result<()>
pub fn save_default(&self) -> Result<()>
Save configuration to the default config file path
§Examples
use zero_trust_sdk::Config;
let config = Config::new("https://api.zerotrust.com").unwrap();
config.save_default().unwrap();
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if authentication token is present
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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