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

An Aspen policy statement.

Statement structs are immutable after creation. They can be created using the StatementBuilder.

Implementations§

Create a new StatementBuilder for building a Statement.

Returns the user-provided statement id if provided, else None.

Returns the effect of the statement (allow or deny).

Returns the list of actions this statement applies to if provided, else None.

Returns the list of actions this statement does not apply to if provided, else None.

Returns the list of resources this statement applies to if provided, else None.

Returns the list of resources this statement does not apply to if provided, else None.

Returns the list of principals this statement applies to if provided, else None.

Returns the list of principals this statement does not apply to if provided, else None.

Returns the conditions that must be met for this statement to apply if provided, else None.

Evaluate this statement against the specified request Context, using the PolicyVersion to perform variable substitution.

Example
let actor = Principal::from(vec![User::from_str("arn:aws:iam::123456789012:user/exampleuser").unwrap().into()]);
let s3_object_arn = Arn::from_str("arn:aws:s3:::examplebucket/exampleuser/my-object").unwrap();
let resources = vec![s3_object_arn.clone()];
let session_data = SessionData::from([("aws:username", SessionValue::from("exampleuser"))]);
let context = Context::builder()
    .service("s3").api("GetObject").actor(actor.clone()).resources(resources.clone())
    .session_data(session_data.clone()).build().unwrap();
let statement = Statement::builder().effect(Effect::Allow).action(vec![Action::new("s3", "Get*").unwrap()])
    .resource(Resource::Any).build().unwrap();
assert_eq!(statement.evaluate(&context, PolicyVersion::V2012_10_17).unwrap(), Decision::Allow);

let context = Context::builder()
    .service("s3").api("PutObject").actor(actor).resources(resources)
    .session_data(session_data).build().unwrap();
assert_eq!(statement.evaluate(&context, PolicyVersion::V2012_10_17).unwrap(), Decision::DefaultDeny);

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.