[][src]Struct sudoku_backend::ops::User

pub struct User {
    pub id: Option<i32>,
    pub username: String,
    pub password: String,
    pub email: String,
    pub created_at: NaiveDateTime,
    pub is_admin: bool,
    pub points_total: i32,
    pub games_total: i32,
    pub games_total_easy: i32,
    pub games_total_medium: i32,
    pub games_total_hard: i32,
}

Refer to doc/user.md for more details.

Fields

Unique user ID.

Actually not optional, but this allows us to get an ID from the database.

User's name or "login" or whatever.

Doubly scrypted password, see doc/user.md for details.

User's contact e-mail

Time user was created.

Whether the user has administrative privileges.

Sum total of the user's points, calculated according to doc/scoring.md#endgame-formula, CHECKed to nonnegativity.

Total amount of games played, CHECKed to nonnegativity.

Amount of easy games played, CHECKed to nonnegativity.

Amount of medium games played, CHECKed to nonnegativity.

Amount of hard games played, CHECKed to nonnegativity.

Methods

impl User
[src]

Create a defaulted user with the specified parameters.

Pull out a user with the specified ID from the specified database.

Insert this user into the specified database, if possible.

Update in-memory and in-DB repr by the specified point count.

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 Clone for User
[src]

Performs copy-assignment from source. Read more

impl From<User> for LoginForm
[src]

impl From<User> for SanitisedUserData
[src]

impl Ord for User
[src]

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Eq for User
[src]

impl PartialOrd<User> for User
[src]

impl Debug for User
[src]

impl Hash for User
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Serialize for User
[src]

impl<'de> Deserialize<'de> for User
[src]

impl<'insert> Insertable<table> for User
[src]

The VALUES clause to insert these records Read more

Insert self into a given table. Read more

impl<'insert> Insertable<table> for &'insert User
[src]

The VALUES clause to insert these records Read more

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]

The Rust type you'd like to map from. Read more

impl<'update> AsChangeset for &'update User
[src]

The table which Self::Changeset will be updating

The update statement this type represents

impl<'update> AsChangeset for User
[src]

The table which Self::Changeset will be updating

The update statement this type represents

impl<'insert> UndecoratedInsertRecord<table> for User
[src]

Auto Trait Implementations

impl Send for User

impl Sync for User

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Typeable for T where
    T: Any
[src]

Get the TypeId of this object.

impl<T> IntoSql for T
[src]

Convert self to an expression for Diesel's query builder. Read more

Convert &self to an expression for Diesel's query builder. Read more