Skip to main content

FaceSyntax

Struct FaceSyntax 

Source
pub struct FaceSyntax {
    pub macro_name: String,
    pub cfg: Option<String>,
    pub location: SyntaxLocation,
    pub end: SyntaxLocation,
    /* private fields */
}
Expand description

Parsed registration declaration, independent of the macro that consumes it. 已解析的注册声明,与消费它的宏实现无关。

Fields§

§macro_name: String

The registration macro’s name exactly as written (control_object, root_object, a generated *_object! alias, …). 注册宏的名字,按源码原文(control_object、root_object、生成的 *_object! 别名等)。

§cfg: Option<String>

The cfg gates the declaration carries, if any, exactly as written. 声明携带的 cfg 门控(若有),按原文保留。

§location: SyntaxLocation

Where the macro invocation starts. 宏调用的起点位置。

§end: SyntaxLocation

Exclusive end of the macro invocation in the source file. 宏调用在源码中的排他结束位置。

Implementations§

Source§

impl FaceSyntax

Source

pub fn field(&self, name: &str) -> Option<String>

One field’s tokens as compact source text, exactly as written. 某个字段的 token 渲染成的紧凑源码文本,按原文输出。

This is the escape hatch for fields the typed readers below do not cover: it answers None only when the field is absent, never because of its shape. 这是下面那些有类型读取器未覆盖字段的出口:只有字段缺失时才返回 None,绝不因形状 而返回。

Source

pub fn cfg(&self) -> Option<&str>

The cfg attribute written on the declaration, if any. 声明上写下的 cfg 属性(若有)。

Source

pub fn field_location(&self, name: &str) -> Option<&SyntaxLocation>

Where one field was written, so a diagnostic can point at it. 某个字段写在哪,供诊断指向它。

Source

pub fn path(&self, name: &str) -> Option<String>

One field as a Rust path; None when it is absent or is not a path. 某个字段作为 Rust 路径;字段缺失或不是路径时为 None。

Source

pub fn string(&self, name: &str) -> Option<String>

One field as a string literal; None when it is absent or is not one. 某个字段作为字符串字面量;字段缺失或不是字面量时为 None。

Source

pub fn boolean(&self, name: &str) -> Option<bool>

One field as a boolean literal; None when it is absent or is not one. 某个字段作为布尔字面量;字段缺失或不是字面量时为 None。

Source

pub fn localized(&self, name: &str, language: &str) -> Option<String>

One localized field’s text in one language, as written (name: { zh: "…", en: "…" }). 某个本地化字段在指定语言下的文本,按原文(name: { zh: "…", en: "…" })。

Source

pub fn string_list(&self, name: &str) -> Option<Vec<String>>

One bracketed list field as strings, in the written order. 某个方括号列表字段的字符串,按书写顺序。

Two names answer a derived value rather than the literal one: handle_traits and part_traits are the searchable labels of the compiler-checked paths in handle_contracts and part_contracts. A face that states a path therefore does not state the label a second time, and every reader of a parsed face — the build-time contract check, the authoring parser, Studio — agrees by construction instead of by convention. A face that states only a label keeps it: that is the unchecked claim it always was. 有两个名字返回的是推导值而不是字面值:handle_traits 与 part_traits 是 handle_contracts 与 part_contracts 里那些参与编译检查的路径的可检索标签。 因此写了路径的注册面不必再写一遍标签,而每个读取已解析注册面的地方——构建期合同 检查、创作解析器、Studio——是构造上一致,而不是靠约定一致。只写标签的注册面则保留 标签:它本来就是一条未经检查的声明。

Source

pub fn path_list(&self, name: &str) -> Option<Vec<String>>

One bracketed list field as Rust paths, in the written order. 某个方括号列表字段的 Rust 路径,按书写顺序。

Source

pub fn requirements(&self, name: &str) -> Option<Vec<(String, String)>>

One list field as capability => provider pairs. 某个列表字段的 capability => provider 对。

Source

pub fn option_string(&self, name: &str) -> Option<Option<String>>

One field as a tri-state string: Some(Some(text)) for Some("text"), Some(None) for None, and None when the field is absent or shaped differently. 某个字段的三态字符串:Some("text") 得 Some(Some(text)),None 得 Some(None),字段缺失或形状不同得 None。

The outer Option separates “not written” from “written as None”, which an edit must not collapse: one means leave the field alone. 外层 Option 把“没写“与“写成 None“分开,编辑时不能合并:前者意味着不要动这个字段。

Source

pub fn parent(&self) -> Option<ParentSyntax>

The declared parent, classified as far as the text allows; None when the field is absent or its expression is not one of the three known shapes. 声明的父级,按文本能分类到的程度给出;字段缺失或表达式不属于三种已知形状时为 None。

Trait Implementations§

Source§

impl Clone for FaceSyntax

Source§

fn clone(&self) -> FaceSyntax

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FaceSyntax

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.