arcature 2026.2.1

Arcature application framework: a high-level Application facade over the certified Arcature subsystems, with the low-level Axum/Tower escape hatch preserved.
Documentation
//! `AuthUser` — the application identity contract (A9).
//!
//! The application owns identity schema. This trait is the seam between the
//! application's `User` type and the framework's auth extractors. The app
//! implements `AuthUser` for its user type, telling the framework:
//!
//! - What type the session stores as the user ID (`Id`).
//! - What session key the ID lives under (`SESSION_KEY`).
//! - How to get the ID from a user value (`id()`).
//!
//! The framework does NOT own the `User` model, the users table, or any
//! identity schema. It only owns the session-based auth DX.
//!
//! # Example
//!
//! ```ignore
//! use arcature::AuthUser;
//!
//! pub struct User { pub id: uuid::Uuid, pub email: String }
//!
//! impl AuthUser for User {
//!     type Id = uuid::Uuid;
//!     const SESSION_KEY: &'static str = "user_id";
//!     fn id(&self) -> &uuid::Uuid { &self.id }
//! }
//! ```

use serde::Serialize;
use serde::de::DeserializeOwned;

/// The application identity contract.
///
/// Implemented by the application's user type. The framework uses this to
/// store/retrieve the user ID in the session and to type the auth
/// extractors (`Auth<U>`, `OptionalAuth<U>`, `AuthManager<U>`).
///
/// The application owns identity schema — this trait does NOT mandate a
/// fixed `User` table, role model, or permission system.
pub trait AuthUser: Send + Sync + 'static {
    /// The type stored in the session to identify the user. Must be
    /// serializable/deserializable (e.g. `Uuid`, `i64`, `String`).
    type Id: Serialize + DeserializeOwned + Clone + Send + Sync + 'static;

    /// The session key under which the user ID is stored. Defaults to
    /// `"user_id"`.
    const SESSION_KEY: &'static str = "user_id";

    /// Get the ID to store in the session on login.
    fn id(&self) -> &Self::Id;
}