Trait fadroma::scrt::permit::Permission
source · pub trait Permission: Serialize + JsonSchema + Clone + PartialEq { }
Expand description
Marker trait that enables strongly typed permits with a finite permission set.
Any type that implements Serialize + JsonSchema + Clone + PartialEq
already
implements this trait due to its blanket implementation.
Examples
use fadroma::{
scrt::permit::{Permit, PermitParams},
serde::{Serialize, Deserialize},
schemars::{self, JsonSchema}
};
#[derive(Serialize, JsonSchema, Clone, PartialEq)]
enum MyPermissions {
A,
B
}
let params = PermitParams::new("allowed_contract").permissions([MyPermissions::A]);
// This constructor is available in test code only, not with cfg(target_arch = "wasm32")!
let permit = Permit::new("from", params);
assert!(permit.check_permission(&MyPermissions::A));
assert!(!permit.check_permission(&MyPermissions::B));