Skip to main content

aws_sdk_inspector2/types/
_package_manager.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// When writing a match expression against `PackageManager`, 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 packagemanager = unimplemented!();
14/// match packagemanager {
15///     PackageManager::Bundler => { /* ... */ },
16///     PackageManager::Cargo => { /* ... */ },
17///     PackageManager::Composer => { /* ... */ },
18///     PackageManager::DotnetCore => { /* ... */ },
19///     PackageManager::Gemspec => { /* ... */ },
20///     PackageManager::Gobinary => { /* ... */ },
21///     PackageManager::Gomod => { /* ... */ },
22///     PackageManager::Jar => { /* ... */ },
23///     PackageManager::Nodepkg => { /* ... */ },
24///     PackageManager::Npm => { /* ... */ },
25///     PackageManager::Nuget => { /* ... */ },
26///     PackageManager::Os => { /* ... */ },
27///     PackageManager::Pip => { /* ... */ },
28///     PackageManager::Pipenv => { /* ... */ },
29///     PackageManager::Poetry => { /* ... */ },
30///     PackageManager::Pom => { /* ... */ },
31///     PackageManager::Pythonpkg => { /* ... */ },
32///     PackageManager::Yarn => { /* ... */ },
33///     other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
34///     _ => { /* ... */ },
35/// }
36/// ```
37/// The above code demonstrates that when `packagemanager` represents
38/// `NewFeature`, the execution path will lead to the second last match arm,
39/// even though the enum does not contain a variant `PackageManager::NewFeature`
40/// in the current version of SDK. The reason is that the variable `other`,
41/// created by the `@` operator, is bound to
42/// `PackageManager::Unknown(UnknownVariantValue("NewFeature".to_owned()))`
43/// and calling `as_str` on it yields `"NewFeature"`.
44/// This match expression is forward-compatible when executed with a newer
45/// version of SDK where the variant `PackageManager::NewFeature` is defined.
46/// Specifically, when `packagemanager` represents `NewFeature`,
47/// the execution path will hit the second last match arm as before by virtue of
48/// calling `as_str` on `PackageManager::NewFeature` also yielding `"NewFeature"`.
49///
50/// Explicitly matching on the `Unknown` variant should
51/// be avoided for two reasons:
52/// - The inner data `UnknownVariantValue` is opaque, and no further information can be extracted.
53/// - It might inadvertently shadow other intended match arms.
54///
55#[allow(missing_docs)] // documentation missing in model
56#[non_exhaustive]
57#[derive(
58    ::std::clone::Clone, ::std::cmp::Eq, ::std::cmp::Ord, ::std::cmp::PartialEq, ::std::cmp::PartialOrd, ::std::fmt::Debug, ::std::hash::Hash,
59)]
60pub enum PackageManager {
61    #[allow(missing_docs)] // documentation missing in model
62    Bundler,
63    #[allow(missing_docs)] // documentation missing in model
64    Cargo,
65    #[allow(missing_docs)] // documentation missing in model
66    Composer,
67    #[allow(missing_docs)] // documentation missing in model
68    DotnetCore,
69    #[allow(missing_docs)] // documentation missing in model
70    Gemspec,
71    #[allow(missing_docs)] // documentation missing in model
72    Gobinary,
73    #[allow(missing_docs)] // documentation missing in model
74    Gomod,
75    #[allow(missing_docs)] // documentation missing in model
76    Jar,
77    #[allow(missing_docs)] // documentation missing in model
78    Nodepkg,
79    #[allow(missing_docs)] // documentation missing in model
80    Npm,
81    #[allow(missing_docs)] // documentation missing in model
82    Nuget,
83    #[allow(missing_docs)] // documentation missing in model
84    Os,
85    #[allow(missing_docs)] // documentation missing in model
86    Pip,
87    #[allow(missing_docs)] // documentation missing in model
88    Pipenv,
89    #[allow(missing_docs)] // documentation missing in model
90    Poetry,
91    #[allow(missing_docs)] // documentation missing in model
92    Pom,
93    #[allow(missing_docs)] // documentation missing in model
94    Pythonpkg,
95    #[allow(missing_docs)] // documentation missing in model
96    Yarn,
97    /// `Unknown` contains new variants that have been added since this code was generated.
98    #[deprecated(note = "Don't directly match on `Unknown`. See the docs on this enum for the correct way to handle unknown variants.")]
99    Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue),
100}
101impl ::std::convert::From<&str> for PackageManager {
102    fn from(s: &str) -> Self {
103        match s {
104            "BUNDLER" => PackageManager::Bundler,
105            "CARGO" => PackageManager::Cargo,
106            "COMPOSER" => PackageManager::Composer,
107            "DOTNET_CORE" => PackageManager::DotnetCore,
108            "GEMSPEC" => PackageManager::Gemspec,
109            "GOBINARY" => PackageManager::Gobinary,
110            "GOMOD" => PackageManager::Gomod,
111            "JAR" => PackageManager::Jar,
112            "NODEPKG" => PackageManager::Nodepkg,
113            "NPM" => PackageManager::Npm,
114            "NUGET" => PackageManager::Nuget,
115            "OS" => PackageManager::Os,
116            "PIP" => PackageManager::Pip,
117            "PIPENV" => PackageManager::Pipenv,
118            "POETRY" => PackageManager::Poetry,
119            "POM" => PackageManager::Pom,
120            "PYTHONPKG" => PackageManager::Pythonpkg,
121            "YARN" => PackageManager::Yarn,
122            other => PackageManager::Unknown(crate::primitives::sealed_enum_unknown::UnknownVariantValue(other.to_owned())),
123        }
124    }
125}
126impl ::std::str::FromStr for PackageManager {
127    type Err = ::std::convert::Infallible;
128
129    fn from_str(s: &str) -> ::std::result::Result<Self, <Self as ::std::str::FromStr>::Err> {
130        ::std::result::Result::Ok(PackageManager::from(s))
131    }
132}
133impl PackageManager {
134    /// Returns the `&str` value of the enum member.
135    pub fn as_str(&self) -> &str {
136        match self {
137            PackageManager::Bundler => "BUNDLER",
138            PackageManager::Cargo => "CARGO",
139            PackageManager::Composer => "COMPOSER",
140            PackageManager::DotnetCore => "DOTNET_CORE",
141            PackageManager::Gemspec => "GEMSPEC",
142            PackageManager::Gobinary => "GOBINARY",
143            PackageManager::Gomod => "GOMOD",
144            PackageManager::Jar => "JAR",
145            PackageManager::Nodepkg => "NODEPKG",
146            PackageManager::Npm => "NPM",
147            PackageManager::Nuget => "NUGET",
148            PackageManager::Os => "OS",
149            PackageManager::Pip => "PIP",
150            PackageManager::Pipenv => "PIPENV",
151            PackageManager::Poetry => "POETRY",
152            PackageManager::Pom => "POM",
153            PackageManager::Pythonpkg => "PYTHONPKG",
154            PackageManager::Yarn => "YARN",
155            PackageManager::Unknown(value) => value.as_str(),
156        }
157    }
158    /// Returns all the `&str` representations of the enum members.
159    pub const fn values() -> &'static [&'static str] {
160        &[
161            "BUNDLER",
162            "CARGO",
163            "COMPOSER",
164            "DOTNET_CORE",
165            "GEMSPEC",
166            "GOBINARY",
167            "GOMOD",
168            "JAR",
169            "NODEPKG",
170            "NPM",
171            "NUGET",
172            "OS",
173            "PIP",
174            "PIPENV",
175            "POETRY",
176            "POM",
177            "PYTHONPKG",
178            "YARN",
179        ]
180    }
181}
182impl ::std::convert::AsRef<str> for PackageManager {
183    fn as_ref(&self) -> &str {
184        self.as_str()
185    }
186}
187impl PackageManager {
188    /// Parses the enum value while disallowing unknown variants.
189    ///
190    /// Unknown variants will result in an error.
191    pub fn try_parse(value: &str) -> ::std::result::Result<Self, crate::error::UnknownVariantError> {
192        match Self::from(value) {
193            #[allow(deprecated)]
194            Self::Unknown(_) => ::std::result::Result::Err(crate::error::UnknownVariantError::new(value)),
195            known => Ok(known),
196        }
197    }
198}
199impl ::std::fmt::Display for PackageManager {
200    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
201        match self {
202            PackageManager::Bundler => write!(f, "BUNDLER"),
203            PackageManager::Cargo => write!(f, "CARGO"),
204            PackageManager::Composer => write!(f, "COMPOSER"),
205            PackageManager::DotnetCore => write!(f, "DOTNET_CORE"),
206            PackageManager::Gemspec => write!(f, "GEMSPEC"),
207            PackageManager::Gobinary => write!(f, "GOBINARY"),
208            PackageManager::Gomod => write!(f, "GOMOD"),
209            PackageManager::Jar => write!(f, "JAR"),
210            PackageManager::Nodepkg => write!(f, "NODEPKG"),
211            PackageManager::Npm => write!(f, "NPM"),
212            PackageManager::Nuget => write!(f, "NUGET"),
213            PackageManager::Os => write!(f, "OS"),
214            PackageManager::Pip => write!(f, "PIP"),
215            PackageManager::Pipenv => write!(f, "PIPENV"),
216            PackageManager::Poetry => write!(f, "POETRY"),
217            PackageManager::Pom => write!(f, "POM"),
218            PackageManager::Pythonpkg => write!(f, "PYTHONPKG"),
219            PackageManager::Yarn => write!(f, "YARN"),
220            PackageManager::Unknown(value) => write!(f, "{value}"),
221        }
222    }
223}