pub struct Predicate { /* private fields */ }Expand description
Parsed DSL predicate. Construct via Predicate::parse and evaluate
via Predicate::satisfied_by.
Implementations§
Source§impl Predicate
impl Predicate
Sourcepub fn parse(expr: &str) -> Result<Predicate, JsValue>
pub fn parse(expr: &str) -> Result<Predicate, JsValue>
Parse a DSL expression into a Predicate.
Examples:
min_count("role:director", 3)and(min_count("role:director", 3), min_distinct("region", 3))or(any("expertise"), all("emergency"))not(none("nationality:cn"))
Sourcepub fn satisfied_by(&self, signers_json: &str) -> Result<bool, JsValue>
pub fn satisfied_by(&self, signers_json: &str) -> Result<bool, JsValue>
Evaluate the predicate against a list of signers. Each signer is a plain JS object mapping attribute name -> array of values:
predicate.satisfiedBy([
{ "role:director": ["yes"], "region": ["europe"] },
{ "role:director": ["yes"], "region": ["americas"] },
]);Trait Implementations§
Source§impl FromWasmAbi for Predicate
impl FromWasmAbi for Predicate
Source§impl IntoWasmAbi for Predicate
impl IntoWasmAbi for Predicate
Source§impl LongRefFromWasmAbi for Predicate
impl LongRefFromWasmAbi for Predicate
Source§impl OptionFromWasmAbi for Predicate
impl OptionFromWasmAbi for Predicate
Source§impl OptionIntoWasmAbi for Predicate
impl OptionIntoWasmAbi for Predicate
Source§impl RefFromWasmAbi for Predicate
impl RefFromWasmAbi for Predicate
Source§type Abi = WasmPtr<WasmRefCell<Predicate>>
type Abi = WasmPtr<WasmRefCell<Predicate>>
The Wasm ABI type references to
Self are recovered from.Source§impl RefMutFromWasmAbi for Predicate
impl RefMutFromWasmAbi for Predicate
impl SupportsConstructor for Predicate
impl SupportsInstanceProperty for Predicate
impl SupportsStaticProperty for Predicate
Source§impl TryFromJsValue for Predicate
impl TryFromJsValue for Predicate
Source§impl VectorFromWasmAbi for Predicate
impl VectorFromWasmAbi for Predicate
Source§impl VectorIntoWasmAbi for Predicate
impl VectorIntoWasmAbi for Predicate
Auto Trait Implementations§
impl Freeze for Predicate
impl RefUnwindSafe for Predicate
impl Send for Predicate
impl Sync for Predicate
impl Unpin for Predicate
impl UnsafeUnpin for Predicate
impl UnwindSafe for Predicate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.