From e1005f715bde3fb260d97a1a08e3e1de358471d6 Mon Sep 17 00:00:00 2001 From: Brett Spradling Date: Sat, 15 May 2021 23:55:19 -0700 Subject: wip --- src/models.rs | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/models.rs') 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, + last_edited_time: DateTime, + has_children: bool, +} #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)] #[serde(tag = "object")] -- cgit v1.2.3