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: StringThe 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: SyntaxLocationWhere the macro invocation starts. 宏调用的起点位置。
end: SyntaxLocationExclusive end of the macro invocation in the source file. 宏调用在源码中的排他结束位置。
Implementations§
Source§impl FaceSyntax
impl FaceSyntax
Sourcepub fn field(&self, name: &str) -> Option<String>
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,绝不因形状
而返回。
Sourcepub fn cfg(&self) -> Option<&str>
pub fn cfg(&self) -> Option<&str>
The cfg attribute written on the declaration, if any.
声明上写下的 cfg 属性(若有)。
Sourcepub fn field_location(&self, name: &str) -> Option<&SyntaxLocation>
pub fn field_location(&self, name: &str) -> Option<&SyntaxLocation>
Where one field was written, so a diagnostic can point at it. 某个字段写在哪,供诊断指向它。
Sourcepub fn path(&self, name: &str) -> Option<String>
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。
Sourcepub fn string(&self, name: &str) -> Option<String>
pub fn string(&self, name: &str) -> Option<String>
One field as a string literal; None when it is absent or is not one.
某个字段作为字符串字面量;字段缺失或不是字面量时为 None。
Sourcepub fn boolean(&self, name: &str) -> Option<bool>
pub fn boolean(&self, name: &str) -> Option<bool>
One field as a boolean literal; None when it is absent or is not one.
某个字段作为布尔字面量;字段缺失或不是字面量时为 None。
Sourcepub fn localized(&self, name: &str, language: &str) -> Option<String>
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: "…" })。
Sourcepub fn string_list(&self, name: &str) -> Option<Vec<String>>
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——是构造上一致,而不是靠约定一致。只写标签的注册面则保留
标签:它本来就是一条未经检查的声明。
Sourcepub fn path_list(&self, name: &str) -> Option<Vec<String>>
pub fn path_list(&self, name: &str) -> Option<Vec<String>>
One bracketed list field as Rust paths, in the written order. 某个方括号列表字段的 Rust 路径,按书写顺序。
Sourcepub fn requirements(&self, name: &str) -> Option<Vec<(String, String)>>
pub fn requirements(&self, name: &str) -> Option<Vec<(String, String)>>
One list field as capability => provider pairs.
某个列表字段的 capability => provider 对。
Sourcepub fn option_string(&self, name: &str) -> Option<Option<String>>
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“分开,编辑时不能合并:前者意味着不要动这个字段。
Sourcepub fn parent(&self) -> Option<ParentSyntax>
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
impl Clone for FaceSyntax
Source§fn clone(&self) -> FaceSyntax
fn clone(&self) -> FaceSyntax
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more