Macro anchor::klipper_config_generate
klipper_config_generate!() { /* proc-macro */ }
Expand description
Generate compile-time configuration
This macro generates the protocol dictionary, message handlers, encoders, and dispatcher
needed. The actual code is generated by the anchor_codegen
build script, and the macro
ensures that the generated code is included correctly.
This must be called exactly once at the root of your crate, typically in main.rs
.
The syntax is as follows:
klipper_config_generate!(options);
The following options are supported:
-
transport = path: type
This is theTransportOutput
that will be used when sending messages to the remote end. The user crate must provide this, and it must be a globalconst
. Anyklipper_reply!
calls will call theoutput
method. Both a path and type must be provided, both must be fully expanded. E.g.:
transport = crate::usb::TRANSPORT_OUTPUT: crate::usb::BufferTransportOutput
-
context = type
An optional context can be passed to allklipper_command
functions. The lifetime'ctx
is available, and allows the context to capture the lifetime when the generated dispatcher is called, and pass this along to the handler functions. If no context type is given, the default is the empty tuple()
.
An example invocation could be:
klipper_config_generate!(
transport = crate::usb::TRANSPORT_OUTPUT: crate::usb::BufferTransportOutput,
context = &'ctx mut crate::State,
);
This generates a module called _anchor_config
, and exports a KLIPPER_TRANSPORT
symbol from
it.