pub struct QueryRewriter { /* private fields */ }Expand description
Query rewriter
Main entry point for query rewriting operations.
Implementations§
Source§impl QueryRewriter
impl QueryRewriter
Sourcepub fn new(config: RewriterConfig) -> Self
pub fn new(config: RewriterConfig) -> Self
Create a new query rewriter
Sourcepub fn builder() -> QueryRewriterBuilder
pub fn builder() -> QueryRewriterBuilder
Create a builder
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if rewriter is enabled
Sourcepub fn rewrite(&self, query: &str) -> Result<RewriteResult, RewriteError>
pub fn rewrite(&self, query: &str) -> Result<RewriteResult, RewriteError>
Rewrite a query
Returns the rewritten query and list of applied rules.
Sourcepub fn test_rewrite(&self, query: &str) -> Result<RewriteResult, RewriteError>
pub fn test_rewrite(&self, query: &str) -> Result<RewriteResult, RewriteError>
Test rewrite without metrics recording
Sourcepub fn add_rule(&self, rule: impl Into<RewriteRule>)
pub fn add_rule(&self, rule: impl Into<RewriteRule>)
Add a new rule
Sourcepub fn remove_rule(&self, rule_id: &str) -> bool
pub fn remove_rule(&self, rule_id: &str) -> bool
Remove a rule by ID
Sourcepub fn update_rule(
&self,
rule_id: &str,
update: impl FnOnce(&mut RewriteRule),
) -> bool
pub fn update_rule( &self, rule_id: &str, update: impl FnOnce(&mut RewriteRule), ) -> bool
Update a rule
Sourcepub fn set_rule_enabled(&self, rule_id: &str, enabled: bool) -> bool
pub fn set_rule_enabled(&self, rule_id: &str, enabled: bool) -> bool
Enable/disable a rule
Sourcepub fn get_rules(&self) -> Vec<RewriteRule>
pub fn get_rules(&self) -> Vec<RewriteRule>
Get all rules
Sourcepub fn get_rule(&self, rule_id: &str) -> Option<RewriteRule>
pub fn get_rule(&self, rule_id: &str) -> Option<RewriteRule>
Get rule by ID
Sourcepub fn stats(&self) -> RewriteStats
pub fn stats(&self) -> RewriteStats
Get statistics
Auto Trait Implementations§
impl Freeze for QueryRewriter
impl !RefUnwindSafe for QueryRewriter
impl Send for QueryRewriter
impl Sync for QueryRewriter
impl Unpin for QueryRewriter
impl UnsafeUnpin for QueryRewriter
impl !UnwindSafe for QueryRewriter
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