1use crate::{ColumnDef, Entity, TableRef};
2use rust_decimal::Decimal;
3use std::{hash::Hash, marker::PhantomData};
4
5#[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
9pub struct FixedDecimal<const WIDTH: u8, const SCALE: u8>(pub Decimal);
10
11impl<const W: u8, const S: u8> From<Decimal> for FixedDecimal<W, S> {
12 fn from(value: Decimal) -> Self {
13 Self(value)
14 }
15}
16
17impl<const W: u8, const S: u8> From<FixedDecimal<W, S>> for Decimal {
18 fn from(value: FixedDecimal<W, S>) -> Self {
19 value.0
20 }
21}
22
23pub struct References<T: Entity> {
25 entity: PhantomData<T>,
26 columns: Box<[ColumnDef]>,
27}
28
29impl<T: Entity> References<T> {
30 pub fn new(columns: Box<[ColumnDef]>) -> Self {
31 Self {
32 columns,
33 entity: Default::default(),
34 }
35 }
36 pub fn table_ref(&self) -> TableRef {
37 T::table().clone()
38 }
39 pub fn columns(&self) -> &[ColumnDef] {
40 &self.columns
41 }
42}