Skip to main content

LastIDError

Enum LastIDError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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)

Fields

§tolerance_seconds: u64

Maximum allowed clock skew in seconds

§

TokenBindingMismatch

DPoP token binding mismatch (SEC-004)

Fields

§expected: String

Expected JWK thumbprint from our DPoP key

§actual: String

Actual JWK thumbprint from token’s cnf.jkt claim

Implementations§

Source§

impl LastIDError

Source

pub fn config(message: impl Into<String>) -> Self

Create a configuration error.

Source

pub fn crypto(message: impl Into<String>) -> Self

Create a crypto error.

Source

pub fn invalid_credential(message: impl Into<String>) -> Self

Create an invalid credential error.

Source

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"));
Source

pub fn policy_validation(message: impl Into<String>) -> Self

Create a policy validation error.

Source

pub fn is_retryable(&self) -> bool

Check if this error is retryable.

Source

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_after value 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()
}
Source

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.

Source

pub fn invalid_did(did: impl Into<String>) -> Self

Create an invalid DID error.

Source

pub fn insecure_url(url: impl Into<String>) -> Self

Create an insecure URL error.

Source

pub const fn clock_skew_exceeded(tolerance_seconds: u64) -> Self

Create a clock skew exceeded error.

Source

pub fn token_binding_mismatch( expected: impl Into<String>, actual: impl Into<String>, ) -> Self

Create a token binding mismatch error.

Trait Implementations§

Source§

impl Debug for LastIDError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for LastIDError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for LastIDError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for LastIDError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for LastIDError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for LastIDError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<HttpError> for LastIDError

Source§

fn from(source: HttpError) -> Self

Converts to this type from the input type.
Source§

impl From<TrustRegistryError> for LastIDError

Source§

fn from(source: TrustRegistryError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more