Skip to main content

easyofd_core/model/
bookmarks.rs

1//! OFD 书签集合。
2//!
3//! 对应 Java: org.ofdrw.core.basicStructure.outline.CT_Outline
4
5use crate::model::bookmark::Bookmark;
6
7/// 书签集合(ofd:Bookmarks / ofd:Outline)。
8///
9/// 对应 Java: ofdrw CT_Outline。
10#[derive(Debug, Clone, PartialEq)]
11pub struct Bookmarks {
12    /// 书签列表。
13    pub items: Vec<Bookmark>,
14}
15
16impl Bookmarks {
17    /// 创建空书签集合。
18    pub fn new() -> Self {
19        Self { items: Vec::new() }
20    }
21
22    /// 添加书签。
23    pub fn push(&mut self, bookmark: Bookmark) {
24        self.items.push(bookmark);
25    }
26
27    /// 书签数量。
28    #[must_use]
29    pub fn len(&self) -> usize {
30        self.items.len()
31    }
32
33    /// 是否为空。
34    #[must_use]
35    pub fn is_empty(&self) -> bool {
36        self.items.is_empty()
37    }
38}
39
40impl Default for Bookmarks {
41    fn default() -> Self {
42        Self::new()
43    }
44}