pub trait AuthEngine:
Send
+ Sync
+ Default {
// Required methods
fn authenticate(&self, username: &str, password: &str) -> AuthResult<()>;
fn user_exists(&self, username: &str) -> AuthResult<bool>;
}Expand description
Trait for authentication engines.
Implementations of this trait provide different authentication backends, such as in-memory storage, databases, LDAP, etc.
Required Methods§
Sourcefn authenticate(&self, username: &str, password: &str) -> AuthResult<()>
fn authenticate(&self, username: &str, password: &str) -> AuthResult<()>
Authenticates a user with the given username and password.
Returns Ok(()) if authentication succeeds, or an error if authentication
fails (AuthError::InvalidCredentials for wrong password,
AuthError::UserNotFound for non-existent user).
Sourcefn user_exists(&self, username: &str) -> AuthResult<bool>
fn user_exists(&self, username: &str) -> AuthResult<bool>
Checks if a user exists in the authentication store.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.