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>
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
&
- postgres &ectionuname
- 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
&
- postgres &ectionuname
- 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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more