1mod entity;
2mod entity_id;
3mod entity_schema;
4mod field;
5mod field_schema;
6mod request;
7mod snowflake;
8mod store;
9mod value;
10mod constants;
11
12use std::fmt;
13
14pub use entity::Entity;
15pub use entity_id::EntityId;
16pub use entity_schema::{EntitySchema, Single, Complete};
17pub use field::Field;
18pub use field_schema::FieldSchema;
19pub use request::{AdjustBehavior, PushCondition, Request};
20use serde::{Deserialize, Serialize};
21pub use snowflake::Snowflake;
22pub use store::{
23 resolve_indirection, BadIndirection, BadIndirectionReason, Context, Store, PageOpts,
24 PageResult,
25};
26pub use value::Value;
27pub use constants::{INDIRECTION_DELIMITER};
28
29#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
30pub struct EntityType(pub String);
31impl From<String> for EntityType {
32 fn from(s: String) -> Self {
33 EntityType(s)
34 }
35}
36
37impl From<&str> for EntityType {
38 fn from(s: &str) -> Self {
39 EntityType(s.to_string())
40 }
41}
42
43impl fmt::Display for EntityType {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 write!(f, "{}", self.0)
46 }
47}
48
49#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
50pub struct FieldType(pub String);
51
52impl From<String> for FieldType {
53 fn from(s: String) -> Self {
54 FieldType(s)
55 }
56}
57
58impl From<&str> for FieldType {
59 fn from(s: &str) -> Self {
60 FieldType(s.to_string())
61 }
62}
63
64impl AsRef<str> for FieldType {
65 fn as_ref(&self) -> &str {
66 &self.0
67 }
68}
69
70impl fmt::Display for FieldType {
71 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
72 write!(f, "{}", self.0)
73 }
74}
75
76impl FieldType {
77 pub fn indirect_fields(&self) -> Vec<Self> {
78 return self.0.split(INDIRECTION_DELIMITER)
79 .map(|s| s.into())
80 .collect::<Vec<Self>>();
81 }
82}
83
84pub type Timestamp = std::time::SystemTime;
85
86pub fn now() -> Timestamp {
87 std::time::SystemTime::now()
88}
89
90pub fn epoch() -> Timestamp {
91 std::time::UNIX_EPOCH
92}