[−][src]Struct oso::Oso
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(&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]
Load a string of polar source directly.
Examples
oso.load_str("allow(a, b, c) if true;");
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");
pub fn query_rule<'a>(
&mut self,
name: &str,
args: impl IntoIterator<Item = &'a dyn ToPolar>
) -> Result<Query>
[src]
&mut self,
name: &str,
args: impl IntoIterator<Item = &'a dyn ToPolar>
) -> 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>(
&mut self,
name: &str,
value: &V
) -> Result<()>
[src]
&mut self,
name: &str,
value: &V
) -> 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,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[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.
fn to_owned(&self) -> T
[src]
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.
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>,