pub struct OdrlEngine { /* private fields */ }Expand description
An ODRL policy engine.
The engine holds a parsed OdrlDocument and evaluates requests against
all matching rules. It applies ODRL’s conflict resolution: prohibitions
take precedence over permissions when both match the same (subject, action, target).
Every check emits a structured OdrlAuditEvent via tracing.
Implementations§
Source§impl OdrlEngine
impl OdrlEngine
Sourcepub fn new(doc: OdrlDocument) -> OdrlEngine
pub fn new(doc: OdrlDocument) -> OdrlEngine
Build an engine from a parsed document.
Sourcepub fn from_yaml(yaml: &str) -> Result<OdrlEngine, String>
pub fn from_yaml(yaml: &str) -> Result<OdrlEngine, String>
Parse a YAML string and build an engine.
Sourcepub fn with_context(self, ctx: ConstraintContext) -> OdrlEngine
pub fn with_context(self, ctx: ConstraintContext) -> OdrlEngine
Override the default constraint context (e.g., set purpose for all checks).
Sourcepub fn check_with_context(
&self,
subject: &str,
action: &str,
resource: &str,
ctx: &ConstraintContext,
) -> PolicyResult
pub fn check_with_context( &self, subject: &str, action: &str, resource: &str, ctx: &ConstraintContext, ) -> PolicyResult
Run a check with a specific context (overrides per-call).
Trait Implementations§
Source§impl PolicyEngine for OdrlEngine
impl PolicyEngine for OdrlEngine
Source§fn check(
&self,
subject: &SubjectId,
action: &str,
resource: &ResourceId,
) -> PolicyResult
fn check( &self, subject: &SubjectId, action: &str, resource: &ResourceId, ) -> PolicyResult
Source§fn check_with_context(
&self,
subject: &SubjectId,
action: &str,
resource: &ResourceId,
ctx: &RequestContext,
) -> PolicyResult
fn check_with_context( &self, subject: &SubjectId, action: &str, resource: &ResourceId, ctx: &RequestContext, ) -> PolicyResult
Evaluate a request with runtime context. Read more
Source§fn check_async<'a>(
&'a self,
subject: &'a SubjectId,
action: &'a str,
resource: &'a ResourceId,
) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
fn check_async<'a>( &'a self, subject: &'a SubjectId, action: &'a str, resource: &'a ResourceId, ) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
Source§fn check_with_context_async<'a>(
&'a self,
subject: &'a SubjectId,
action: &'a str,
resource: &'a ResourceId,
ctx: &'a RequestContext,
) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
fn check_with_context_async<'a>( &'a self, subject: &'a SubjectId, action: &'a str, resource: &'a ResourceId, ctx: &'a RequestContext, ) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
Evaluate a request with runtime context asynchronously. Read more
Source§fn with_fallback(self, fallback: Arc<dyn PolicyEngine>) -> FallbackEngine<Self>where
Self: Sized,
fn with_fallback(self, fallback: Arc<dyn PolicyEngine>) -> FallbackEngine<Self>where
Self: Sized,
Compose this engine with a fallback. Read more
Auto Trait Implementations§
impl Freeze for OdrlEngine
impl RefUnwindSafe for OdrlEngine
impl Send for OdrlEngine
impl Sync for OdrlEngine
impl Unpin for OdrlEngine
impl UnsafeUnpin for OdrlEngine
impl UnwindSafe for OdrlEngine
Blanket Implementations§
Source§impl<T> AsyncPolicyEngine for Twhere
T: PolicyEngine + ?Sized,
impl<T> AsyncPolicyEngine for Twhere
T: PolicyEngine + ?Sized,
Source§fn check_async<'a>(
&'a self,
subject: &'a SubjectId,
action: &'a str,
resource: &'a ResourceId,
) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
fn check_async<'a>( &'a self, subject: &'a SubjectId, action: &'a str, resource: &'a ResourceId, ) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
Evaluate whether
subject may perform action on resource
asynchronously.Source§fn check_with_context_async<'a>(
&'a self,
subject: &'a SubjectId,
action: &'a str,
resource: &'a ResourceId,
ctx: &'a RequestContext,
) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
fn check_with_context_async<'a>( &'a self, subject: &'a SubjectId, action: &'a str, resource: &'a ResourceId, ctx: &'a RequestContext, ) -> Pin<Box<dyn Future<Output = PolicyResult> + Send + 'a>>
Evaluate a request with runtime context asynchronously.
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