Struct Arn

Source
pub struct Arn { /* private fields */ }
Expand description

An Amazon Resource Name (ARN) representing an exact resource.

This is used to represent a known resource, such as an S3 bucket, EC2 instance, assumed role instance, etc. This is not used to represent resource statements in the IAM Aspen policy language, which may contain wildcards.

Arn objects are immutable.

Implementations§

Source§

impl Arn

Source

pub fn new( partition: &str, service: &str, region: &str, account_id: &str, resource: &str, ) -> Result<Self, ArnError>

Create a new ARN from the specified components.

  • partition - The partition the resource is in (required). This is usually aws, aws-cn, or aws-us-gov for actual AWS resources, but may be any string meeting the rules specified in validate_partition for non-AWS resources.
  • service - The service the resource belongs to (required). This is a service name like ec2 or s3. Non-AWS resources must conform to the naming rules specified in validate_service.
  • region - The region the resource is in (optional). If the resource is regional (and may other regions may have the resources with the same name), this is the region name. If the resource is global, this is empty. This is usually a region name like us-east-1 or us-west-2, but may be any string meeting the rules specified in validate_region.
  • account_id - The account ID the resource belongs to (optional). This is the 12-digit account ID or the string aws for certain AWS-owned resources. Some resources (such as S3 buckets and objects) do not need the account ID (the bucket name is globally unique within a partition), so this may be empty.
  • resource - The resource name (required). This is the name of the resource. The formatting is service-specific, but must be a valid UTF-8 string.
§Errors
Source

pub unsafe fn new_unchecked( partition: &str, service: &str, region: &str, account_id: &str, resource: &str, ) -> Self

Create a new ARN from the specified components, bypassing any validation.

§Safety

The following constraints must be met:

  • partition - Must meet the rules specified in validate_partition.
  • service - Must meet the rules specified in validate_service.
  • region - Must be empty or meet the rules specified in validate_region.
  • account_id - Must be empty, a 12 ASCII digit account ID, or the string aws.
  • resource - A valid UTF-8 string.
Source

pub fn partition(&self) -> &str

Retrieve the partition the resource is in.

Source

pub fn service(&self) -> &str

Retrieve the service the resource belongs to.

Source

pub fn region(&self) -> &str

Retrieve the region the resource is in.

Source

pub fn account_id(&self) -> &str

Retrieve the account ID the resource belongs to.

Source

pub fn resource(&self) -> &str

Retrieve the resource name.

Trait Implementations§

Source§

impl Clone for Arn

Source§

fn clone(&self) -> Arn

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Arn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Arn

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Arn

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Return the ARN.

Source§

impl FromStr for Arn

Parse a string into an Arn.

Source§

type Err = ArnError

ArnError is returned if the string is not a valid ARN.

Source§

fn from_str(s: &str) -> Result<Self, ArnError>

Parse an ARN from a string.

§Errors
Source§

impl Hash for Arn

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Arn

Orders ARNs by partition, service, region, account ID, and resource.

Source§

fn cmp(&self, other: &Self) -> Ordering

Returns the relative ordering between this and another ARN.

1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Arn

Source§

fn eq(&self, other: &Arn) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Arn

Orders ARNs by partition, service, region, account ID, and resource.

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

Returns the relative ordering between this and another ARN.

1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Arn

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Arn

Source§

impl StructuralPartialEq for Arn

Auto Trait Implementations§

§

impl Freeze for Arn

§

impl RefUnwindSafe for Arn

§

impl Send for Arn

§

impl Sync for Arn

§

impl Unpin for Arn

§

impl UnwindSafe for Arn

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,