fts_core/
models.rs

1mod auction;
2mod auth;
3mod bound;
4mod cost;
5mod datetime;
6mod outcome;
7mod product;
8mod submission;
9
10pub use auction::{AuctionMetaData, AuctionSolveRequest, RawAuctionInput};
11pub use auth::{AuthData, AuthHistoryRecord, AuthId, AuthRecord, Portfolio};
12pub use bound::Bound;
13pub use cost::{
14    Constant, CostData, CostHistoryRecord, CostId, CostRecord, Curve, Group, GroupDisplay, Point,
15};
16pub use datetime::{DateTimeRangeQuery, DateTimeRangeResponse};
17pub use outcome::{AuctionOutcome, Outcome};
18pub use product::{ProductQueryResponse, ProductRecord};
19pub use submission::SubmissionRecord;
20
21macro_rules! uuid_wrapper {
22    ($struct: ident) => {
23        /// A UUID newtype
24        #[derive(
25            Debug,
26            Hash,
27            PartialEq,
28            Eq,
29            Clone,
30            Copy,
31            serde::Serialize,
32            serde::Deserialize,
33            PartialOrd,
34            Ord,
35            utoipa::ToSchema,
36        )]
37        #[serde(transparent)]
38        #[repr(transparent)]
39        pub struct $struct(uuid::Uuid);
40
41        impl From<uuid::Uuid> for $struct {
42            fn from(value: uuid::Uuid) -> Self {
43                Self(value)
44            }
45        }
46
47        impl Into<uuid::Uuid> for $struct {
48            fn into(self) -> uuid::Uuid {
49                self.0
50            }
51        }
52
53        impl TryFrom<&str> for $struct {
54            type Error = <uuid::Uuid as std::str::FromStr>::Err;
55
56            fn try_from(value: &str) -> Result<Self, Self::Error> {
57                Ok(Self(<uuid::Uuid as std::str::FromStr>::from_str(value)?))
58            }
59        }
60
61        impl Into<String> for $struct {
62            fn into(self) -> String {
63                self.0.to_string()
64            }
65        }
66
67        impl std::ops::Deref for $struct {
68            type Target = uuid::Uuid;
69
70            fn deref(&self) -> &Self::Target {
71                &self.0
72            }
73        }
74
75        impl std::fmt::Display for $struct {
76            fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
77                self.0.fmt(f)
78            }
79        }
80    };
81}
82
83pub(crate) use uuid_wrapper;
84uuid_wrapper!(BidderId);
85uuid_wrapper!(ProductId);