pub struct PolicyEngine { /* private fields */ }Expand description
Evaluates query plans against a fixed policy configuration.
§Examples
use vlorql_core::policy::{PolicyConfig, PolicyEngine};
let engine = PolicyEngine::new(PolicyConfig::default());
assert!(engine.config().table_policies.is_empty());Implementations§
Source§impl PolicyEngine
impl PolicyEngine
Sourcepub fn new(config: PolicyConfig) -> Self
pub fn new(config: PolicyConfig) -> Self
Creates an engine from an immutable policy configuration.
Sourcepub fn config(&self) -> &PolicyConfig
pub fn config(&self) -> &PolicyConfig
Returns the configuration used by this engine.
Sourcepub fn validate(
&self,
plan: &QueryPlan,
schema: &SchemaSnapshot,
) -> Result<(), Vec<VlorQLError>>
pub fn validate( &self, plan: &QueryPlan, schema: &SchemaSnapshot, ) -> Result<(), Vec<VlorQLError>>
Validates all base-table and column references and collects every violation.
Sourcepub fn apply_row_filters(&self, plan: &QueryPlan) -> Option<Predicate>
pub fn apply_row_filters(&self, plan: &QueryPlan) -> Option<Predicate>
Combines every applicable row filter into one left-associated AND predicate.
The returned predicate contains policy filters only. The caller is responsible
for combining it with the query plan’s existing WHERE predicate.
Sourcepub fn is_column_allowed(&self, table: &str, column: &str) -> bool
pub fn is_column_allowed(&self, table: &str, column: &str) -> bool
Returns whether a table and column pass the configured policy rules.
Sourcepub fn get_row_filter(&self, table: &str) -> Option<&RowFilter>
pub fn get_row_filter(&self, table: &str) -> Option<&RowFilter>
Returns the table-specific row filter, if configured.
Sourcepub fn get_policy_for_table(&self, table: &str) -> Option<&TablePolicy>
pub fn get_policy_for_table(&self, table: &str) -> Option<&TablePolicy>
Returns the policy configured for an exact schema table name.
Trait Implementations§
Source§impl Clone for PolicyEngine
impl Clone for PolicyEngine
Source§fn clone(&self) -> PolicyEngine
fn clone(&self) -> PolicyEngine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PolicyEngine
impl RefUnwindSafe for PolicyEngine
impl Send for PolicyEngine
impl Sync for PolicyEngine
impl Unpin for PolicyEngine
impl UnsafeUnpin for PolicyEngine
impl UnwindSafe for PolicyEngine
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request