pub struct User {
pub id: UserID,
pub username: String,
pub roles: Roles,
pub prefs: UserSettings,
pub picture: Option<i64>,
}
Fields
id: UserID
username: String
roles: Roles
prefs: UserSettings
picture: Option<i64>
Implementations
sourceimpl User
impl User
sourcepub async fn get_all(
conn: &mut Transaction<'_>
) -> Result<Vec<Self>, DatabaseError>
pub async fn get_all(
conn: &mut Transaction<'_>
) -> Result<Vec<Self>, DatabaseError>
Method gets all entries from the table users.
pub async fn get_by_id(
conn: &mut Transaction<'_>,
uid: UserID
) -> Result<Self, DatabaseError>
pub async fn get(
conn: &mut Transaction<'_>,
username: &str
) -> Result<Self, DatabaseError>
sourcepub async fn authenticate(
conn: &mut Transaction<'_>,
uname: String,
pw: String
) -> Result<Self, DatabaseError>
pub async fn authenticate(
conn: &mut Transaction<'_>,
uname: String,
pw: String
) -> Result<Self, DatabaseError>
Method gets one entry from the table users based on the username supplied and password.
Arguments
uname
- username we wish to target and deletepw_hash
- hash of the password for the user we are trying to access
sourcepub async fn get_pass(
&self,
conn: &mut Transaction<'_>
) -> Result<String, DatabaseError>
pub async fn get_pass(
&self,
conn: &mut Transaction<'_>
) -> Result<String, DatabaseError>
sourcepub async fn delete(
conn: &mut Transaction<'_>,
uid: UserID
) -> Result<usize, DatabaseError>
pub async fn delete(
conn: &mut Transaction<'_>,
uid: UserID
) -> Result<usize, DatabaseError>
Method deletes a entry from the table users and returns the number of rows deleted. NOTE: Return should always be 1
Arguments
uname
- username we wish to target and delete
sourcepub async fn set_password(
&self,
conn: &mut Transaction<'_>,
password: String
) -> Result<usize, DatabaseError>
pub async fn set_password(
&self,
conn: &mut Transaction<'_>,
password: String
) -> Result<usize, DatabaseError>
Method resets the password for a user to a new password.
Arguments
&
- db &ectionpassword
- new password.
pub async fn set_username(
conn: &mut Transaction<'_>,
old_username: String,
new_username: String
) -> Result<usize, DatabaseError>
pub async fn set_picture(
conn: &mut Transaction<'_>,
uid: UserID,
asset_id: i64
) -> Result<usize, DatabaseError>
pub fn has_role(&self, role: &str) -> bool
pub fn roles(&self) -> Roles
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more