pub struct Record {Show 20 fields
pub key: String,
pub ty: String,
pub default: Option<Value>,
pub allowed: Vec<String>,
pub separators: Vec<String>,
pub required: bool,
pub stability: String,
pub since: Option<String>,
pub deprecation: Option<Value>,
pub group: Option<String>,
pub maps_to: Option<String>,
pub example: Option<String>,
pub observe: Option<String>,
pub reviewed: Option<String>,
pub summary: Option<String>,
pub modified: Option<String>,
pub source: Option<String>,
pub env: Option<EnvBinding>,
pub arg: Option<ArgBinding>,
pub subcommands: Vec<String>,
}Expand description
One input, flattened to plain JSON-friendly types.
This is the shape every language binding implements and the JSON Schema describes. Rich types collapse to strings here on purpose: the contract must be expressible in C, Python, and JSON, none of which have const-validated newtypes.
Unknown fields are ignored rather than rejected on read: the format grows by adding optional fields, so a consumer pinned to this version must keep reading documents produced by a later one. Authoring mistakes are caught by the command-line checker, which reports unrecognised fields explicitly.
Fields§
§key: StringTransport-free identity, snake_case. The join key across every source.
ty: StringWire kind: one of crate::Type::ALL.
default: Option<Value>The declared default, in its natural JSON form.
allowed: Vec<String>Accepted tokens for the enum and list kinds.
separators: Vec<String>Characters that separate items in a list value.
required: boolWhether the program requires this input.
stability: StringOne of crate::Stability::ALL.
since: Option<String>Introducing version, major.minor.patch.
deprecation: Option<Value>{ since, replaced_by, migration }, present only when deprecated.
group: Option<String>Grouping tag for documentation and help output.
maps_to: Option<String>A key in another configuration surface this input bridges to.
example: Option<String>A copy-pasteable example.
observe: Option<String>A resolved-configuration field this input visibly changes.
reviewed: Option<String>Date a human last verified the entry, YYYY-MM-DD.
summary: Option<String>Prose description.
modified: Option<String>Date the declaration was last edited. Stamped by tooling from version control, never hand-written.
source: Option<String>Which project and revision this record came from; populated when records from several documents are merged.
env: Option<EnvBinding>The environment binding, if this input accepts one.
arg: Option<ArgBinding>The argument-vector binding, if this input accepts one.
subcommands: Vec<String>Restricts this input to one or more subcommands, by their token —
see crate::Input::subcommands. Empty means always active.
Implementations§
Source§impl Record
impl Record
Sourcepub fn env_names(&self) -> Vec<&str>
pub fn env_names(&self) -> Vec<&str>
Every environment name this input answers to.
Examples found in repository?
99pub fn usage() -> String {
100 let mut text = String::from("usage: minigrep [OPTIONS] <QUERY> <FILE>\n\n");
101 for record in Contract::records() {
102 text.push_str(&format!(
103 " {:<20} {}\n",
104 record.usage(),
105 record.summary.as_deref().unwrap_or("")
106 ));
107 if !record.env_names().is_empty() {
108 text.push_str(&format!(
109 " {:<20} (or set {})\n",
110 "",
111 record.env_names().join(", ")
112 ));
113 }
114 }
115 text
116}Sourcepub fn arg_labels(&self) -> Vec<String>
pub fn arg_labels(&self) -> Vec<String>
Every argument spelling this input answers to, dashes included.
Sourcepub fn usage(&self) -> String
pub fn usage(&self) -> String
The signature as it would appear in help output, e.g.
-l, --log-level <LEVEL>. Empty when the input has no argument form.
Examples found in repository?
99pub fn usage() -> String {
100 let mut text = String::from("usage: minigrep [OPTIONS] <QUERY> <FILE>\n\n");
101 for record in Contract::records() {
102 text.push_str(&format!(
103 " {:<20} {}\n",
104 record.usage(),
105 record.summary.as_deref().unwrap_or("")
106 ));
107 if !record.env_names().is_empty() {
108 text.push_str(&format!(
109 " {:<20} (or set {})\n",
110 "",
111 record.env_names().join(", ")
112 ));
113 }
114 }
115 text
116}