diff options
author | 2021-09-22 14:13:05 -0700 | |
---|---|---|
committer | 2021-09-22 14:13:05 -0700 | |
commit | f34ba4d79682665603d5ce3192b5422aab3f6800 (patch) | |
tree | d2bded634af25a2bfe7e5ab817b14a5759e0f5ef /src/models.rs | |
parent | 50faf778671358d70fa967735a062b4a6b6dfe64 (diff) | |
download | notion-f34ba4d79682665603d5ce3192b5422aab3f6800.tar.gz notion-f34ba4d79682665603d5ce3192b5422aab3f6800.tar.zst notion-f34ba4d79682665603d5ce3192b5422aab3f6800.zip |
feat: Paging improvements and ergonomics
Diffstat (limited to 'src/models.rs')
-rw-r--r-- | src/models.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/models.rs b/src/models.rs index aead105..0007cfb 100644 --- a/src/models.rs +++ b/src/models.rs @@ -167,6 +167,17 @@ pub struct Properties { pub properties: HashMap<String, PropertyValue>, } +impl Properties { + pub fn title(&self) -> Option<String> { + self.properties.values().find_map(|p| match p { + PropertyValue::Title { title, .. } => { + Some(title.into_iter().map(|t| t.plain_text()).collect()) + } + _ => None, + }) + } +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] pub struct Page { pub id: PageId, @@ -180,6 +191,12 @@ pub struct Page { pub parent: Parent, } +impl Page { + pub fn title(&self) -> Option<String> { + self.properties.title() + } +} + #[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)] pub struct BlockCommon { pub id: BlockId, |