pub struct Rule(/* private fields */);Expand description
A Lua wrapper for a compiled rusty_rules::Rule that can be evaluated against context data.
It can be efficiently evaluated multiple times against different contexts.
Methods from Deref<Target = Rule<LuaValue>>§
Sourcepub fn evaluate(&self, context: &Ctx) -> Result<bool, Box<dyn Error>>
pub fn evaluate(&self, context: &Ctx) -> Result<bool, Box<dyn Error>>
Evaluates a rule synchronously using the provided context.
This method evaluates the rule against the provided context and returns a boolean result indicating whether the rule matched. If the rule contains any async operations, this method will return an error.
Sourcepub async fn evaluate_async(
&self,
context: &Ctx,
) -> Result<bool, Box<dyn Error>>
pub async fn evaluate_async( &self, context: &Ctx, ) -> Result<bool, Box<dyn Error>>
Evaluates a rule asynchronously using the provided context.
This method evaluates the rule against the provided context and returns a boolean result indicating whether the rule matched. It supports rules containing both synchronous and asynchronous operations.
Trait Implementations§
Source§impl UserData for Rule
impl UserData for Rule
Source§fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M)
fn add_methods<M: LuaUserDataMethods<Self>>(methods: &mut M)
Adds custom methods and operators specific to this userdata.
Source§fn add_fields<F>(fields: &mut F)where
F: UserDataFields<Self>,
fn add_fields<F>(fields: &mut F)where
F: UserDataFields<Self>,
Adds custom fields specific to this userdata.
Source§fn register(registry: &mut UserDataRegistry<Self>)
fn register(registry: &mut UserDataRegistry<Self>)
Registers this type for use in Lua. Read more
Auto Trait Implementations§
impl Freeze for Rule
impl !RefUnwindSafe for Rule
impl !Send for Rule
impl !Sync for Rule
impl Unpin for Rule
impl !UnwindSafe for Rule
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoLuaMulti for Twhere
T: IntoLua,
impl<T> IntoLuaMulti for Twhere
T: IntoLua,
Source§fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>
Performs the conversion.