PolicyBuilder

Struct PolicyBuilder 

Source
pub struct PolicyBuilder<V, M, S> { /* private fields */ }
Expand description

A policy builder, responsible for parsing policy definition and constructing Policy struct.

It handles policy definition versioning and allows fine-grained configuration of Policy components.

Implementations§

Source§

impl PolicyBuilder<DefaultValidator, Default, DefaultSubstituter>

Source

pub fn from_json( json: impl Into<String>, ) -> PolicyBuilder<DefaultValidator, Default, DefaultSubstituter>

Constructs a PolicyBuilder from provided json policy definition, with default configuration.

Call to this method does not parse or validate the json, all heavy work is done in build method.

Source

pub fn from_definition( definition: PolicyDefinition, ) -> PolicyBuilder<DefaultValidator, Default, DefaultSubstituter>

Constructs a PolicyBuilder from provided policy definition struct, with default configuration.

Call to this method does not validate the definition, all heavy work is done in build method.

Source§

impl<V, M, S, E> PolicyBuilder<V, M, S>
where V: PolicyValidator<Error = E>, M: ResourceMatcher, S: Substituter, E: StdError + Sync + Into<Box<dyn StdError>> + 'static,

Source

pub fn with_validator<V1>(self, validator: V1) -> PolicyBuilder<V1, M, S>

Specifies the PolicyValidator to validate the policy definition.

Source

pub fn with_matcher<M1>(self, matcher: M1) -> PolicyBuilder<V, M1, S>

Specifies the ResourceMatcher to use with Policy.

Source

pub fn with_substituter<S1>(self, substituter: S1) -> PolicyBuilder<V, M, S1>

Specifies the Substituter to use with Policy.

Source

pub fn with_default_decision(self, decision: Decision) -> Self

Specifies the default decision that Policy will return if no rules match the request.

Source

pub fn build(self) -> Result<Policy<M, S>>

Builds a Policy consuming the builder.

This method does all the heavy lifting of deserializing json, validating and constructing the policy rules tree.

§Errors

Returns PolicyValidator::Error if any.

Auto Trait Implementations§

§

impl<V, M, S> Freeze for PolicyBuilder<V, M, S>
where V: Freeze, M: Freeze, S: Freeze,

§

impl<V, M, S> RefUnwindSafe for PolicyBuilder<V, M, S>

§

impl<V, M, S> Send for PolicyBuilder<V, M, S>
where V: Send, M: Send, S: Send,

§

impl<V, M, S> Sync for PolicyBuilder<V, M, S>
where V: Sync, M: Sync, S: Sync,

§

impl<V, M, S> Unpin for PolicyBuilder<V, M, S>
where V: Unpin, M: Unpin, S: Unpin,

§

impl<V, M, S> UnwindSafe for PolicyBuilder<V, M, S>
where V: UnwindSafe, M: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.