1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use TokenStream;
use parse_macro_input;
/// Generate types definitions, serdes and API client or server side code.
///
/// Arguments:
/// * client = absent or "" - do not generate client code at all; "raw" or "async_worker" - generate client with specified flavor.
/// * server = true/false - whether to generate server code or not.
/// * no_alloc = true/false - whether to use std types or RefVec for strings, vectors. Lifetime will be added automatically if no_alloc = true.
/// * use_async - whether to generate async-aware code.
/// * debug_to_file = "path to an output file" - save generated code to a file for debug purposes.
/// * derive = "A, B, C" - put additional derives on generated types definitions.
/// * method_model = "move_*=deferred, rotate_*=deferred, _=immediate" - list of comma separated regex expressions and deferred or immediate keywords.
/// Deferred methods can answer right away or later with a provided request id.
/// Immediate methods have to answer right away and ideally do not block.
/// Underscore captures all the unmatched methods.
/// * property_model = "_=get_set" - list of comma separated regex expressions and value_on_changed or get_set keywords.
/// Depending on the application, it might be more convenient to store property directly as a context struct member and
/// use value_on_changed, so that generated code directly reads and writes to it. Notification method is called when the value is changed.
/// In other cases, get_set is more useful, allowing to represent GPIO pin as a bool property, for example.
/// Generate types definitions, serdes and trait client or server side code.
///
/// See [ww_api](ww_api) for supported arguments.
/// Define a ww_trait, this macro is only a marker and produces no Rust code. All the work is done inside ww_impl! macro, which
/// loads the appropriate .rs file again through a file system or from crates.io, finds this marker and parses the trait definition.
/// TODO: transform ww_trait into valid Rust trait?
/// TODO: emit unit constant to check for name collisions
///
/// Example:
/// ```ignore
/// use wire_weaver_derive::ww_trait;
///
/// #[ww_trait]
/// pub trait BuildInfo {
/// fn date() -> u32;
/// fn compiler_version() -> String;
/// }
/// ```
/// Create FullVersion with the crate name and major.minor.patch numbers during compile time.