pub enum PrincipalIdentity {
AssumedRole(AssumedRole),
CanonicalUser(CanonicalUser),
FederatedUser(FederatedUser),
RootUser(RootUser),
Service(Service),
User(User),
}
Expand description
A principal identity that is the source of an action in an AWS (or AWS-like) service.
From
conversions are provided for each specific type of identity.
§Examples
let pi: PrincipalIdentity = User::from_str("arn:aws:iam::123456789012:user/username").unwrap().into();
assert_eq!(pi.as_user().unwrap().user_name(), "username");
Variants§
AssumedRole(AssumedRole)
Details for an assumed role.
CanonicalUser(CanonicalUser)
Details for an S3 canonical user.
FederatedUser(FederatedUser)
Details for a federated user.
RootUser(RootUser)
Details for the root user of an account.
Service(Service)
Details for a service.
User(User)
Details for an IAM user.
Implementations§
source§impl PrincipalIdentity
impl PrincipalIdentity
sourcepub fn source(&self) -> PrincipalSource
pub fn source(&self) -> PrincipalSource
Return the source of this principal.
sourcepub fn has_arn(&self) -> bool
pub fn has_arn(&self) -> bool
Indicates whether this principal has an associated ARN.
To obtain the ARN, use code similar to the following:
let ident = PrincipalIdentity::User(User::new("aws", "123456789012", "/", "username").unwrap());
if ident.has_arn() {
let arn: Arn = ident.try_into().unwrap();
}
sourcepub fn as_assumed_role(&self) -> Option<&AssumedRole>
pub fn as_assumed_role(&self) -> Option<&AssumedRole>
If the principal identity is an assumed role, return it. Otherwise, return None
.
sourcepub fn as_canonical_user(&self) -> Option<&CanonicalUser>
pub fn as_canonical_user(&self) -> Option<&CanonicalUser>
If the principal identity is a canonical user, return it. Otherwise, return None
.
sourcepub fn as_federated_user(&self) -> Option<&FederatedUser>
pub fn as_federated_user(&self) -> Option<&FederatedUser>
If the principal identity is a federated user, return it. Otherwise, return None
.
sourcepub fn as_root_user(&self) -> Option<&RootUser>
pub fn as_root_user(&self) -> Option<&RootUser>
If the principal identity is a root user, return it. Otherwise, return None
.
sourcepub fn as_service(&self) -> Option<&Service>
pub fn as_service(&self) -> Option<&Service>
If the principal identity is a service, return it. Otherwise, return None
.
sourcepub fn as_user(&self) -> Option<&User>
pub fn as_user(&self) -> Option<&User>
If the principal identity is a user, return it. Otherwise, return None
.
sourcepub fn parse_arn(arn: &str) -> Result<Self, PrincipalError>
pub fn parse_arn(arn: &str) -> Result<Self, PrincipalError>
Parse an ARN, possibly returning a principal identity. This is mainly a convenience function for unit tests.
§Example
let pi = PrincipalIdentity::parse_arn("arn:aws:iam::123456789012:user/username").unwrap();
assert!(pi.as_user().is_some());
Trait Implementations§
source§impl Clone for PrincipalIdentity
impl Clone for PrincipalIdentity
source§fn clone(&self) -> PrincipalIdentity
fn clone(&self) -> PrincipalIdentity
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PrincipalIdentity
impl Debug for PrincipalIdentity
source§impl Display for PrincipalIdentity
impl Display for PrincipalIdentity
source§impl From<AssumedRole> for PrincipalIdentity
impl From<AssumedRole> for PrincipalIdentity
Wrap an AssumedRole in a PrincipalIdentity.
source§fn from(assumed_role: AssumedRole) -> Self
fn from(assumed_role: AssumedRole) -> Self
source§impl From<CanonicalUser> for PrincipalIdentity
impl From<CanonicalUser> for PrincipalIdentity
Wrap a CanonicalUser in a PrincipalIdentity.
source§fn from(canonical_user: CanonicalUser) -> Self
fn from(canonical_user: CanonicalUser) -> Self
source§impl From<FederatedUser> for PrincipalIdentity
impl From<FederatedUser> for PrincipalIdentity
Wrap a FederatedUser in a PrincipalIdentity.
source§fn from(federated_user: FederatedUser) -> Self
fn from(federated_user: FederatedUser) -> Self
source§impl From<RootUser> for PrincipalIdentity
impl From<RootUser> for PrincipalIdentity
Wrap a RootUser in a PrincipalIdentity.
source§impl From<Service> for PrincipalIdentity
impl From<Service> for PrincipalIdentity
Wrap a Service in a PrincipalIdentity.
source§impl From<User> for PrincipalIdentity
impl From<User> for PrincipalIdentity
Wrap a User in a PrincipalIdentity.
source§impl Hash for PrincipalIdentity
impl Hash for PrincipalIdentity
source§impl Ord for PrincipalIdentity
impl Ord for PrincipalIdentity
source§fn cmp(&self, other: &PrincipalIdentity) -> Ordering
fn cmp(&self, other: &PrincipalIdentity) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for PrincipalIdentity
impl PartialEq for PrincipalIdentity
source§fn eq(&self, other: &PrincipalIdentity) -> bool
fn eq(&self, other: &PrincipalIdentity) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for PrincipalIdentity
impl PartialOrd for PrincipalIdentity
source§fn partial_cmp(&self, other: &PrincipalIdentity) -> Option<Ordering>
fn partial_cmp(&self, other: &PrincipalIdentity) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<&PrincipalIdentity> for Arn
impl TryFrom<&PrincipalIdentity> for Arn
§type Error = PrincipalError
type Error = PrincipalError
source§impl TryFrom<PrincipalIdentity> for Arn
impl TryFrom<PrincipalIdentity> for Arn
§type Error = PrincipalError
type Error = PrincipalError
impl Eq for PrincipalIdentity
impl StructuralPartialEq for PrincipalIdentity
Auto Trait Implementations§
impl Freeze for PrincipalIdentity
impl RefUnwindSafe for PrincipalIdentity
impl Send for PrincipalIdentity
impl Sync for PrincipalIdentity
impl Unpin for PrincipalIdentity
impl UnwindSafe for PrincipalIdentity
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)