macro_rules! derive_deftly_template_ItemValueParseable {
({ $($driver:tt)* } [$($aoptions:tt)*] ($($future:tt)*) $($tpassthrough:tt)*) => { ... };
($($wrong:tt)*) => { ... };
}Expand description
Derive ItemValueParseable (or SignatureItemParseable)
Fields in the struct are parsed from the keyword line arguments, in the order they appear in the struct.
§Field type
Each field should be:
implItemArgumentParseable(one argument),Option<impl ItemArgumentParseable>(one optional argument),Vec<impl ItemArgumentParseable>(zero or more arguments), orBTreeSet<impl ItemArgumentParseable + Ord>(zero or more arguments).
ItemArgumentParseable can be implemented via impl FromStr,
by writing impl NormalItemArgument.
For Option or Vec, we expect that if there are any further arguments,
they are for this field.
So absence of any optional argument means absence of following arguments,
and no arguments can follow a Vec.
Some Tor netdocs have optional arguments followed by other data,
with unclear/ambiguous parsing rules.
These cases typically require manual implementation of ItemValueParseable.
(Multiplicity is implemented via types in the multiplicity module,
specifically [ArgumentSetSelector] and ArgumentSetMethods.)
§Top-level attributes:
-
`#[deftly(netdoc(no_extra_args))]:
Reject, rather than ignore, additional arguments found in the document which aren’t described by the struct.
-
`#[deftly(netdoc(signature(hash_accu = HASH_ACCU))]:
This item is a signature item.
SignatureItemParseablewill be implemented instead ofItemValueParseable.HASH_ACCUis the type in which the hash(es) for this item will be accumulated, and must implementSignatureHashesAccumulator. It is used asSignatureItemParseable::HashAccu. -
#[deftly(netdoc(debug))]:Currently implemented only as a placeholder
The generated implementation may in future generate copious debug output to the program’s stderr when it is run. Do not enable in production!
-
#[deftly(netdoc(debug))]:Currently implemented only as a placeholder
The generated implementation may in future generate copious debug output to the program’s stderr when it is run. Do not enable in production!
§Field-level attributes:
-
`#[deftly(netdoc(rest))]:
The field is the whole rest of the line. Must come after any other normal argument fields. Only allowed once.
The field type must implement
FromStr. (I.e.Vec,Optionetc., are not allowed, andItemArgumentParseableis not used.) -
`#[deftly(netdoc(object))]:
The field is the Object. It must implement
ItemObjectParseable(or beOption<impl ItemObjectParseable>).Only allowed once. If omittted, any object is rejected.
-
`#[deftly(netdoc(object(label = “LABEL”)))]:
Sets the expected label for an Object. If not supplied, uses
ItemObjectParseable::check_label. -
`#[deftly(netdoc(with = MODULE)]:
Instead of
ItemArgumentParseable, the argument is parsed withMODULE::from_args, which must have the same signature asItemArgumentParseable::from_args.With
#[deftly(netdoc(rest))], the argument is parsed withMODULE::from_args_rest, must have the signaturefn from_args_rest(s: &str) -> Result<FIELD, _>). and replaces<FIELD as FromStr>::from_str.With
#[deftly(netdoc(object))], usesMODULE::try_fromwhich must have the signaturefn(Vec<u8>) -> Result<OBJECT, _>; likeTryFrom::<Vec>>::try_from . LABEL must also be specified unless the object also implementsItemObjectParseable. Errors from parsing will all be collapsed into [ErrorProblem::ObjectInvalidData`]. -
`#[deftly(netdoc(skip))]:
Do not parse this field; fill it in with
Default::default()instead.
This is a derive_deftly template. Do not invoke it directly.
To use it, write: #[derive(Deftly)] #[derive_deftly(ItemValueParseable)].