pub struct Meta {Show 19 fields
pub doc: DocumentMut,
pub str_version: Option<i64>,
pub spec: Option<String>,
pub kind_raw: Option<String>,
pub kind: Option<Kind>,
pub id: Option<String>,
pub name: Option<String>,
pub type: Option<String>,
pub title: Option<String>,
pub summary: Option<String>,
pub tags: Vec<String>,
pub revision: Option<i64>,
pub created_at: Option<String>,
pub updated_at: Option<String>,
pub schema: Option<String>,
pub policies: Policies,
pub authors: Vec<Author>,
pub refs: Vec<RefItem>,
pub entries: Vec<Entry>,
}Expand description
一份 ._meta 的完整内容:保序文档 + 类型化视图。
Fields§
§doc: DocumentMut保注释、保顺序的 TOML 文档(写回用)。
str_version: Option<i64>str 主版本。
spec: Option<String>规范版本。
kind_raw: Option<String>档位。
kind: Option<Kind>解析出的档位。
id: Option<String>自身 id。
name: Option<String>bundle 短名(root)。
type: Option<String>类型。
title: Option<String>标题。
summary: Option<String>摘要。
标签。
revision: Option<i64>修订号。
created_at: Option<String>创建时间。
updated_at: Option<String>更新时间。
schema: Option<String>payload schema 引用。
policies: Policies策略。
贡献者。
refs: Vec<RefItem>跨枝关联。
entries: Vec<Entry>内容清单。
Implementations§
Source§impl Meta
impl Meta
Sourcepub fn to_json(&self) -> JValue
pub fn to_json(&self) -> JValue
归一化为规范 JSON:顶层裸键与各表按 4.9 的键序/表序输出, 未知键原样保留,使其可被 JSON Schema 校验器与 AI 稳定消费。
Sourcepub fn sort_collections(&mut self)
pub fn sort_collections(&mut self)
按 (order, path|id) 重排 entries / refs,并重设文档位置使新顺序真正落盘。
Sourcepub fn canonicalize(&mut self)
pub fn canonicalize(&mut self)
规范 §4.9 全量规范化(顶层键序 + 表序 + 表内键序 + 集合排序)。
Sourcepub fn revision_issues(&self, rel: &str) -> Vec<Issue>
pub fn revision_issues(&self, rel: &str) -> Vec<Issue>
校验序号等基础合法性(E_REVISION_STALE 的可判定部分)。
Source§impl Meta
impl Meta
Sourcepub fn touch(&mut self)
pub fn touch(&mut self)
revision + 1 并刷新 updated_at。
updated_at 一律写成 TOML 原生 offset date-time(规范 4.1),不得是字符串。
Sourcepub fn set_str_or_remove(&mut self, key: &str, v: &str)
pub fn set_str_or_remove(&mut self, key: &str, v: &str)
设置顶层字符串字段;v 为空串则移除该字段。
Sourcepub fn set_str_array(&mut self, key: &str, values: &[String])
pub fn set_str_array(&mut self, key: &str, values: &[String])
设置顶层字符串数组字段(如 tags)。
按 id 插入或替换一条 [[authors]],返回 true 表示新增。
按 id 删除 [[authors]]。
Sourcepub fn set_entry_str(&mut self, path: &str, key: &str, v: &str) -> bool
pub fn set_entry_str(&mut self, path: &str, key: &str, v: &str) -> bool
在指定分支的 entries[path] 上设置字符串字段(保注释,键序由规范化收口)。
key 限 ENTRY_KEYS 中的字符串字段;v 为空串则移除该键。
返回 false 表示该分支没有 path 对应的条目。
Sourcepub fn set_entry_int(&mut self, path: &str, key: &str, v: Option<i64>) -> bool
pub fn set_entry_int(&mut self, path: &str, key: &str, v: Option<i64>) -> bool
在 entries[path] 上设置整数字段(如 order)。None 表示移除。
Sourcepub fn upsert_entry(&mut self, e: &Entry) -> bool
pub fn upsert_entry(&mut self, e: &Entry) -> bool
插入或替换一条 [[entries]],返回 true 表示新增。
Sourcepub fn remove_entry_path(&mut self, path: &str) -> bool
pub fn remove_entry_path(&mut self, path: &str) -> bool
删除指定 path 的 [[entries]] 元素。
Sourcepub fn remove_ref(&mut self, id: &str) -> bool
pub fn remove_ref(&mut self, id: &str) -> bool
按 id 删除 [[refs]]。
Sourcepub fn canonical_text(&self, strip_comments: bool) -> String
pub fn canonical_text(&self, strip_comments: bool) -> String
规范 §4.9 归一化后的 TOML 文本(键序 / 表序固定,注释保留)。
属性是只读的派生视图:这里在副本上做规范化,不改动 self.doc。