Struct scratchstack_aws_principal::User
source · pub struct User { /* private fields */ }
Expand description
Details about an AWS IAM user.
User structs are immutable.
Implementations§
source§impl User
impl User
sourcepub fn new(
partition: &str,
account_id: &str,
path: &str,
user_name: &str
) -> Result<Self, PrincipalError>
pub fn new(
partition: &str,
account_id: &str,
path: &str,
user_name: &str
) -> Result<Self, PrincipalError>
Create a User object.
Arguments
account_id
: The 12 digit account id. This must be composed of 12 ASCII digits or a PrincipalError::InvalidAccountId error will be returned.path
: The IAM path the group is under. This must meet the following requirements or a PrincipalError::InvalidPath error will be returned:- The path must contain between 1 and 512 characters.
- The path must start and end with
/
. - All characters in the path must be in the ASCII range 0x21 (
!
) through 0x7E (~
). The AWS documentation erroneously indicates that 0x7F (DEL) is acceptable; however, the IAM APIs reject this character.
user_name
: The name of the user. This must meet the following requirements or a PrincipalError::InvalidUserName error will be returned:- The name must contain between 1 and 64 characters.
- The name must be composed to ASCII alphanumeric characters or one of
, - . = @ _
.
Return value
If all of the requirements are met, a User object is returned. Otherwise, a PrincipalError error is returned.
sourcepub fn account_id(&self) -> &str
pub fn account_id(&self) -> &str
The account ID of the user.
Trait Implementations§
source§impl From<User> for PrincipalIdentity
impl From<User> for PrincipalIdentity
Wrap a User in a PrincipalIdentity.
source§impl FromStr for User
impl FromStr for User
§type Err = PrincipalError
type Err = PrincipalError
The associated error which can be returned from parsing.
source§impl Ord for User
impl Ord for User
source§impl PartialEq<User> for User
impl PartialEq<User> for User
source§impl PartialOrd<User> for User
impl PartialOrd<User> for User
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<&Arn> for User
impl TryFrom<&Arn> for User
source§fn try_from(arn: &Arn) -> Result<Self, Self::Error>
fn try_from(arn: &Arn) -> Result<Self, Self::Error>
If an Arn represents a valid IAM user, convert it to a User; otherwise, return a PrincipalError indicating what is wrong with the ARN.
Example
let arn = Arn::from_str("arn:aws:iam::123456789012:user/path/user-name").unwrap();
let user = User::try_from(&arn).unwrap();
assert_eq!(user.path(), "/path/");
assert_eq!(user.user_name(), "user-name");
§type Error = PrincipalError
type Error = PrincipalError
The type returned in the event of a conversion error.