aws_sdk_ecs/types/
_ulimit_name.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `UlimitName`, it is important to ensure
4/// your code is forward-compatible. That is, if a match arm handles a case for a
5/// feature that is supported by the service but has not been represented as an enum
6/// variant in a current version of SDK, your code should continue to work when you
7/// upgrade SDK to a future version in which the enum does include a variant for that
8/// feature.
9///
10/// Here is an example of how you can make a match expression forward-compatible:
11///
12/// ```text
13/// # let ulimitname = unimplemented!();
14/// match ulimitname {
15///     UlimitName::Core => { /* ... */ },
16///     UlimitName::Cpu => { /* ... */ },
17///     UlimitName::Data => { /* ... */ },
18///     UlimitName::Fsize => { /* ... */ },
19///     UlimitName::Locks => { /* ... */ },
20///     UlimitName::Memlock => { /* ... */ },
21///     UlimitName::Msgqueue => { /* ... */ },
22///     UlimitName::Nice => { /* ... */ },
23///     UlimitName::Nofile => { /* ... */ },
24///     UlimitName::Nproc => { /* ... */ },
25///     UlimitName::Rss => { /* ... */ },
26///     UlimitName::Rtprio => { /* ... */ },
27///     UlimitName::Rttime => { /* ... */ },
28///     UlimitName::Sigpending => { /* ... */ },
29///     UlimitName::Stack => { /* ... */ },
30///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
31///     _ => { /* ... */ },
32/// }
33/// ```
34/// The above code demonstrates that when `ulimitname` represents
35/// `NewFeature`, the execution path will lead to the second last match arm,
36/// even though the enum does not contain a variant `UlimitName::NewFeature`
37/// in the current version of SDK. The reason is that the variable `other`,
38/// created by the `@` operator, is bound to
39/// `UlimitName::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
40/// and calling `as_str` on it yields `"NewFeature"`.
41/// This match expression is forward-compatible when executed with a newer
42/// version of SDK where the variant `UlimitName::NewFeature` is defined.
43/// Specifically, when `ulimitname` represents `NewFeature`,
44/// the execution path will hit the second last match arm as before by virtue of
45/// calling `as_str` on `UlimitName::NewFeature` also yielding `"NewFeature"`.
46///
47/// Explicitly matching on the `Unknown` variant should
48/// be avoided for two reasons:
49/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
50/// - It might inadvertently shadow other intended match arms.
51///
52#[allow(missing_docs)] // documentation missing in model
53#[non_exhaustive]
54#[derive(
55    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
56)]
57pub enum UlimitName {
58    #[allow(missing_docs)] // documentation missing in model
59    Core,
60    #[allow(missing_docs)] // documentation missing in model
61    Cpu,
62    #[allow(missing_docs)] // documentation missing in model
63    Data,
64    #[allow(missing_docs)] // documentation missing in model
65    Fsize,
66    #[allow(missing_docs)] // documentation missing in model
67    Locks,
68    #[allow(missing_docs)] // documentation missing in model
69    Memlock,
70    #[allow(missing_docs)] // documentation missing in model
71    Msgqueue,
72    #[allow(missing_docs)] // documentation missing in model
73    Nice,
74    #[allow(missing_docs)] // documentation missing in model
75    Nofile,
76    #[allow(missing_docs)] // documentation missing in model
77    Nproc,
78    #[allow(missing_docs)] // documentation missing in model
79    Rss,
80    #[allow(missing_docs)] // documentation missing in model
81    Rtprio,
82    #[allow(missing_docs)] // documentation missing in model
83    Rttime,
84    #[allow(missing_docs)] // documentation missing in model
85    Sigpending,
86    #[allow(missing_docs)] // documentation missing in model
87    Stack,
88    /// `Unknown` contains new variants that have been added since this code was generated.
89    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
90    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
91}
92impl ::std::convert::From<&str> for UlimitName {
93    fn from(s: &str) -> Self {
94        match s {
95            "core" => UlimitName::Core,
96            "cpu" => UlimitName::Cpu,
97            "data" => UlimitName::Data,
98            "fsize" => UlimitName::Fsize,
99            "locks" => UlimitName::Locks,
100            "memlock" => UlimitName::Memlock,
101            "msgqueue" => UlimitName::Msgqueue,
102            "nice" => UlimitName::Nice,
103            "nofile" => UlimitName::Nofile,
104            "nproc" => UlimitName::Nproc,
105            "rss" => UlimitName::Rss,
106            "rtprio" => UlimitName::Rtprio,
107            "rttime" => UlimitName::Rttime,
108            "sigpending" => UlimitName::Sigpending,
109            "stack" => UlimitName::Stack,
110            other => UlimitName::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
111        }
112    }
113}
114impl ::std::str::FromStr for UlimitName {
115    type Err = ::std::convert::Infallible;
116
117    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
118        ::std::result::Result::Ok(UlimitName::from(s))
119    }
120}
121impl UlimitName {
122    /// Returns the `&str` value of the enum member.
123    pub fn as_str(&self) -> &str {
124        match self {
125            UlimitName::Core => "core",
126            UlimitName::Cpu => "cpu",
127            UlimitName::Data => "data",
128            UlimitName::Fsize => "fsize",
129            UlimitName::Locks => "locks",
130            UlimitName::Memlock => "memlock",
131            UlimitName::Msgqueue => "msgqueue",
132            UlimitName::Nice => "nice",
133            UlimitName::Nofile => "nofile",
134            UlimitName::Nproc => "nproc",
135            UlimitName::Rss => "rss",
136            UlimitName::Rtprio => "rtprio",
137            UlimitName::Rttime => "rttime",
138            UlimitName::Sigpending => "sigpending",
139            UlimitName::Stack => "stack",
140            UlimitName::Unknown(value) => value.as_str(),
141        }
142    }
143    /// Returns all the `&str` representations of the enum members.
144    pub const fn values() -> &'static [&'static str] {
145        &[
146            "core",
147            "cpu",
148            "data",
149            "fsize",
150            "locks",
151            "memlock",
152            "msgqueue",
153            "nice",
154            "nofile",
155            "nproc",
156            "rss",
157            "rtprio",
158            "rttime",
159            "sigpending",
160            "stack",
161        ]
162    }
163}
164impl ::std::convert::AsRef<str> for UlimitName {
165    fn as_ref(&self) -> &str {
166        self.as_str()
167    }
168}
169impl UlimitName {
170    /// Parses the enum value while disallowing unknown variants.
171    ///
172    /// Unknown variants will result in an error.
173    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
174        match Self::from(value) {
175            #[allow(deprecated)]
176            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
177            known => Ok(known),
178        }
179    }
180}
181impl ::std::fmt::Display for UlimitName {
182    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
183        match self {
184            UlimitName::Core => write!(f, "core"),
185            UlimitName::Cpu => write!(f, "cpu"),
186            UlimitName::Data => write!(f, "data"),
187            UlimitName::Fsize => write!(f, "fsize"),
188            UlimitName::Locks => write!(f, "locks"),
189            UlimitName::Memlock => write!(f, "memlock"),
190            UlimitName::Msgqueue => write!(f, "msgqueue"),
191            UlimitName::Nice => write!(f, "nice"),
192            UlimitName::Nofile => write!(f, "nofile"),
193            UlimitName::Nproc => write!(f, "nproc"),
194            UlimitName::Rss => write!(f, "rss"),
195            UlimitName::Rtprio => write!(f, "rtprio"),
196            UlimitName::Rttime => write!(f, "rttime"),
197            UlimitName::Sigpending => write!(f, "sigpending"),
198            UlimitName::Stack => write!(f, "stack"),
199            UlimitName::Unknown(value) => write!(f, "{value}"),
200        }
201    }
202}