pub enum RoleExpr {
And(Box<RoleExpr>, Box<RoleExpr>),
Or(Box<RoleExpr>, Box<RoleExpr>),
Not(Box<RoleExpr>),
Role(String),
Invalid,
}
Expand description
A RoleExpr
is a boolean expression tree.
It is typically parsed by the RoleExprParser. However it can also be build programmatically.
Here an example for the expression admin or power_user
:
use toql_core::role_expr::RoleExpr;
let e = RoleExpr::Role("admin".to_string())
.or(RoleExpr::Role("power_user".to_string()));
assert_eq!("(`admin`); (`power_user`)", e.to_string());
Notice that the string representation of OR always comes with parenthesis to express logical priority. To validate a role expression use the RoleValidator.
RoleExpr
are used by Toql derive generated code.
End users should restrict actions with role expressions through the Toql derive.
Example
Restricting the field’s selection to the roles ‘admin’ or ‘power_user’
use toql_derive::Toql;
#[derive(Toql)]
struct FooBar {
#[toql(key)]
id: u64,
#[toql(roles(load="admin;power_user"))]
name: Option<String>
}
Variants
And(Box<RoleExpr>, Box<RoleExpr>)
Concatenate both nodes with AND
Or(Box<RoleExpr>, Box<RoleExpr>)
Concatenate both nodes with OR
Not(Box<RoleExpr>)
Negate node
Role(String)
This node is a role name
Invalid
This node is always invalid
Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for RoleExpr
impl Send for RoleExpr
impl Sync for RoleExpr
impl Unpin for RoleExpr
impl UnwindSafe for RoleExpr
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more