Skip to main content

Meta

Struct Meta 

Source
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>

摘要。

§tags: Vec<String>

标签。

§revision: Option<i64>

修订号。

§created_at: Option<String>

创建时间。

§updated_at: Option<String>

更新时间。

§schema: Option<String>

payload schema 引用。

§policies: Policies

策略。

§authors: Vec<Author>

贡献者。

§refs: Vec<RefItem>

跨枝关联。

§entries: Vec<Entry>

内容清单。

Implementations§

Source§

impl Meta

Source

pub fn to_json(&self) -> JValue

归一化为规范 JSON:顶层裸键与各表按 4.9 的键序/表序输出, 未知键原样保留,使其可被 JSON Schema 校验器与 AI 稳定消费。

Source

pub fn sort_collections(&mut self)

(order, path|id) 重排 entries / refs,并重设文档位置使新顺序真正落盘。

Source

pub fn canonicalize(&mut self)

规范 §4.9 全量规范化(顶层键序 + 表序 + 表内键序 + 集合排序)。

Source

pub fn revision_issues(&self, rel: &str) -> Vec<Issue>

校验序号等基础合法性(E_REVISION_STALE 的可判定部分)。

Source§

impl Meta

Source

pub fn resync(&mut self)

写操作后重新同步类型化视图(doc 为准)。

Source

pub fn touch(&mut self)

revision + 1 并刷新 updated_at

updated_at 一律写成 TOML 原生 offset date-time(规范 4.1),不得是字符串。

Source

pub fn set_str(&mut self, key: &str, v: &str)

设置顶层字符串字段(保注释)。

Source

pub fn set_str_or_remove(&mut self, key: &str, v: &str)

设置顶层字符串字段;v 为空串则移除该字段。

Source

pub fn set_str_array(&mut self, key: &str, values: &[String])

设置顶层字符串数组字段(如 tags)。

Source

pub fn upsert_author(&mut self, a: &Author) -> bool

id 插入或替换一条 [[authors]],返回 true 表示新增。

Source

pub fn remove_author(&mut self, id: &str) -> bool

id 删除 [[authors]]

Source

pub fn set_entry_str(&mut self, path: &str, key: &str, v: &str) -> bool

指定分支entries[path] 上设置字符串字段(保注释,键序由规范化收口)。

keyENTRY_KEYS 中的字符串字段;v 为空串则移除该键。 返回 false 表示该分支没有 path 对应的条目。

Source

pub fn set_entry_int(&mut self, path: &str, key: &str, v: Option<i64>) -> bool

entries[path] 上设置整数字段(如 order)。None 表示移除。

Source

pub fn upsert_entry(&mut self, e: &Entry) -> bool

插入或替换一条 [[entries]],返回 true 表示新增。

Source

pub fn remove_entry_path(&mut self, path: &str) -> bool

删除指定 path[[entries]] 元素。

Source

pub fn push_ref(&mut self, r: &RefItem)

追加一条 [[refs]]

Source

pub fn remove_ref(&mut self, id: &str) -> bool

按 id 删除 [[refs]]

Source

pub fn canonical_text(&self, strip_comments: bool) -> String

规范 §4.9 归一化后的 TOML 文本(键序 / 表序固定,注释保留)。

属性是只读的派生视图:这里在副本上做规范化,不改动 self.doc

Source

pub fn save(&self, path: &Path) -> Result<()>

保注释写回磁盘(写出的字节一律是 §4.9 规范形式)。

Trait Implementations§

Source§

impl Debug for Meta

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Meta

§

impl RefUnwindSafe for Meta

§

impl Send for Meta

§

impl Sync for Meta

§

impl Unpin for Meta

§

impl UnsafeUnpin for Meta

§

impl UnwindSafe for Meta

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more