pub struct Specimen {
pub id: i64,
pub user_id: i64,
pub species_id: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub size_baby_ratio: f32,
pub size_adult_ratio: f32,
pub lifespan_days_ratio: f32,
pub catch_age: f32,
}Fields§
§id: i64Primary key of this specimen in the database
user_id: i64The primary key of the user this specimen belongs to
species_id: i32The species ID this specimen is associated with (species are defined in the config)
created_at: DateTime<Utc>When the dataset was created
updated_at: DateTime<Utc>When the dataset was last updated
size_baby_ratio: f32Baby size ratio (0-1) relative to species’ min/max baby size range
size_adult_ratio: f32Adult size ratio (0-1) relative to species’ min/max adult size range
lifespan_days_ratio: f32Lifespan ratio (0-1) relative to species’ min/max lifespan range
catch_age: f32The age this fish was caught at (from 0 to 1)
Implementations§
Source§impl Specimen
impl Specimen
pub fn get_age( &self, config: Arc<dyn ConfigInterface>, time_multiplier: f32, ) -> GameResult<f32>
pub fn get_size_mm( &self, config: Arc<dyn ConfigInterface>, time_multiplier: f32, ) -> GameResult<f32>
pub fn get_weight_g( &self, config: Arc<dyn ConfigInterface>, time_multiplier: f32, ) -> GameResult<f32>
pub fn get_total_size_ratio( &self, config: Arc<dyn ConfigInterface>, time_multiplier: f32, ) -> GameResult<f32>
Trait Implementations§
Source§impl<'update> AsChangeset for &'update Specimen
impl<'update> AsChangeset for &'update Specimen
Source§type Changeset = <(Grouped<Eq<user_id, <&'update i64 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<species_id, <&'update i32 as AsExpression<<species_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <&'update DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <&'update DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_baby_ratio, <&'update f32 as AsExpression<<size_baby_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_adult_ratio, <&'update f32 as AsExpression<<size_adult_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<lifespan_days_ratio, <&'update f32 as AsExpression<<lifespan_days_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<catch_age, <&'update f32 as AsExpression<<catch_age as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
type Changeset = <(Grouped<Eq<user_id, <&'update i64 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<species_id, <&'update i32 as AsExpression<<species_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <&'update DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <&'update DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_baby_ratio, <&'update f32 as AsExpression<<size_baby_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_adult_ratio, <&'update f32 as AsExpression<<size_adult_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<lifespan_days_ratio, <&'update f32 as AsExpression<<lifespan_days_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<catch_age, <&'update f32 as AsExpression<<catch_age as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
The update statement this type represents
Source§fn as_changeset(self) -> <Self as AsChangeset>::Changeset
fn as_changeset(self) -> <Self as AsChangeset>::Changeset
Convert
self into the actual update statement being executedSource§impl AsChangeset for Specimen
impl AsChangeset for Specimen
Source§type Changeset = <(Grouped<Eq<user_id, <i64 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<species_id, <i32 as AsExpression<<species_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_baby_ratio, <f32 as AsExpression<<size_baby_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_adult_ratio, <f32 as AsExpression<<size_adult_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<lifespan_days_ratio, <f32 as AsExpression<<lifespan_days_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<catch_age, <f32 as AsExpression<<catch_age as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
type Changeset = <(Grouped<Eq<user_id, <i64 as AsExpression<<user_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<species_id, <i32 as AsExpression<<species_id as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_baby_ratio, <f32 as AsExpression<<size_baby_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<size_adult_ratio, <f32 as AsExpression<<size_adult_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<lifespan_days_ratio, <f32 as AsExpression<<lifespan_days_ratio as Expression>::SqlType>>::Expression>>, Grouped<Eq<catch_age, <f32 as AsExpression<<catch_age as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
The update statement this type represents
Source§fn as_changeset(self) -> <Self as AsChangeset>::Changeset
fn as_changeset(self) -> <Self as AsChangeset>::Changeset
Convert
self into the actual update statement being executedSource§impl<'de> Deserialize<'de> for Specimen
impl<'de> Deserialize<'de> for Specimen
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Model for Specimen
impl Model for Specimen
type Table = table
type PrimaryKeyType = i64
type InsertType = NewSpecimen
fn table() -> Self::Table
fn id(&self) -> Self::PrimaryKeyType
Source§impl<__DB: Backend, __ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6, __ST7, __ST8> Queryable<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6, __ST7, __ST8), __DB> for Specimen
impl<__DB: Backend, __ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6, __ST7, __ST8> Queryable<(__ST0, __ST1, __ST2, __ST3, __ST4, __ST5, __ST6, __ST7, __ST8), __DB> for Specimen
Source§impl Repository<Specimen> for SpecimenRepository
impl Repository<Specimen> for SpecimenRepository
fn get_db(&self) -> Arc<RwLock<dyn DatabaseInterface>>
fn create( &self, new_entity: NewSpecimen, ) -> Result<Specimen, GameRepositoryError>
fn find(&self, id: i64) -> Result<Option<Specimen>, GameRepositoryError>
fn save(&self, entity: Specimen) -> Result<Specimen, GameRepositoryError>
fn delete(&self, entity: Specimen) -> Result<bool, GameRepositoryError>
fn get_connection( &self, ) -> Result<PooledConnection<ConnectionManager<PgConnection>>, GameDatabaseError>
Source§impl<__DB: Backend> Selectable<__DB> for Specimen
impl<__DB: Backend> Selectable<__DB> for Specimen
Source§type SelectExpression = (id, user_id, species_id, created_at, updated_at, size_baby_ratio, size_adult_ratio, lifespan_days_ratio, catch_age)
type SelectExpression = (id, user_id, species_id, created_at, updated_at, size_baby_ratio, size_adult_ratio, lifespan_days_ratio, catch_age)
The expression you’d like to select. Read more
Source§fn construct_selection() -> Self::SelectExpression
fn construct_selection() -> Self::SelectExpression
Construct an instance of the expression
impl StructuralPartialEq for Specimen
Auto Trait Implementations§
impl Freeze for Specimen
impl RefUnwindSafe for Specimen
impl Send for Specimen
impl Sync for Specimen
impl Unpin for Specimen
impl UnwindSafe for Specimen
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self to an expression for Diesel’s query builder. Read moreSource§impl<T, DB> SelectableHelper<DB> for Twhere
T: Selectable<DB>,
DB: Backend,
impl<T, DB> SelectableHelper<DB> for Twhere
T: Selectable<DB>,
DB: Backend,
Source§fn as_select() -> SelectBy<T, DB>
fn as_select() -> SelectBy<T, DB>
Construct a select clause based on a
Selectable implementation. Read moreSource§fn as_returning() -> SelectBy<Self, DB>
fn as_returning() -> SelectBy<Self, DB>
An alias for
as_select that can be used with returning clausesSource§impl<T, ST, DB> StaticallySizedRow<ST, DB> for T
impl<T, ST, DB> StaticallySizedRow<ST, DB> for T
Source§const FIELD_COUNT: usize = <ST as crate::util::TupleSize>::SIZE
const FIELD_COUNT: usize = <ST as crate::util::TupleSize>::SIZE
The number of fields that this type will consume.