[−][src]Struct sudoku_backend::ops::User
Refer to doc/user.md
for more details.
Fields
id: Option<i32>
Unique user ID.
Actually not optional, but this allows us to get an ID from the database.
username: String
User's name or "login" or whatever.
password: String
Doubly scrypted password, see doc/user.md
for details.
email: String
User's contact e-mail
created_at: NaiveDateTime
Time user was created.
is_admin: bool
Whether the user has administrative privileges.
points_total: i32
Sum total of the user's points, calculated according to doc/scoring.md#endgame-formula
, CHECK
ed to nonnegativity.
games_total: i32
Total amount of games played, CHECK
ed to nonnegativity.
games_total_easy: i32
Amount of easy games played, CHECK
ed to nonnegativity.
games_total_medium: i32
Amount of medium games played, CHECK
ed to nonnegativity.
games_total_hard: i32
Amount of hard games played, CHECK
ed to nonnegativity.
Methods
impl User
[src]
impl User
pub fn new<U: Into<String>, P: Into<String>, E: Into<String>>(
username: U,
password: P,
email: E
) -> User
[src]
pub fn new<U: Into<String>, P: Into<String>, E: Into<String>>(
username: U,
password: P,
email: E
) -> User
Create a defaulted user with the specified parameters.
pub fn get_by_id(id: i32, db: &SqliteConnection) -> Result<User, &'static str>
[src]
pub fn get_by_id(id: i32, db: &SqliteConnection) -> Result<User, &'static str>
Pull out a user with the specified ID from the specified database.
pub fn add(&self, db: &SqliteConnection) -> Result<(), &'static str>
[src]
pub fn add(&self, db: &SqliteConnection) -> Result<(), &'static str>
Insert this user into the specified database, if possible.
pub fn solve(
&mut self,
for_points: usize,
for_difficulty: BoardDifficulty,
db: &SqliteConnection
) -> Result<(), &'static str>
[src]
pub fn solve(
&mut self,
for_points: usize,
for_difficulty: BoardDifficulty,
db: &SqliteConnection
) -> Result<(), &'static str>
Update in-memory and in-DB repr by the specified point count.
pub fn leaders(
cfg: &LeaderboardConfig,
db: &SqliteConnection
) -> Result<Vec<User>, &'static str>
[src]
pub fn leaders(
cfg: &LeaderboardConfig,
db: &SqliteConnection
) -> Result<Vec<User>, &'static str>
Retrieve the board with the specified ID.
Examples
Given:
INSERT INTO "users"
VALUES(1, 'karolsw3', 'password', 'email', '2018-07-23 18:18:24', 0, 435, 1, 1, 0, 0);
INSERT INTO "users"
VALUES(2, 'nabijaczleweli', 'password', 'email', '2018-07-23 19:08:09', 1, 732, 1, 0, 1, 0);
INSERT INTO "users"
VALUES(3, 'sehe', 'password', 'email', '2018-07-23 19:08:56', 0, 1230, 2, 0, 0, 2);
INSERT INTO "users"
VALUES(4, 'skorezore', 'password', 'email', '2018-07-23 19:11:06', 0, 222, 1, 0, 0, 1);
The following holds:
let users = User::leaders(&LeaderboardConfig { count: 3, ordering: SolutionOrdering::WorstToBest, }, &db).unwrap(); assert_eq!( users, &[User { id: Some(4), username: "skorezore".to_string(), password: "password".to_string(), email: "skorezore@e.mail".to_string(), created_at: NaiveDate::from_ymd(2018, 07, 23).and_hms(19, 11, 06), is_admin: false, points_total: 222, games_total: 1, games_total_easy: 0, games_total_medium: 0, games_total_hard: 1, }, User { id: Some(1), username: "karolsw3".to_string(), password: "password".to_string(), email: "karolsw3@e.mail".to_string(), created_at: NaiveDate::from_ymd(2018, 07, 23).and_hms(18, 18, 24), is_admin: false, points_total: 435, games_total: 1, games_total_easy: 1, games_total_medium: 0, games_total_hard: 0, }, User { id: Some(2), username: "nabijaczleweli".to_string(), password: "password".to_string(), email: "nabijaczleweli@e.mail".to_string(), created_at: NaiveDate::from_ymd(2018, 07, 23).and_hms(19, 08, 09), is_admin: true, points_total: 732, games_total: 1, games_total_easy: 0, games_total_medium: 1, games_total_hard: 0, }]);
Trait Implementations
impl PartialEq<User> for User
[src]
impl PartialEq<User> for User
impl Clone for User
[src]
impl Clone for User
fn clone(&self) -> User
[src]
fn clone(&self) -> User
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl From<User> for LoginForm
[src]
impl From<User> for LoginForm
impl From<User> for SanitisedUserData
[src]
impl From<User> for SanitisedUserData
fn from(u: User) -> SanitisedUserData
[src]
fn from(u: User) -> SanitisedUserData
impl Ord for User
[src]
impl Ord for User
fn cmp(&self, other: &User) -> Ordering
[src]
fn cmp(&self, other: &User) -> Ordering
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Eq for User
[src]
impl Eq for User
impl PartialOrd<User> for User
[src]
impl PartialOrd<User> for User
fn partial_cmp(&self, other: &User) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &User) -> Option<Ordering>
fn lt(&self, other: &User) -> bool
[src]
fn lt(&self, other: &User) -> bool
fn le(&self, other: &User) -> bool
[src]
fn le(&self, other: &User) -> bool
fn gt(&self, other: &User) -> bool
[src]
fn gt(&self, other: &User) -> bool
fn ge(&self, other: &User) -> bool
[src]
fn ge(&self, other: &User) -> bool
impl Debug for User
[src]
impl Debug for User
impl Hash for User
[src]
impl Hash for User
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Serialize for User
[src]
impl Serialize for User
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
impl<'de> Deserialize<'de> for User
[src]
impl<'de> Deserialize<'de> for User
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
impl<'insert> Insertable<table> for User
[src]
impl<'insert> Insertable<table> for User
type Values = <(Option<Eq<id, i32>>, Option<Eq<username, String>>, Option<Eq<password, String>>, Option<Eq<email, String>>, Option<Eq<created_at, NaiveDateTime>>, Option<Eq<is_admin, bool>>, Option<Eq<points_total, i32>>, Option<Eq<games_total, i32>>, Option<Eq<games_total_easy, i32>>, Option<Eq<games_total_medium, i32>>, Option<Eq<games_total_hard, i32>>) as Insertable<table>>::Values
The VALUES
clause to insert these records Read more
fn values(self) -> Self::Values
[src]
fn values(self) -> Self::Values
fn insert_into(
self,
table: T
) -> InsertStatement<T, Self::Values, Insert, NoReturningClause>
[src]
fn insert_into(
self,
table: T
) -> InsertStatement<T, Self::Values, Insert, NoReturningClause>
Insert self
into a given table. Read more
impl<'insert> Insertable<table> for &'insert User
[src]
impl<'insert> Insertable<table> for &'insert User
type Values = <(Option<Eq<id, &'insert i32>>, Option<Eq<username, &'insert String>>, Option<Eq<password, &'insert String>>, Option<Eq<email, &'insert String>>, Option<Eq<created_at, &'insert NaiveDateTime>>, Option<Eq<is_admin, &'insert bool>>, Option<Eq<points_total, &'insert i32>>, Option<Eq<games_total, &'insert i32>>, Option<Eq<games_total_easy, &'insert i32>>, Option<Eq<games_total_medium, &'insert i32>>, Option<Eq<games_total_hard, &'insert i32>>) as Insertable<table>>::Values
The VALUES
clause to insert these records Read more
fn values(self) -> Self::Values
[src]
fn values(self) -> Self::Values
fn insert_into(
self,
table: T
) -> InsertStatement<T, Self::Values, Insert, NoReturningClause>
[src]
fn insert_into(
self,
table: T
) -> InsertStatement<T, Self::Values, Insert, NoReturningClause>
Insert self
into a given table. Read more
impl<__DB: Backend, __ST> Queryable<__ST, __DB> for User where
(Option<i32>, String, String, String, NaiveDateTime, bool, i32, i32, i32, i32, i32): Queryable<__ST, __DB>,
[src]
impl<__DB: Backend, __ST> Queryable<__ST, __DB> for User where
(Option<i32>, String, String, String, NaiveDateTime, bool, i32, i32, i32, i32, i32): Queryable<__ST, __DB>,
type Row = <(Option<i32>, String, String, String, NaiveDateTime, bool, i32, i32, i32, i32, i32) as Queryable<__ST, __DB>>::Row
The Rust type you'd like to map from. Read more
fn build(row: Self::Row) -> Self
[src]
fn build(row: Self::Row) -> Self
impl<'update> AsChangeset for &'update User
[src]
impl<'update> AsChangeset for &'update User
type Target = table
The table which Self::Changeset
will be updating
type Changeset = <(Eq<username, &'update String>, Eq<password, &'update String>, Eq<email, &'update String>, Eq<created_at, &'update NaiveDateTime>, Eq<is_admin, &'update bool>, Eq<points_total, &'update i32>, Eq<games_total, &'update i32>, Eq<games_total_easy, &'update i32>, Eq<games_total_medium, &'update i32>, Eq<games_total_hard, &'update i32>) as AsChangeset>::Changeset
The update statement this type represents
fn as_changeset(self) -> Self::Changeset
[src]
fn as_changeset(self) -> Self::Changeset
impl<'update> AsChangeset for User
[src]
impl<'update> AsChangeset for User
type Target = table
The table which Self::Changeset
will be updating
type Changeset = <(Eq<username, String>, Eq<password, String>, Eq<email, String>, Eq<created_at, NaiveDateTime>, Eq<is_admin, bool>, Eq<points_total, i32>, Eq<games_total, i32>, Eq<games_total_easy, i32>, Eq<games_total_medium, i32>, Eq<games_total_hard, i32>) as AsChangeset>::Changeset
The update statement this type represents
fn as_changeset(self) -> Self::Changeset
[src]
fn as_changeset(self) -> Self::Changeset
impl<'insert> UndecoratedInsertRecord<table> for User
[src]
impl<'insert> UndecoratedInsertRecord<table> for User
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
impl<T> Typeable for T where
T: Any,
[src]
impl<T> Typeable for T where
T: Any,
impl<T> IntoSql for T
[src]
impl<T> IntoSql for T
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
[src]
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
Convert self
to an expression for Diesel's query builder. Read more
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
[src]
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
Convert &self
to an expression for Diesel's query builder. Read more