Expand description
The official Cyclone attributes.
cyclone-attributes → your source → cyclonec → generated codeThis crate defines network and codec, and does nothing with them. It
is the syntax half of Cyclone: the part that makes annotated Rust compile,
so that cyclonec has something to read.
use cyclone_attributes::*;
#[network]
#[codec]
struct DeviceState {
#[network(u32)]
#[codec(edge, unity)]
id: u32,
#[network(f32)]
#[codec(edge)]
temperature: f32,
#[network(string)]
#[codec(unity)]
display_name: String,
}§What it does
The attributes are inert markers. Applied to an item, they remove themselves and every Cyclone attribute inside it, and hand back the item otherwise untouched — same fields, same types, same derives, same doc comments, same spans.
That removal is the entire implementation, and it exists for one narrow
reason: Rust does not allow an attribute macro on a field, so
#[network(u32)] cannot compile on its own. An attribute on the struct is
what makes the ones on its fields legal, by consuming them.
So the annotated struct above compiles to exactly:
struct DeviceState {
id: u32,
temperature: f32,
display_name: String,
}§What it does not do
Everything else. There is no Reader, no Writer, no Encode, no
Decode, no registry, no reflection, no dynamic dispatch, and no generated
code of any kind. It reads no Cyclone type, validates no annotation, and
knows no codec name.
cyclonec reads the annotations out of your source, not out of this
crate’s expansion, and every semantic question belongs to it:
- Whether
u32names a Cyclone type. - Whether a field declared
u64may carry#[network(u32)]. - What
edgeorunitymean, and which fields each one covers.
On the last of those especially: a codec name is an identifier you
invent. This crate has no list of them, no default, and no opinion — edge,
unity, server, orange_pi are all the same to it, which is to say
nothing at all.
§Scope
This crate is not a serialization runtime and not a networking library. It is two attributes and the code that takes them back off.