[][src]Struct sudoku_backend::ops::SudokuSolution

pub struct SudokuSolution {
    pub id: Option<i32>,
    pub display_name: String,
    pub board_id: i32,
    pub skeleton: String,
    pub difficulty: i32,
    pub solution_duration_secs: i32,
    pub score: i32,
    pub solution_time: NaiveDateTime,
}

Refer to doc/sudoku.md for more details.

Fields

Unique board ID.

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

Solver's display name

The solved board ID

The solved board skeleton

Board "difficulty", between one and three

Time in seconds taken to achieve the solution

Score achieved for the solve

Time the solution occured at

Methods

impl SudokuSolution
[src]

Create a ready-to-insert solution out of the specified data.

Does not validate.

Retrieve the board with the specified ID.

Examples

Given:

INSERT INTO "sudoku_solutions"
    VALUES(1, 'benlo', 104,
           '.79.2.48...5..........3762.....4627....85......4.9....48....7..5......3.1.....9..',
           3, 26, 435, '2018-08-03 18:26:35');

INSERT INTO "sudoku_solutions"
    VALUES(2, 'EasyStudentBegonia', 104,
           '3.9..54..............937.2.9...4.27...6......21....56..8.56....5...1.8..1..3.....',
           3, 22, 498, '2018-08-03 18:42:56');

INSERT INTO "sudoku_solutions"
    VALUES(3, 'WithoutHighBirch', 104,
           '3.9..54.1.25.8.....4.9......581...7...68.....2....35...8....7.2.......3.1......54',
           3, 14, 732, '2018-08-03 18:44:06');

INSERT INTO "sudoku_solutions"
    VALUES(4, 'LateBrokenAppendix', 104,
           '.7...5..1...4.1...8....762.95......3..68.....21.............71....2......6.3..95.',
           3, 14, 732, '2018-08-03 18:44:25');

The following holds:

let solutions = SudokuSolution::leaders(&LeaderboardConfig {
    count: 3,
    ordering: SolutionOrdering::BestToWorst,
}, &db).unwrap();
assert_eq!(
    solutions,
    &[SudokuSolution {
          id: Some(3),
          display_name: "WithoutHighBirch".to_string(),
          board_id: 104,
          skeleton: "3.9..54.1.25.8.....4.9......581...7...68.....2....35...8....7.2.......3.1......54".to_string(),
          difficulty: 3,
          solution_duration_secs: 14,
          score: 732,
          solution_time: NaiveDate::from_ymd(2018, 8, 3).and_hms(18, 44, 06),
      },
      SudokuSolution {
          id: Some(4),
          display_name: "LateBrokenAppendix".to_string(),
          board_id: 104,
          skeleton: ".7...5..1...4.1...8....762.95......3..68.....21.............71....2......6.3..95.".to_string(),
          difficulty: 3,
          solution_duration_secs: 14,
          score: 732,
          solution_time: NaiveDate::from_ymd(2018, 8, 3).and_hms(18, 44, 25),
      },
      SudokuSolution {
          id: Some(2),
          display_name: "EasyStudentBegonia".to_string(),
          board_id: 104,
          skeleton: "3.9..54..............937.2.9...4.27...6......21....56..8.56....5...1.8..1..3.....".to_string(),
          difficulty: 3,
          solution_duration_secs: 22,
          score: 498,
          solution_time: NaiveDate::from_ymd(2018, 8, 3).and_hms(18, 42, 56),
      }]);

Insert this board into the specified DB, updating its id.

Examples

Assuming empty table:

let mut board =
    SudokuSolution::new(username, board_skeleton, &SudokuBoard::get(board_id, &db).unwrap(), Duration::seconds(25));
assert!(solution.id.is_none());

solution.insert(&db).unwrap();
assert_eq!(solution.id, Some(1));

Trait Implementations

impl PartialEq<SudokuSolution> for SudokuSolution
[src]

impl Clone for SudokuSolution
[src]

Performs copy-assignment from source. Read more

impl Ord for SudokuSolution
[src]

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Eq for SudokuSolution
[src]

impl PartialOrd<SudokuSolution> for SudokuSolution
[src]

impl Debug for SudokuSolution
[src]

impl Hash for SudokuSolution
[src]

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

impl Serialize for SudokuSolution
[src]

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

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

The VALUES clause to insert these records Read more

Insert self into a given table. Read more

impl<'insert> Insertable<table> for &'insert SudokuSolution
[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 SudokuSolution where
    (Option<i32>, String, i32, String, i32, i32, i32, NaiveDateTime): Queryable<__ST, __DB>, 
[src]

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

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

The table which Self::Changeset will be updating

The update statement this type represents

impl<'update> AsChangeset for SudokuSolution
[src]

The table which Self::Changeset will be updating

The update statement this type represents

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

Auto Trait Implementations

impl Send for SudokuSolution

impl Sync for SudokuSolution

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