macro_rules! derive_deftly_template_ItemValueParseable {
({ $($driver:tt)* } [$($aoptions:tt)*] ($($future:tt)*) $($tpassthrough:tt)*) => { ... };
($($wrong:tt)*) => { ... };
}
parse2
only.Expand description
Derive ItemValueParseable
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:
impl
ItemArgumentParseable
(one argument),Option<impl ItemArgumentParseable>
(one optional argument), orVec<impl ItemArgumentParseable>
(zero or more arguments).
ItemArgumentParseable
is implemented for every impl FromStr
,
so impl FromStr
, Option<impl FromStr>
and Vec<impl FromStr>
are supported.
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.
§Field-level attributes:
-
`#[deftly(netdoc(object))]:
The field is the Object. It must implement
ItemObjectParseable
(so it can be beOption<impl ItemObjectParseable>
for an optional item.)Only allowed once. If omittted, any object is rejected.
-
`#[deftly(netdoc(sig_hash = “HASH_METHOD”))]:
This item is a signature item.
SignatureItemParseable
will be implemented instead ofItemValueParseable
.This field is a document hash. The hash will be computed using
HASH_METHOD
, which will be resolved withsig_hash_methods::*
in scope.fn HASH_METHOD(body: &SignatureHashInputs) -> HASH_FIELD_VALUE
.
This is a derive_deftly
template. Do not invoke it directly.
To use it, write: #[derive(Deftly)] #[derive_deftly(ItemValueParseable)]
.