aws_credential_types/
attributes.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6//! Types representing specific pieces of data contained within credentials or within token
7
8/// Type representing a unique identifier representing an AWS account.
9#[derive(Clone, Debug, Eq, PartialEq)]
10pub struct AccountId {
11    inner: String,
12}
13
14impl AccountId {
15    /// Return the string equivalent of this account id.
16    pub fn as_str(&self) -> &str {
17        &self.inner
18    }
19}
20
21impl<T> From<T> for AccountId
22where
23    T: Into<String>,
24{
25    fn from(value: T) -> Self {
26        Self {
27            inner: value.into(),
28        }
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use super::*;
35
36    #[test]
37    fn account_id_creation() {
38        let expected = "012345678901";
39        assert_eq!(expected, AccountId::from(expected).as_str());
40        assert_eq!(expected, AccountId::from(String::from(expected)).as_str());
41    }
42}