Enum scratchstack_aspen::Action
source · pub enum Action {
Any,
Specific(SpecificActionDetails),
}
Expand description
An action in an Aspen policy.
This can either be Any
action (represented by the string *
), or a service and an API pattern (Specific
)
in the form service:api_pattern
. The API pattern may contain wildcard characters (*
and ?
).
Variants§
Implementations§
source§impl Action
impl Action
sourcepub fn new<S: Into<String>, A: Into<String>>(
service: S,
api: A
) -> Result<Self, AspenError>
pub fn new<S: Into<String>, A: Into<String>>(
service: S,
api: A
) -> Result<Self, AspenError>
Create a new Action::Specific action.
Errors
An AspenError::InvalidAction error is returned in any of the following cases:
service
orapi
is empty.service
contains non-ASCII alphanumeric characters, hyphen (-
), or underscore (_
).service
begins or ends with a hyphen or underscore.api
contains non-ASCII alphanumeric characters, hyphen (-
), underscore (_
), asterisk (*
), or question mark (?
).api
begins or ends with a hyphen or underscore.
sourcepub fn is_any(&self) -> bool
pub fn is_any(&self) -> bool
Returns true if this action is Action::Any.
sourcepub fn specific(&self) -> Option<(&str, &str)>
pub fn specific(&self) -> Option<(&str, &str)>
If the action is Action::Specific, returns the service and action.
sourcepub fn service(&self) -> &str
pub fn service(&self) -> &str
Returns the service for this action or “*” if this action is Action::Any.
sourcepub fn api(&self) -> &str
pub fn api(&self) -> &str
Returns the API for this action or “*” if this action is Action::Any.