pub enum AuthConfig {
None,
Bearer {
token: String,
},
}Expand description
Authentication configuration for the Letta client.
Supports both bearer token authentication (for Letta Cloud) and no authentication (for local development servers).
Variants§
Implementations§
Source§impl AuthConfig
impl AuthConfig
Sourcepub fn none() -> Self
pub fn none() -> Self
Create a new no-authentication configuration.
This is typically used for local development servers that don’t require authentication.
§Examples
use letta::auth::AuthConfig;
let auth = AuthConfig::none();Sourcepub fn apply_to_headers(&self, headers: &mut HeaderMap) -> LettaResult<()>
pub fn apply_to_headers(&self, headers: &mut HeaderMap) -> LettaResult<()>
Apply authentication to HTTP headers.
This method adds the appropriate authentication headers to the
provided HeaderMap based on the authentication configuration.
§Arguments
headers- The header map to modify
§Errors
Returns a LettaError::Auth if the authentication configuration
is invalid or if the token cannot be converted to a valid header value.
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Check if authentication is configured.
Returns true if authentication is configured, false otherwise.
§Examples
use letta::auth::AuthConfig;
let auth = AuthConfig::bearer("token");
assert!(auth.is_authenticated());
let auth = AuthConfig::none();
assert!(!auth.is_authenticated());Sourcepub fn auth_type(&self) -> &'static str
pub fn auth_type(&self) -> &'static str
Get the authentication type as a string.
This is useful for logging and debugging purposes.
Sourcepub fn validate(&self) -> LettaResult<()>
pub fn validate(&self) -> LettaResult<()>
Validate the authentication configuration.
This performs basic validation of the authentication configuration to ensure it’s properly formed.
§Errors
Returns a LettaError::Auth if the configuration is invalid.
Trait Implementations§
Source§impl Clone for AuthConfig
impl Clone for AuthConfig
Source§fn clone(&self) -> AuthConfig
fn clone(&self) -> AuthConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AuthConfig
impl Debug for AuthConfig
Source§impl Default for AuthConfig
impl Default for AuthConfig
Auto Trait Implementations§
impl Freeze for AuthConfig
impl RefUnwindSafe for AuthConfig
impl Send for AuthConfig
impl Sync for AuthConfig
impl Unpin for AuthConfig
impl UnsafeUnpin for AuthConfig
impl UnwindSafe for AuthConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.