pub struct Library {
pub folders: HashMap<String, Folder>,
pub notes: HashMap<String, Note>,
pub resources: HashMap<String, Resource>,
pub tags: HashMap<String, Tag>,
pub note_tags: Vec<NoteTag>,
/* private fields */
}Fields§
§folders: HashMap<String, Folder>§notes: HashMap<String, Note>§resources: HashMap<String, Resource>Implementations§
Source§impl Library
impl Library
Sourcepub fn from_contents(contents: Vec<String>) -> (Library, BuildStats)
pub fn from_contents(contents: Vec<String>) -> (Library, BuildStats)
把一批原始 .md 内容解析、分类、建索引为 Library,返回类型计数 + 解析错误数。 拉取(并行/缓存)由调用方负责;这里只做纯解析与索引,便于编译到 WASM。
Sourcepub fn note_count(&self, folder_id: &str) -> usize
pub fn note_count(&self, folder_id: &str) -> usize
某笔记本(含根 “”)直属笔记数。
Sourcepub fn child_folder_ids_sorted(&self, parent_id: &str) -> Vec<String>
pub fn child_folder_ids_sorted(&self, parent_id: &str) -> Vec<String>
子笔记本,按标题排序。
Sourcepub fn notes_in_folder_sorted(&self, folder_id: &str) -> Vec<&Note>
pub fn notes_in_folder_sorted(&self, folder_id: &str) -> Vec<&Note>
某笔记本下的笔记,按更新时间倒序。
pub fn note(&self, id: &str) -> Option<&Note>
pub fn resource(&self, id: &str) -> Option<&Resource>
Sourcepub fn upsert_note(&mut self, content: &str) -> Result<String>
pub fn upsert_note(&mut self, content: &str) -> Result<String>
新增或更新一篇笔记(写回成功后同步内存)。返回笔记 id。
Sourcepub fn upsert_folder(&mut self, content: &str) -> Result<String>
pub fn upsert_folder(&mut self, content: &str) -> Result<String>
新增或更新一个笔记本(写回成功后同步内存)。返回笔记本 id。
Sourcepub fn is_self_or_descendant(&self, root: &str, candidate: &str) -> bool
pub fn is_self_or_descendant(&self, root: &str, candidate: &str) -> bool
candidate 是否就是 root 本身、或位于 root 子树之下。
用于移动笔记本时防止把笔记本移进它自己或其后代(成环)。
Sourcepub fn upsert_resource(&mut self, content: &str) -> Result<String>
pub fn upsert_resource(&mut self, content: &str) -> Result<String>
新增或更新一个资源(上传成功后同步内存,使 /api/resources 能拿到 mime)。返回资源 id。
Sourcepub fn remove_note(&mut self, id: &str)
pub fn remove_note(&mut self, id: &str)
删除一篇笔记(写回成功后同步内存)。
Sourcepub fn remove_resource(&mut self, id: &str)
pub fn remove_resource(&mut self, id: &str)
删除一个资源(写回成功后同步内存)。
Sourcepub fn resource_usage(&self) -> HashMap<String, usize>
pub fn resource_usage(&self) -> HashMap<String, usize>
每个资源被多少篇笔记引用(扫描所有笔记正文里的 :/<id>)。
未出现在结果中的资源即为无人引用的“孤儿”。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Library
impl RefUnwindSafe for Library
impl Send for Library
impl Sync for Library
impl Unpin for Library
impl UnsafeUnpin for Library
impl UnwindSafe for Library
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more