pub struct Policy { /* private fields */ }
Expand description

The top-level structure for holding an Aspen policy.

This does not directly derive Deserialize/Serialize to prevent serde from allowing this to be represented as an array.

Policy structures are immutable after creation.

Implementations§

Returns a builder for a Policy.

Returns the policy version.

Returns the user-specified identifier for the policy, or None if no identifier was specified.

Returns the policy statements associated with the policy.

Evaluates the policy against the request Context.

Returns Decision::Deny if the policy denies the request, Decision::Allow if the policy allows the request, or Decision::DefaultDeny if the policy does not explicitly allow or deny the request.

Example
let action = Action::from_str("s3:ListBucket").unwrap();
let resource = Resource::from_str("arn:aws:s3:::examplebucket").unwrap();
let statement = Statement::builder().effect(Effect::Allow).action(action).resource(resource).build().unwrap();
let policy = Policy::builder().statement(statement).build().unwrap();

let actor = Principal::from(vec![User::from_str("arn:aws:iam::123456789012:user/exampleuser").unwrap().into()]);
let context = Context::builder().service("s3").api("ListBucket").actor(actor)
    .session_data(SessionData::new()).build().unwrap();
policy.evaluate(&context);

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.