#[non_exhaustive]pub enum LastIDError {
Show 15 variants
Config(String),
Http(HttpError),
TrustRegistry(TrustRegistryError),
Crypto(String),
InvalidCredential(String),
Timeout(u64),
PolicyValidation(String),
Serialization(Error),
Io(Error),
TomlParse(Error),
InvalidDid(String),
EmptyClientId,
InsecureUrl(String),
ClockSkewExceeded {
tolerance_seconds: u64,
},
TokenBindingMismatch {
expected: String,
actual: String,
},
}Expand description
Top-level SDK error type.
All SDK operations return this error type, which encompasses configuration errors, HTTP errors, trust registry errors, cryptographic errors, and more.
§Error Handling
Use pattern matching to handle specific error cases:
use lastid_sdk::{HttpError, LastIDError};
fn handle_error(err: LastIDError) {
match err {
LastIDError::Http(HttpError::RateLimited {
retry_after_seconds,
}) => {
println!(
"Rate limited, retry after {} seconds",
retry_after_seconds
);
}
LastIDError::TrustRegistry(e) => {
println!("Trust registry error: {}", e);
}
LastIDError::Timeout(seconds) => {
println!("Request timed out after {} seconds", seconds);
}
_ => println!("Error: {}", err),
}
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Config(String)
Configuration error (missing or invalid config)
Http(HttpError)
HTTP request failed
TrustRegistry(TrustRegistryError)
Trust registry error
Crypto(String)
Cryptographic operation failed
InvalidCredential(String)
Invalid credential (parsing or validation failed)
Timeout(u64)
Request timeout
PolicyValidation(String)
Policy validation failed
Serialization(Error)
Serialization error
Io(Error)
IO error
TomlParse(Error)
TOML parsing error
InvalidDid(String)
Invalid DID format
EmptyClientId
Invalid client ID (empty or whitespace-only)
InsecureUrl(String)
HTTP URL not allowed in production (SEC-001)
ClockSkewExceeded
Clock skew exceeded tolerance (SEC-005)
TokenBindingMismatch
DPoP token binding mismatch (SEC-004)
Implementations§
Source§impl LastIDError
impl LastIDError
Sourcepub fn invalid_credential(message: impl Into<String>) -> Self
pub fn invalid_credential(message: impl Into<String>) -> Self
Create an invalid credential error.
Sourcepub fn credential_parse(message: impl Into<String>) -> Self
pub fn credential_parse(message: impl Into<String>) -> Self
Create a credential parsing error.
This is an alias for invalid_credential used specifically when
TryFrom conversions fail due to type mismatch or missing required
fields.
§Example
use lastid_sdk::LastIDError;
let err = LastIDError::credential_parse("Expected LastID.Persona, got LastID.Employment");
assert!(err.to_string().contains("LastID.Persona"));Sourcepub fn policy_validation(message: impl Into<String>) -> Self
pub fn policy_validation(message: impl Into<String>) -> Self
Create a policy validation error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error is retryable.
Sourcepub fn suggested_retry_delay_ms(&self) -> Option<u64>
pub fn suggested_retry_delay_ms(&self) -> Option<u64>
Get suggested retry delay in milliseconds.
Returns Some(delay) for retryable errors with a recommended wait time.
Returns None for non-retryable errors.
§Retry Strategy Hints
- Rate limited: Use the
retry_aftervalue from the response - Network errors: Start with short delays (100-500ms), use exponential backoff
- Server errors (5xx): Use moderate delays (1-5s), with exponential backoff
- Timeout: Increase timeout or use exponential backoff
§Example
use lastid_sdk::LastIDError;
fn should_retry(err: &LastIDError, attempt: u32) -> Option<u64> {
if !err.is_retryable() || attempt >= 3 {
return None;
}
err.suggested_retry_delay_ms()
}Sourcepub const fn category(&self) -> &'static str
pub const fn category(&self) -> &'static str
Get the error category for logging and metrics.
Returns a static string describing the error category, useful for structured logging and metrics.
Sourcepub fn invalid_did(did: impl Into<String>) -> Self
pub fn invalid_did(did: impl Into<String>) -> Self
Create an invalid DID error.
Sourcepub fn insecure_url(url: impl Into<String>) -> Self
pub fn insecure_url(url: impl Into<String>) -> Self
Create an insecure URL error.
Sourcepub const fn clock_skew_exceeded(tolerance_seconds: u64) -> Self
pub const fn clock_skew_exceeded(tolerance_seconds: u64) -> Self
Create a clock skew exceeded error.
Trait Implementations§
Source§impl Debug for LastIDError
impl Debug for LastIDError
Source§impl Display for LastIDError
impl Display for LastIDError
Source§impl Error for LastIDError
impl Error for LastIDError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for LastIDError
impl From<Error> for LastIDError
Source§impl From<Error> for LastIDError
impl From<Error> for LastIDError
Source§impl From<Error> for LastIDError
impl From<Error> for LastIDError
Source§impl From<HttpError> for LastIDError
impl From<HttpError> for LastIDError
Source§impl From<TrustRegistryError> for LastIDError
impl From<TrustRegistryError> for LastIDError
Source§fn from(source: TrustRegistryError) -> Self
fn from(source: TrustRegistryError) -> Self
Auto Trait Implementations§
impl Freeze for LastIDError
impl !RefUnwindSafe for LastIDError
impl Send for LastIDError
impl Sync for LastIDError
impl Unpin for LastIDError
impl UnsafeUnpin for LastIDError
impl !UnwindSafe for LastIDError
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> 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.