Struct scratchstack_aws_principal::User
source · [−]pub struct User { /* private fields */ }
Expand description
Details about an AWS IAM user.
User structs are immutable.
Implementations
sourceimpl 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
sourceimpl From<User> for PrincipalIdentity
impl From<User> for PrincipalIdentity
Wrap a User in a PrincipalIdentity.
sourceimpl FromStr for User
impl FromStr for User
sourcefn from_str(arn: &str) -> Result<Self, PrincipalError>
fn from_str(arn: &str) -> Result<Self, PrincipalError>
type Err = PrincipalError
type Err = PrincipalError
The associated error which can be returned from parsing.
sourceimpl Ord for User
impl Ord for User
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<User> for User
impl PartialOrd<User> for User
sourcefn partial_cmp(&self, other: &User) -> Option<Ordering>
fn partial_cmp(&self, other: &User) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const 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 moresourceimpl TryFrom<&Arn> for User
impl TryFrom<&Arn> for User
sourcefn 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.
impl Eq for User
impl StructuralEq for User
impl StructuralPartialEq for User
Auto Trait Implementations
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more