Skip to main content

Module value

Module value 

Source
Expand description

Turning a value’s bytes into a Rust type.

A field’s type says how its value is read, through FromArg:

TypeReads
String, char, bool, integers, floats, std::net addressesUTF-8 text, parsed with str::parse
PathBuf, OsStringthe bytes as they are on Unix, UTF-8 elsewhere
Vec<u8>the bytes as they are
an enum deriving ValueEnumone of its variants’ names
Parsed<T>any T: FromStr, a type from another crate included
CInt<T>an integer in C syntax: 0x400000, 010000
KeyValue<K, V>key=value, split at the first =

Any other type implements FromArg itself. In an Occurrence variant, Spanned<T> is a T with where it was found.

Structs§

CInt
An integer in C syntax, as linkers and assemblers read one: 0x/0X hex, a leading 0 for octal, otherwise decimal, with a sign for signed types. --image-base=0x400000, -z max-page-size=0x1000, -Ttext=010000.
CIntError
The error of a malformed CInt.
ChoiceError
The cause of an ErrorKind::InvalidChoice: the value is not one of choices.
KeyValue
key=value, split at the first =: --defsym=sym=expr, -z max-page-size=4096, --section-start=.text=0x1000. The value may hold more =.
MissingEquals
The error of a KeyValue with no =.
Parsed
Any FromStr type as a value: the text is parsed with str::parse, and its error becomes the invalid value’s cause.
Spanned
A value with where it was found: an Occurrence variant holding a Spanned<T> gets the flag’s (or word’s) offset and whether the value was attached (-zfoo, --name=value) or the next word (-z foo).

Traits§

FromArg
A type a flag’s value can be converted into.

Functions§

to_str
The value as &str.