diff --git a/src/database/mod.rs b/src/database/mod.rs index c26efac..fe0bfd1 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -8,7 +8,7 @@ use anyhow::Result; use std::path::{Path, PathBuf}; -use crate::model::database::{Identifier, Key, Value}; +use crate::database::model::{Key, SequenceKey, Value}; use crate::solver::RecordType; /* RE-EXPORTS */ @@ -19,9 +19,11 @@ pub use util::SchemaBuilder; #[cfg(test)] mod test; -mod error; mod util; +pub mod model; +pub mod error; + /* IMPLEMENTATION MODULES */ pub mod volatile; @@ -84,7 +86,7 @@ pub trait KVStore { /// Replaces the value associated with `key` with the bits of `record`, /// creating one if it does not already exist. Fails if under any violation /// of implementation-specific assumptions of record size or contents. - fn put(&mut self, key: &Key, record: &R) -> Result<()>; + fn insert(&mut self, key: &Key, record: &R) -> Result<()>; /// Returns the bits associated with the value of `key`, or `None` if there /// is no such association. Infallible due to all possible values of `key` @@ -93,7 +95,7 @@ pub trait KVStore { /// Removes the association of `key` to whatever value it is currently bound /// to, or does nothing if there is no such value. - fn delete(&mut self, key: &Key); + fn remove(&mut self, key: &Key); } /// Allows a database to be evicted to persistent media. Implementing this trait @@ -132,17 +134,21 @@ pub trait Tabular where T: Table, { - /// Creates a new table with `id` and `schema`. Fails if another table with - /// the same `id` already exists, or under any I/O failure. - fn create_table(&self, id: Identifier, schema: Schema) -> Result<&mut T>; + /// Creates a new table with `schema`. Returns a unique key that can be used + /// to later acquire the table. + fn insert_table(&self, schema: Schema) -> Result; /// Obtains a mutable reference to the [`Table`] with `id`. Fails if no such /// table exists in the underlying database, or under any I/O failure. - fn select_table(&self, id: Identifier) -> Result<&mut T>; + fn get_table_mut(&self, key: SequenceKey) -> Result<&mut T>; + + /// Obtains an immutable reference to the [`Table`] with `id`. Fails if no + /// such table exists in the underlying database, or under any I/O failure. + fn get_table(&self, key: SequenceKey) -> Result<&T>; /// Forgets about the association of `id` to any existing table, doing /// nothing if there is no such table. Fails under any I/O failure. - fn delete_table(&self, table: &mut T) -> Result<()>; + fn remove_table(&self, table: &mut T) -> Result<()>; } /* TABLE INTERFACE */ @@ -162,10 +168,10 @@ where /// Returns the total number of bytes being used to store the contents of /// `self`, excluding metadata (both in memory and persistent media). - fn size(&self) -> u64; + fn bytes(&self) -> u64; /// Returns the identifier associated with `self`. - fn id(&self) -> Identifier; + fn id(&self) -> SequenceKey; } /* RECORD INTERFACE */ diff --git a/src/database/model.rs b/src/database/model.rs new file mode 100644 index 0000000..1f8be05 --- /dev/null +++ b/src/database/model.rs @@ -0,0 +1,16 @@ +//! # Database Data Models Module +//! +//! Provides definitions for types used in database interfaces. + +use bitvec::order::Msb0; +use bitvec::slice::BitSlice; + +/// A generic number used to differentiate between objects. +pub type SequenceKey = u64; + +/// The type of a raw sequence of bits encoding a database value associated +/// with a key, backed by a [`BitSlice`] with [`u8`] big-endian storage. +pub type Value = BitSlice; + +/// The type of a database key per an implementation of [`KVStore`]. +pub type Key = BitSlice; diff --git a/src/database/vector/mod.rs b/src/database/vector/mod.rs index 47cdcf7..db8ecea 100644 --- a/src/database/vector/mod.rs +++ b/src/database/vector/mod.rs @@ -17,8 +17,8 @@ use anyhow::Result; use std::path::Path; use crate::{ + database::model::{Key, SequenceKey, Value}, database::{self, KVStore, Persistent, Record, Schema, Tabular}, - model::database::{Identifier, Key, Value}, }; /* DEFINITIONS */ @@ -53,19 +53,19 @@ impl Drop for Database { } impl Tabular for Database { - fn create_table( - &self, - id: Identifier, - schema: Schema, - ) -> Result<&mut Table> { + fn insert_table(&self, schema: Schema) -> Result { todo!() } - fn select_table(&self, id: Identifier) -> Result<&mut Table> { + fn get_table_mut(&self, key: SequenceKey) -> Result<&mut Table> { todo!() } - fn delete_table(&self, id: &mut Table) -> Result<()> { + fn get_table(&self, key: SequenceKey) -> Result<&Table> { + todo!() + } + + fn remove_table(&self, table: &mut Table) -> Result<()> { todo!() } } @@ -79,17 +79,17 @@ impl database::Table for Table { todo!() } - fn size(&self) -> u64 { + fn bytes(&self) -> u64 { todo!() } - fn id(&self) -> Identifier { + fn id(&self) -> SequenceKey { todo!() } } impl KVStore for Table { - fn put(&mut self, key: &Key, value: &R) -> Result<()> + fn insert(&mut self, key: &Key, value: &R) -> Result<()> where R: Record, { @@ -100,7 +100,7 @@ impl KVStore for Table { todo!() } - fn delete(&mut self, key: &Key) { + fn remove(&mut self, key: &Key) { todo!() } } diff --git a/src/database/volatile/mod.rs b/src/database/volatile/mod.rs index a904ee3..16dcd3e 100644 --- a/src/database/volatile/mod.rs +++ b/src/database/volatile/mod.rs @@ -7,9 +7,10 @@ use anyhow::Result; use std::sync::Arc; +use crate::database::model::SequenceKey; use crate::database::util::KeySequencer; -use resource::ResourceManager; -use transaction::TransactionManager; +use crate::database::volatile::resource::ResourceManager; +use crate::database::volatile::transaction::TransactionManager; /* RE-EXPORTS */ @@ -24,7 +25,6 @@ mod resource; /* DEFINITIONS */ -type SequenceKey = u64; type TransactionID = SequenceKey; type ResourceID = SequenceKey; @@ -53,7 +53,7 @@ impl Sequencer { } impl Database { - fn new() -> Self { + pub fn new() -> Self { let sequencer = Arc::new(Sequencer::default()); let resource_manager = ResourceManager::new(sequencer.clone()); let transaction_manager = TransactionManager::new( @@ -68,7 +68,10 @@ impl Database { } } - fn create_transaction(&self, request: Request) -> Result> { + pub fn create_transaction( + &self, + request: Request, + ) -> Result> { let transaction = self .resource_manager .initialize_transaction( diff --git a/src/game/crossteaser/mod.rs b/src/game/crossteaser/mod.rs index 67fab5c..f5068e4 100644 --- a/src/game/crossteaser/mod.rs +++ b/src/game/crossteaser/mod.rs @@ -17,6 +17,8 @@ use anyhow::{Context, Result}; use crate::game::crossteaser::variants::*; +use crate::game::model::State; +use crate::game::model::Variant; use crate::game::Bounded; use crate::game::Codec; use crate::game::Forward; @@ -26,9 +28,7 @@ use crate::game::Transition; use crate::game::Variable; use crate::interface::IOMode; use crate::interface::Solution; -use crate::model::game::State; -use crate::model::game::Variant; -use crate::model::solver::SUtility; +use crate::solver::model::SUtility; use crate::solver::ClassicPuzzle; /* SUBMODULES */ diff --git a/src/game/mock/builder.rs b/src/game/mock/builder.rs index 853ab90..9af60f4 100644 --- a/src/game/mock/builder.rs +++ b/src/game/mock/builder.rs @@ -13,7 +13,7 @@ use std::collections::{HashMap, HashSet}; use crate::game::mock::Node; use crate::game::mock::Session; -use crate::model::game::PlayerCount; +use crate::game::model::PlayerCount; /* DEFINITIONS */ diff --git a/src/game/mock/mod.rs b/src/game/mock/mod.rs index a9007a6..eaaf95c 100644 --- a/src/game/mock/mod.rs +++ b/src/game/mock/mod.rs @@ -12,12 +12,12 @@ use petgraph::{graph::NodeIndex, Graph}; use std::collections::HashMap; +use crate::game::model::Player; +use crate::game::model::PlayerCount; +use crate::game::model::State; use crate::game::Bounded; use crate::game::Transition; -use crate::model::game::Player; -use crate::model::game::PlayerCount; -use crate::model::game::State; -use crate::model::solver::IUtility; +use crate::solver::model::IUtility; /* RE-EXPORTS */ diff --git a/src/game/mod.rs b/src/game/mod.rs index b281c9a..a090062 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -78,20 +78,21 @@ use anyhow::{Context, Result}; -use crate::model::game::{State, Variant, DEFAULT_STATE_BYTES}; +use crate::game::model::{State, Variant, DEFAULT_STATE_BYTES}; /* UTILITY MODULES */ -#[cfg(test)] -pub mod mock; - #[cfg(test)] mod test; - -mod error; mod util; -/* IMPLEMENTED GAMES */ +pub mod model; +pub mod error; + +/* MODULES */ + +#[cfg(test)] +pub mod mock; pub mod crossteaser; pub mod zero_by; diff --git a/src/game/model.rs b/src/game/model.rs new file mode 100644 index 0000000..b352eff --- /dev/null +++ b/src/game/model.rs @@ -0,0 +1,33 @@ +//! # Game Data Models Module +//! +//! Provides definitions for types used in game interfaces. + +use bitvec::{array::BitArray, order::Msb0}; +use clap::ValueEnum; + +/// The default number of bytes used to encode states. +pub const DEFAULT_STATE_BYTES: usize = 8; + +/// Unique identifier of a particular state in a game. +pub type State = BitArray<[u8; B], Msb0>; + +/// String encoding some specific game's variant. +pub type Variant = String; + +/// Unique identifier for a player in a game. +pub type Player = usize; + +/// Unique identifier of a subset of states of a game. +pub type Partition = u64; + +/// Count of the number of states in a game. +pub type StateCount = u64; + +/// Count of the number of players in a game. +pub type PlayerCount = Player; + +// Specifies the game offerings available through all interfaces. +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] +pub enum GameModule { + ZeroBy, +} diff --git a/src/game/util.rs b/src/game/util.rs index 9ff88e8..f268ef1 100644 --- a/src/game/util.rs +++ b/src/game/util.rs @@ -4,17 +4,19 @@ //! more than a single game. use std::fmt::Display; +use std::hash::{DefaultHasher, Hasher}; use anyhow::bail; -use anyhow::{Context, Result}; +use anyhow::Result; +use crate::database::model::SequenceKey; +use crate::game::model::State; use crate::game::GameData; use crate::game::Information; +use crate::game::Variable; +use crate::game::{error::GameError, Bounded, Codec, Transition}; use crate::interface::GameAttribute; -use crate::{ - game::{error::GameError, Bounded, Codec, Transition}, - model::game::State, -}; +use crate::util::Identify; /* STATE HISTORY VERIFICATION */ @@ -163,3 +165,17 @@ impl GameData { } } } + +/* IDENTIFICATION */ + +impl Identify for G +where + G: Variable, +{ + fn id(&self) -> SequenceKey { + let mut hasher = DefaultHasher::new(); + self.variant_string() + .hash(&mut hasher); + hasher.finish() + } +} diff --git a/src/game/zero_by/mod.rs b/src/game/zero_by/mod.rs index 34acc5f..5e4b03c 100644 --- a/src/game/zero_by/mod.rs +++ b/src/game/zero_by/mod.rs @@ -14,6 +14,8 @@ use anyhow::{Context, Result}; use bitvec::field::BitField; use crate::game::error::GameError; +use crate::game::model::Variant; +use crate::game::model::{Player, PlayerCount, State}; use crate::game::zero_by::states::*; use crate::game::zero_by::variants::*; use crate::game::Information; @@ -21,10 +23,8 @@ use crate::game::Variable; use crate::game::{Bounded, Codec, Forward}; use crate::game::{GameData, Transition}; use crate::interface::{IOMode, Solution}; -use crate::model::game::Variant; -use crate::model::game::{Player, PlayerCount, State}; -use crate::model::solver::SUtility; use crate::solver::algorithm::strong; +use crate::solver::model::SUtility; use crate::solver::{Sequential, SimpleUtility}; /* SUBMODULES */ diff --git a/src/game/zero_by/states.rs b/src/game/zero_by/states.rs index cdd60c7..82e8f78 100644 --- a/src/game/zero_by/states.rs +++ b/src/game/zero_by/states.rs @@ -7,11 +7,11 @@ use regex::Regex; use crate::game::error::GameError; +use crate::game::model::Player; +use crate::game::model::State; use crate::game::zero_by::Elements; use crate::game::zero_by::Session; use crate::game::zero_by::NAME; -use crate::model::game::Player; -use crate::model::game::State; /* ZERO-BY STATE ENCODING */ diff --git a/src/game/zero_by/variants.rs b/src/game/zero_by/variants.rs index fbe21da..aeb8973 100644 --- a/src/game/zero_by/variants.rs +++ b/src/game/zero_by/variants.rs @@ -7,8 +7,8 @@ use bitvec::field::BitField; use regex::Regex; use crate::game::error::GameError; +use crate::game::model::{Player, State}; use crate::game::zero_by::{Session, NAME}; -use crate::model::game::{Player, State}; use crate::util::min_ubits; /* ZERO-BY VARIANT ENCODING */ diff --git a/src/interface/standard/cli.rs b/src/interface/standard/cli.rs index 574216f..ccee112 100644 --- a/src/interface/standard/cli.rs +++ b/src/interface/standard/cli.rs @@ -7,11 +7,11 @@ use clap::{Args, Parser, Subcommand}; +use crate::database::model::SequenceKey; +use crate::game::model::GameModule; use crate::interface::{ GameAttribute, IOMode, InfoFormat, QueryFormat, Solution, }; -use crate::model::database::Identifier; -use crate::model::game::GameModule; /* COMMAND LINE INTERFACE */ @@ -98,7 +98,7 @@ pub struct QueryArgs { /* DEFAULTS PROVIDED */ /// Numeric identifier for the table that the query should be run on. #[arg(short, long)] - pub table: Option, + pub table: Option, /// Query specification string, conforming to ExQL syntax. #[arg(short, long)] diff --git a/src/main.rs b/src/main.rs index 3f3c5fe..e047796 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,16 +14,15 @@ use std::process; use anyhow::{Context, Result}; use clap::Parser; +use crate::game::model::GameModule; use crate::game::{Forward, Information}; use crate::interface::standard::cli::*; -use crate::model::game::GameModule; /* MODULES */ mod interface; mod database; mod solver; -mod model; mod game; mod util; diff --git a/src/model.rs b/src/model.rs deleted file mode 100644 index f43a49d..0000000 --- a/src/model.rs +++ /dev/null @@ -1,103 +0,0 @@ -#![allow(dead_code)] -//! # Data Models Module -//! -//! This module contains centralized definitions for custom data types used -//! throughout the project. - -/// # Game Data Models Module -/// -/// Provides definitions for types used in game interfaces. -pub mod game { - - use bitvec::{array::BitArray, order::Msb0}; - use clap::ValueEnum; - - /// The default number of bytes used to encode states. - pub const DEFAULT_STATE_BYTES: usize = 8; - - /// Unique identifier of a particular state in a game. - pub type State = - BitArray<[u8; B], Msb0>; - - /// String encoding some specific game's variant. - pub type Variant = String; - - /// Unique identifier for a player in a game. - pub type Player = usize; - - /// Unique identifier of a subset of states of a game. - pub type Partition = u64; - - /// Count of the number of states in a game. - pub type StateCount = u64; - - /// Count of the number of players in a game. - pub type PlayerCount = Player; - - // Specifies the game offerings available through all interfaces. - #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] - pub enum GameModule { - ZeroBy, - } -} - -/// # Solver Data Models Module -/// -/// Provides definitions for types used in solver implementations. -pub mod solver { - /// Indicates the "depth of draw" which a drawing position corresponds to. - /// For more information, see [this whitepaper](TODO). This value should be - /// 0 for non-drawing positions. - pub type DrawDepth = u64; - - /// Indicates the number of choices that players have to make to reach a - /// terminal state in a game under perfect play. For drawing positions, - /// indicates the number of choices players can make to bring the game to a - /// state which can transition to a non-drawing state. - pub type Remoteness = u64; - - /// Please refer to [this](https://en.wikipedia.org/wiki/Mex_(mathematics)). - pub type MinExclusion = u64; - - /// A measure of how "good" an outcome is for a given player in a game. - /// Positive values indicate an overall gain from having played the game, - /// and negative values are net losses. The metric over abstract utility is - /// subjective. - pub type RUtility = f64; - - /// A discrete measure of how "good" an outcome is for a given player. - /// Positive values indicate an overall gain from having played the game, - /// and negative values are net losses. The metric over abstract utility is - /// subjective. - pub type IUtility = i64; - - /// A simple measure of hoe "good" an outcome is for a given player in a - /// game. The specific meaning of each variant can change based on the game - /// in consideration, but this is ultimately an intuitive notion. - #[derive(Clone, Copy)] - pub enum SUtility { - Lose = 0, - Draw = 1, - Tie = 2, - Win = 3, - } -} - -/// # Database Data Models Module -/// -/// Provides definitions for types used in database interfaces. -pub mod database { - - use bitvec::order::Msb0; - use bitvec::slice::BitSlice; - - /// A generic number used to differentiate between objects. - pub type Identifier = u64; - - /// The type of a raw sequence of bits encoding a database value associated - /// with a key, backed by a [`BitSlice`] with [`u8`] big-endian storage. - pub type Value = BitSlice; - - /// The type of a database key per an implementation of [`KVStore`]. - pub type Key = BitSlice; -} diff --git a/src/solver/algorithm/strong/acyclic.rs b/src/solver/algorithm/strong/acyclic.rs index 205a581..fedcb1a 100644 --- a/src/solver/algorithm/strong/acyclic.rs +++ b/src/solver/algorithm/strong/acyclic.rs @@ -5,11 +5,11 @@ use anyhow::{Context, Result}; use crate::database::volatile; -use crate::database::{KVStore, Tabular}; +use crate::database::KVStore; +use crate::game::model::PlayerCount; use crate::game::{Bounded, Transition}; use crate::interface::IOMode; -use crate::model::game::PlayerCount; -use crate::model::solver::{IUtility, Remoteness}; +use crate::solver::model::{IUtility, Remoteness}; use crate::solver::record::mur::RecordBuffer; use crate::solver::{IntegerUtility, RecordType, Sequential}; use crate::util::Identify; @@ -88,7 +88,7 @@ where .context("Failed to create placeholder record.")?; if db.get(&curr).is_none() { - db.put(&curr, &buf)?; + db.insert(&curr, &buf)?; if game.end(curr) { buf = RecordBuffer::new(game.players()) @@ -100,7 +100,7 @@ where buf.set_remoteness(0) .context("Failed to set remoteness for end state.")?; - db.put(&curr, &buf)?; + db.insert(&curr, &buf)?; } else { stack.push(curr); stack.extend( @@ -132,7 +132,7 @@ where .set_remoteness(min_rem + 1) .context("Failed to set remoteness for solved record.")?; - db.put(&curr, &optimal)?; + db.insert(&curr, &optimal)?; } } Ok(()) diff --git a/src/solver/mod.rs b/src/solver/mod.rs index 70724f1..722bc0c 100644 --- a/src/solver/mod.rs +++ b/src/solver/mod.rs @@ -6,13 +6,20 @@ //! solutions, or finding "solutions" under different game-theoretic definitions //! of that word. -use crate::model::{ - game::{ - Partition, Player, PlayerCount, State, StateCount, - DEFAULT_STATE_BYTES as DBYTES, - }, - solver::{IUtility, RUtility, SUtility}, +use crate::game::model::{ + Partition, Player, PlayerCount, State, StateCount, + DEFAULT_STATE_BYTES as DBYTES, }; +use crate::solver::model::{IUtility, RUtility, SUtility}; + +/* UTILITY MODULES */ + +#[cfg(test)] +mod test; +mod util; + +pub mod error; +pub mod model; /* MODULES */ @@ -56,11 +63,6 @@ pub mod algorithm { } } -#[cfg(test)] -mod test; -mod error; -mod util; - /* SOLVER DATABASE RECORDS */ /// A record layout that can be used to encode and decode the attributes stored diff --git a/src/solver/model.rs b/src/solver/model.rs new file mode 100644 index 0000000..6187d39 --- /dev/null +++ b/src/solver/model.rs @@ -0,0 +1,40 @@ +//! # Solver Data Models Module +//! +//! Provides definitions for types used in solver implementations. + +/// Indicates the "depth of draw" which a drawing position corresponds to. +/// For more information, see [this whitepaper](TODO). This value should be +/// 0 for non-drawing positions. +pub type DrawDepth = u64; + +/// Indicates the number of choices that players have to make to reach a +/// terminal state in a game under perfect play. For drawing positions, +/// indicates the number of choices players can make to bring the game to a +/// state which can transition to a non-drawing state. +pub type Remoteness = u64; + +/// Please refer to [this](https://en.wikipedia.org/wiki/Mex_(mathematics)). +pub type MinExclusion = u64; + +/// A measure of how "good" an outcome is for a given player in a game. +/// Positive values indicate an overall gain from having played the game, +/// and negative values are net losses. The metric over abstract utility is +/// subjective. +pub type RUtility = f64; + +/// A discrete measure of how "good" an outcome is for a given player. +/// Positive values indicate an overall gain from having played the game, +/// and negative values are net losses. The metric over abstract utility is +/// subjective. +pub type IUtility = i64; + +/// A simple measure of hoe "good" an outcome is for a given player in a +/// game. The specific meaning of each variant can change based on the game +/// in consideration, but this is ultimately an intuitive notion. +#[derive(Clone, Copy)] +pub enum SUtility { + Lose = 0, + Draw = 1, + Tie = 2, + Win = 3, +} diff --git a/src/solver/record/mur.rs b/src/solver/record/mur.rs index ef6dd00..fbc3814 100644 --- a/src/solver/record/mur.rs +++ b/src/solver/record/mur.rs @@ -11,9 +11,9 @@ use bitvec::slice::BitSlice; use bitvec::{bitarr, BitArr}; use crate::database::{Attribute, Datatype, Record, Schema, SchemaBuilder}; -use crate::model::game::{Player, PlayerCount}; -use crate::model::solver::{IUtility, Remoteness}; +use crate::game::model::{Player, PlayerCount}; use crate::solver::error::SolverError::RecordViolation; +use crate::solver::model::{IUtility, Remoteness}; use crate::solver::RecordType; use crate::util; diff --git a/src/solver/record/rem.rs b/src/solver/record/rem.rs index fe2c7c6..18bfa4b 100644 --- a/src/solver/record/rem.rs +++ b/src/solver/record/rem.rs @@ -9,8 +9,8 @@ use bitvec::slice::BitSlice; use bitvec::{bitarr, BitArr}; use crate::database::{Attribute, Datatype, Record, Schema, SchemaBuilder}; -use crate::model::solver::Remoteness; use crate::solver::error::SolverError::RecordViolation; +use crate::solver::model::Remoteness; use crate::solver::RecordType; use crate::util; diff --git a/src/solver/record/sur.rs b/src/solver/record/sur.rs index 9ee6dd8..2caf509 100644 --- a/src/solver/record/sur.rs +++ b/src/solver/record/sur.rs @@ -11,9 +11,9 @@ use bitvec::slice::BitSlice; use bitvec::{bitarr, BitArr}; use crate::database::{Attribute, Datatype, Record, Schema, SchemaBuilder}; -use crate::model::game::{Player, PlayerCount}; -use crate::model::solver::{Remoteness, SUtility}; +use crate::game::model::{Player, PlayerCount}; use crate::solver::error::SolverError::RecordViolation; +use crate::solver::model::{Remoteness, SUtility}; use crate::solver::RecordType; use crate::util; diff --git a/src/solver/util.rs b/src/solver/util.rs index d237da5..1b7e96f 100644 --- a/src/solver/util.rs +++ b/src/solver/util.rs @@ -7,8 +7,8 @@ use std::fmt::Display; use std::ops::Not; use crate::database::Schema; -use crate::model::solver::{IUtility, RUtility, SUtility}; use crate::solver::error::SolverError; +use crate::solver::model::{IUtility, RUtility, SUtility}; use crate::solver::{record, RecordType}; /* RECORD TYPE IMPLEMENTATIONS */ diff --git a/src/test.rs b/src/test.rs index c08b154..f1fb756 100644 --- a/src/test.rs +++ b/src/test.rs @@ -4,7 +4,7 @@ //! on throughout the project, and defines the structure of the development //! resources that are generated through tests. -use anyhow::{anyhow, bail, Context, Result}; +use anyhow::{bail, Context, Result}; use strum_macros::Display; use std::{ diff --git a/src/util.rs b/src/util.rs index 2c3564e..31901b1 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,9 +3,7 @@ //! This module makes room for verbose or repeated routines used in the //! top-level module of this crate. -use std::hash::{DefaultHasher, Hash, Hasher}; - -use crate::{game::Variable, model::database::Identifier}; +use crate::database::model::SequenceKey; /* INTERFACES */ @@ -15,19 +13,7 @@ pub trait Identify { /// Returns an ID that is unique in some degree to the state of this object. /// The semantics of when variations are acceptable are implicit, and should /// be enforced by an API consuming the [`Identify`] trait. - fn id(&self) -> Identifier; -} - -impl Identify for G -where - G: Variable, -{ - fn id(&self) -> Identifier { - let mut hasher = DefaultHasher::new(); - self.variant_string() - .hash(&mut hasher); - hasher.finish() - } + fn id(&self) -> SequenceKey; } /* BIT FIELDS */