You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the type system, we can already determine all of the parameter and return types to put them in the blueprint.json.
What we can't know, though, is the description and the argument names.
Proposed Solution
Add a small proc macro to generate a struct holding the extra job metadata.
// The `tangle_job` proc macro has much more information available than the type system provides/// My job#[tangle_job]fnfoo(arg:TangleArg<u16>) -> TangleResult<()>;
The #[tangle_job] macro generates the following:
/// My jobfnfoo(arg:TangleArg<u16>) -> TangleResult<()>;structFooMetadata{name:&'staticstr,description:&'staticstr,params:[&'staticstr;1]}implFooMetadata{fninit() -> Self{Self{name:"foo",description:"My job",params:["arg"]}}}
It does so by taking the function name and parameter names (pretty much for free), and then building the description string from the doc comments.
Then, to apply the metadata to the job, just specify it in your blueprint! macro:
blueprint!{
job:[(foo,FooMetadata::init())]}
Meaning this only adds 2 small extra steps for defining a job:
Putting #[tangle_job] on your job
Specifying the metadata type in the blueprint! macro
The text was updated successfully, but these errors were encountered:
Overview
Using the type system, we can already determine all of the parameter and return types to put them in the blueprint.json.
What we can't know, though, is the description and the argument names.
Proposed Solution
Add a small proc macro to generate a struct holding the extra job metadata.
The
#[tangle_job]
macro generates the following:It does so by taking the function name and parameter names (pretty much for free), and then building the description string from the doc comments.
Then, to apply the metadata to the job, just specify it in your
blueprint!
macro:Meaning this only adds 2 small extra steps for defining a job:
#[tangle_job]
on your jobblueprint!
macroThe text was updated successfully, but these errors were encountered: