pub enum Ty {
}Expand description
A declared type, as a generated registry holds it.
Containers borrow so the whole thing is const-constructible:
Ty::List(&Ty::String).
Variants§
Bool
Int
Uint
An integer that may not be negative.
Float
String
Path
A filesystem path. Read as a string here; what makes it a path is what the CLI does with it, and refusing one because it does not exist yet would be wrong.
Url
Duration
A span of time, as text — "30s", "1h". Not parsed here: the crate that owns the
duration type owns its spelling, and the generated struct is where it is turned into
one.
Object
A table whose keys the spec does not describe.
List(&'static Ty)
Set(&'static Ty)
Like a list, but duplicates are dropped on merge.
Map(&'static Ty)
A table with values of one type.
Option(&'static Ty)
Absent is a legitimate state. Only meaningful about the setting as a whole, so coercion looks straight through it.
Any
A union, or a type only the tool understands. Nothing is coerced and nothing is refused: the spec said usage cannot know what belongs here, so it takes what it is given.
Implementations§
Source§impl Ty
impl Ty
Sourcepub fn name(self) -> String
pub fn name(self) -> String
This type as the spec spells it: uint, list<string>, option<path>.
Distinct from Ty::describe, which is prose for an error message. An explanation shows
the author’s own vocabulary, because that is what a reader will search the docs for —
“type a non-negative integer” sends them looking for something no spec says.
Sourcepub fn coerce(self, value: Value) -> Result<Value, TypeError>
pub fn coerce(self, value: Value) -> Result<Value, TypeError>
value read as this type.
Text arriving from a layer that has no types of its own is converted; a value that already has the right shape passes through untouched. Anything else is an error rather than a silent reinterpretation — the whole point of declaring the type.