oasis-rs
oasis-rs copied to clipboard
Mechanism for permissioning methods as #[owner_only] and transitioning owner
#[service]
struct MyService;
impl MyService {
#[owner_only]
fn owner_only(&self, _ctx: &Context) -> Result<u32> {
Ok(42)
}
fn explicit_owner_only(&self, ctx: &Context) -> Result<u32> {
if ctx.sender() != self._owner { // `self._owner` is auto-added
return Err(format_err!("Permission denied"));
}
Ok(42)
}
}
It's probably worth differentiating mix-in libraries that can be added to services from the core runtime standard library
👍
#[service(plugins = [acl, some_crate::some_plugin])]
struct MyService;
// or maybe
#[service]
#[plugin(acl)]
#[plugin(some_crate::some_plugin)]
struct MyService;