pub struct RegoEngine { /* private fields */ }
Available on crate feature
opa
only.Expand description
Rego evaluation engine.
Implementations§
Source§impl RegoEngine
impl RegoEngine
Sourcepub fn add_policy(
&self,
path: impl Into<String>,
rego: impl Into<String>,
) -> Result<String, Error>
pub fn add_policy( &self, path: impl Into<String>, rego: impl Into<String>, ) -> Result<String, Error>
Adds a policy.
Sourcepub fn add_data_json(&self, data_json: &str) -> Result<(), Error>
pub fn add_data_json(&self, data_json: &str) -> Result<(), Error>
Adds the data document in the JSON format.
Sourcepub fn clear_data(&self)
pub fn clear_data(&self)
Clears the data document.
Sourcepub fn set_input_json(&self, input_json: &str) -> Result<(), Error>
pub fn set_input_json(&self, input_json: &str) -> Result<(), Error>
Sets the input document in the JSON format.
Sourcepub fn eval_rule(&self, path: impl Into<String>) -> Result<Value, Error>
pub fn eval_rule(&self, path: impl Into<String>) -> Result<Value, Error>
Evaluates a rule at the given path.
Sourcepub fn eval_bool_query(&self, query: impl Into<String>) -> Result<bool, Error>
pub fn eval_bool_query(&self, query: impl Into<String>) -> Result<bool, Error>
Evaluates a Rego query that produces a boolean value.
Sourcepub fn eval_allow_query(&self, query: impl Into<String>) -> bool
pub fn eval_allow_query(&self, query: impl Into<String>) -> bool
Evaluates an allow
query.
Sourcepub fn eval_deny_query(&self, query: impl Into<String>) -> bool
pub fn eval_deny_query(&self, query: impl Into<String>) -> bool
Evaluates a deny
query.
Returns a reference to the shared Rego engine.
Auto Trait Implementations§
impl !Freeze for RegoEngine
impl !RefUnwindSafe for RegoEngine
impl Send for RegoEngine
impl Sync for RegoEngine
impl Unpin for RegoEngine
impl !UnwindSafe for RegoEngine
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 more