diff options
Diffstat (limited to 'src/models.rs')
-rw-r--r-- | src/models.rs | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/models.rs b/src/models.rs index f0909d9..ba98094 100644 --- a/src/models.rs +++ b/src/models.rs @@ -135,8 +135,45 @@ pub struct Page { parent: Parent, } +impl Identifiable for String { + type Type = String; + + fn id(&self) -> &Self::Type { + self + } +} + +#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Hash, Clone)] +#[serde(transparent)] +pub struct BlockId(String); + +impl BlockId { + pub fn id(&self) -> &str { + &self.0 + } +} + +impl Identifiable for BlockId { + type Type = BlockId; + + fn id(&self) -> &Self::Type { + self + } +} + +impl Display for BlockId { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] -pub struct Block {} +pub struct Block { + id: BlockId, + created_time: DateTime<Utc>, + last_edited_time: DateTime<Utc>, + has_children: bool, +} #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] #[serde(tag = "object")] |