pub struct UserStore { /* private fields */ }Expand description
User storage operations
Implementations§
Source§impl UserStore
impl UserStore
Sourcepub fn new(pool: DatabasePool) -> Self
pub fn new(pool: DatabasePool) -> Self
Create a new user store
Sourcepub async fn create(
&self,
id: Uuid,
username: String,
email: String,
password_hash: String,
full_name: Option<String>,
) -> Result<UserRow>
pub async fn create( &self, id: Uuid, username: String, email: String, password_hash: String, full_name: Option<String>, ) -> Result<UserRow>
Create a new user
Sourcepub async fn get_by_username(&self, username: &str) -> Result<Option<UserRow>>
pub async fn get_by_username(&self, username: &str) -> Result<Option<UserRow>>
Get a user by username
Sourcepub async fn update_last_login(&self, id: &Uuid) -> Result<()>
pub async fn update_last_login(&self, id: &Uuid) -> Result<()>
Update user’s last login timestamp
Sourcepub async fn update_full_name(
&self,
id: &Uuid,
full_name: Option<String>,
) -> Result<()>
pub async fn update_full_name( &self, id: &Uuid, full_name: Option<String>, ) -> Result<()>
Update user’s full name
Sourcepub async fn remove_role(&self, user_id: &Uuid, role: &str) -> Result<()>
pub async fn remove_role(&self, user_id: &Uuid, role: &str) -> Result<()>
Remove role from user
Sourcepub async fn add_permission(
&self,
user_id: &Uuid,
permission: String,
) -> Result<()>
pub async fn add_permission( &self, user_id: &Uuid, permission: String, ) -> Result<()>
Add permission to user
Sourcepub async fn remove_permission(
&self,
user_id: &Uuid,
permission: &str,
) -> Result<()>
pub async fn remove_permission( &self, user_id: &Uuid, permission: &str, ) -> Result<()>
Remove permission from user
Sourcepub async fn exists_by_email(&self, email: &str) -> Result<bool>
pub async fn exists_by_email(&self, email: &str) -> Result<bool>
Check if user exists by email
Auto Trait Implementations§
impl Freeze for UserStore
impl !RefUnwindSafe for UserStore
impl Send for UserStore
impl Sync for UserStore
impl Unpin for UserStore
impl !UnwindSafe for UserStore
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more