pub enum TokenEnvironment {
Mock,
Live,
Auto,
}Expand description
Token environment detection for automatic strategy selection
Variants§
Mock
Mock environment - use isolated token management without persistence
Live
Live environment - use full token management with persistence
Auto
Auto-detect environment based on credentials and settings
Implementations§
Source§impl TokenEnvironment
impl TokenEnvironment
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Detects the current token environment based on environment variables and credential patterns
Detection logic:
- If
AMP_TESTS=liveis set, returnsLive - If credentials contain “mock” string, returns
Mock - If real credentials are present without live test flag, returns
Live - Fallback to
Mockfor safety
Sourcepub fn has_mock_credentials(
username: &str,
password: &str,
base_url: &str,
) -> bool
pub fn has_mock_credentials( username: &str, password: &str, base_url: &str, ) -> bool
Checks if the provided credentials indicate a mock environment
Mock credentials are detected by:
- Username containing “mock” (case-insensitive)
- Password containing “mock” (case-insensitive)
- Base URL containing localhost, 127.0.0.1, or “mock”
Sourcepub async fn create_strategy(
&self,
mock_token: Option<String>,
) -> Result<Box<dyn TokenStrategy>, Error>
pub async fn create_strategy( &self, mock_token: Option<String>, ) -> Result<Box<dyn TokenStrategy>, Error>
Sourcepub async fn create_auto_strategy(
mock_token: Option<String>,
) -> Result<Box<dyn TokenStrategy>, Error>
pub async fn create_auto_strategy( mock_token: Option<String>, ) -> Result<Box<dyn TokenStrategy>, Error>
Sourcepub fn should_persist_tokens(&self) -> bool
pub fn should_persist_tokens(&self) -> bool
Determines if token persistence should be enabled for this environment
Trait Implementations§
Source§impl Clone for TokenEnvironment
impl Clone for TokenEnvironment
Source§fn clone(&self) -> TokenEnvironment
fn clone(&self) -> TokenEnvironment
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 TokenEnvironment
impl Debug for TokenEnvironment
impl Eq for TokenEnvironment
Source§impl PartialEq for TokenEnvironment
impl PartialEq for TokenEnvironment
impl StructuralPartialEq for TokenEnvironment
Auto Trait Implementations§
impl Freeze for TokenEnvironment
impl RefUnwindSafe for TokenEnvironment
impl Send for TokenEnvironment
impl Sync for TokenEnvironment
impl Unpin for TokenEnvironment
impl UnsafeUnpin for TokenEnvironment
impl UnwindSafe for TokenEnvironment
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.