Using zome_fn with pub use crate::my_mod::my_function;

I’d like to put a function into a crate module and have the zome_fn decorate the reference to the function.

#[zome_fn("hc_public")]
pub use crate::collective::create_collective;

When I attempt this, I get a compile error:

error: cannot find attribute `zome_fn` in this scope
   --> src/lib.rs:175:4
    |
175 |     #[zome_fn("hc_public")]
    |       ^^^^^^^

It is possible to refer a zome_fn to a function in another module?

What I normally do is just wrap it.

#[zome_fn("hc_public")]
pub create_collective(arg: Foo) -> ZomeApiResult<Bar> {
    crate::collective::create_collective(arg)
}

You can use the same name because it’s in a different module.

3 Likes

Perfect! Thank you!