dfinity / cdk-rs

Rust canister development kit for the Internet Computer.
Apache License 2.0
202 stars 88 forks source link

Feature: guard function with input parameters #414

Closed 0kenx closed 1 year ago

0kenx commented 1 year ago

It would be useful for the guard function to support input parameters. For example, a guard function can be defined as

enum Role {
    Admin,
    User,
}
fn has_role(role: Role) -> Result<(), String>

and the corresponding guard would be #[update(guard = "has_role(Admin)")]

benjizhai commented 1 year ago

I have implemented this in my Rustic crate's modifiers macro https://docs.rs/rustic/0.1.6/rustic/attr.modifiers.html

0kenx commented 1 year ago

Oh that looks nice, thanks!

sesi200 commented 1 year ago

We're now collecting feature requests over here: https://dx.internetcomputer.org/topic/199