Struct oso::Oso [−][src]
Oso is the main struct you interact with. It is an instance of the Oso authorization library and contains the polar language knowledge base and query engine.
Implementations
impl Oso
[src]
pub fn new() -> Self
[src]
Create a new instance of Oso. Each instance is separate and can have different rules and classes loaded into it.
pub fn is_allowed<Actor, Action, Resource>(
&mut self,
actor: Actor,
action: Action,
resource: Resource
) -> Result<bool> where
Actor: ToPolar,
Action: ToPolar,
Resource: ToPolar,
[src]
&mut self,
actor: Actor,
action: Action,
resource: Resource
) -> Result<bool> where
Actor: ToPolar,
Action: ToPolar,
Resource: ToPolar,
High level interface for authorization decisions. Makes an allow query with the given actor, action and resource and returns true or false.
pub fn clear_rules(&mut self)
[src]
Clear out all files and rules that have been loaded.
pub fn load_file<P: AsRef<Path>>(&mut self, file: P) -> Result<()>
[src]
Load a file containing polar rules. All polar files must end in .polar
pub fn load_str(&mut self, s: &str) -> Result<()>
[src]
pub fn query(&mut self, s: &str) -> Result<Query>
[src]
Query the knowledge base. This can be an allow query or any other polar expression.
Examples
oso.query("x = 1 or x = 2");
#[must_use = "Query that is not consumed does nothing."]pub fn query_rule(
&mut self,
name: &str,
args: impl ToPolarList
) -> Result<Query>
[src]
&mut self,
name: &str,
args: impl ToPolarList
) -> Result<Query>
Query the knowledge base but with a rule name and argument list. This allows you to pass in rust values.
Examples
oso.query_rule("is_admin", vec![User{name: "steve"}]);
pub fn register_class(&mut self, class: Class) -> Result<()>
[src]
Register a rust type as a Polar class.
See [oso::Class
] docs.
pub fn register_constant<V: ToPolar + Send + Sync>(
&mut self,
value: V,
name: &str
) -> Result<()>
[src]
&mut self,
value: V,
name: &str
) -> Result<()>
Register a rust type as a Polar constant.
See [oso::Class
] docs.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Oso
impl Send for Oso
impl Sync for Oso
impl Unpin for Oso
impl !UnwindSafe for Oso
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,