streamingfast / substreams-rs

7 stars 3 forks source link

Accept `Result<Option<T>, ...>` and `Option<T>` when using proc-macro `#[substreams::handler::map]` #11

Closed maoueh closed 3 months ago

maoueh commented 1 year ago

Right now we only accept Result<T, substreams::errors::Error> when using proc-macro #[substreams::handler::map] but a lot of use cases would make the experience easier if we accepted the form Result<Option<T>, substreams::errors::Error>, plain Option<T> and maybe even just T.

The goal of this task is to update the Rust proc macro code in substreams-rs to properly support all those cases.

Proc macro don't have access to type information as it work as the lexing level having access to "token". So we will need some "hard-coded" "String" check to determine the right code to generate.