pub trait DeviceResolver:
Send
+ Sync
+ 'static {
type Error: Error + Send + Sync + 'static;
// Required method
fn resolve(
&self,
parts: &Parts,
) -> impl Future<Output = Result<Option<DeviceId>, Self::Error>> + Send;
}device only.Expand description
Resolve (or create) the DeviceId associated with an inbound HTTP
request.
Implementors hold whatever state they need (a DeviceStore, a tenant
fingerprint key registry, etc.) and produce a DeviceId per request.
§Failure semantics
Ok(None) means “no device could be associated with this request”,
not an error. Reserve Self::Error for genuine storage / configuration
faults the caller should propagate. The session layer treats Ok(None)
as a no-op (leaves
SessionData::device_id at
None); it logs Err(_) and continues with None.
§Tenant context
Implementations that need tenant scoping should read the TenantId
from request.extensions() populated by an upstream tenant-resolver
middleware. The trait does not pass tenant explicitly because the
session layer that drives the resolver is itself tenant-agnostic.
Required Associated Types§
Required Methods§
Sourcefn resolve(
&self,
parts: &Parts,
) -> impl Future<Output = Result<Option<DeviceId>, Self::Error>> + Send
fn resolve( &self, parts: &Parts, ) -> impl Future<Output = Result<Option<DeviceId>, Self::Error>> + Send
Resolve the device for parts. Always best-effort: returning
Ok(None) is the documented “no device” outcome; the layer never
fails the request on Err(_).
Takes axum::http::request::Parts rather than the full
Request<Body> because axum::body::Body is !Sync; borrowing
the request across an await boundary is forbidden in a Send
future. The session layer splits the request before calling and
reassembles it after.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".