Enum aws_sdk_grafana::model::PermissionType
source · #[non_exhaustive]
pub enum PermissionType {
CustomerManaged,
ServiceManaged,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against PermissionType
, it is important to ensure
your code is forward-compatible. That is, if a match arm handles a case for a
feature that is supported by the service but has not been represented as an enum
variant in a current version of SDK, your code should continue to work when you
upgrade SDK to a future version in which the enum does include a variant for that
feature.
Here is an example of how you can make a match expression forward-compatible:
# let permissiontype = unimplemented!();
match permissiontype {
PermissionType::CustomerManaged => { /* ... */ },
PermissionType::ServiceManaged => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when permissiontype
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant PermissionType::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
PermissionType::Unknown(UnknownVariantValue("NewFeature".to_owned()))
and calling as_str
on it yields "NewFeature"
.
This match expression is forward-compatible when executed with a newer
version of SDK where the variant PermissionType::NewFeature
is defined.
Specifically, when permissiontype
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on PermissionType::NewFeature
also yielding "NewFeature"
.
Explicitly matching on the Unknown
variant should
be avoided for two reasons:
- The inner data
UnknownVariantValue
is opaque, and no further information can be extracted. - It might inadvertently shadow other intended match arms.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
CustomerManaged
Customer Managed
ServiceManaged
Service Managed
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl PermissionType
impl PermissionType
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the &str
value of the enum member.
Examples found in repository?
More examples
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
pub fn serialize_structure_crate_input_create_workspace_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateWorkspaceInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_1) = &input.account_access_type {
object.key("accountAccessType").string(var_1.as_str());
}
if let Some(var_2) = &input.authentication_providers {
let mut array_3 = object.key("authenticationProviders").start_array();
for item_4 in var_2 {
{
array_3.value().string(item_4.as_str());
}
}
array_3.finish();
}
if let Some(var_5) = &input.client_token {
object.key("clientToken").string(var_5.as_str());
}
if let Some(var_6) = &input.organization_role_name {
object.key("organizationRoleName").string(var_6.as_str());
}
if let Some(var_7) = &input.permission_type {
object.key("permissionType").string(var_7.as_str());
}
if let Some(var_8) = &input.stack_set_name {
object.key("stackSetName").string(var_8.as_str());
}
if let Some(var_9) = &input.tags {
#[allow(unused_mut)]
let mut object_10 = object.key("tags").start_object();
for (key_11, value_12) in var_9 {
{
object_10.key(key_11.as_str()).string(value_12.as_str());
}
}
object_10.finish();
}
if let Some(var_13) = &input.workspace_data_sources {
let mut array_14 = object.key("workspaceDataSources").start_array();
for item_15 in var_13 {
{
array_14.value().string(item_15.as_str());
}
}
array_14.finish();
}
if let Some(var_16) = &input.workspace_description {
object.key("workspaceDescription").string(var_16.as_str());
}
if let Some(var_17) = &input.workspace_name {
object.key("workspaceName").string(var_17.as_str());
}
if let Some(var_18) = &input.workspace_notification_destinations {
let mut array_19 = object
.key("workspaceNotificationDestinations")
.start_array();
for item_20 in var_18 {
{
array_19.value().string(item_20.as_str());
}
}
array_19.finish();
}
if let Some(var_21) = &input.workspace_organizational_units {
let mut array_22 = object.key("workspaceOrganizationalUnits").start_array();
for item_23 in var_21 {
{
array_22.value().string(item_23.as_str());
}
}
array_22.finish();
}
if let Some(var_24) = &input.workspace_role_arn {
object.key("workspaceRoleArn").string(var_24.as_str());
}
Ok(())
}
pub fn serialize_structure_crate_input_create_workspace_api_key_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateWorkspaceApiKeyInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_25) = &input.key_name {
object.key("keyName").string(var_25.as_str());
}
if let Some(var_26) = &input.key_role {
object.key("keyRole").string(var_26.as_str());
}
if let Some(var_27) = &input.seconds_to_live {
object.key("secondsToLive").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_27).into()),
);
}
Ok(())
}
pub fn serialize_structure_crate_input_tag_resource_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::TagResourceInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_28) = &input.tags {
#[allow(unused_mut)]
let mut object_29 = object.key("tags").start_object();
for (key_30, value_31) in var_28 {
{
object_29.key(key_30.as_str()).string(value_31.as_str());
}
}
object_29.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_update_permissions_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::UpdatePermissionsInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_32) = &input.update_instruction_batch {
let mut array_33 = object.key("updateInstructionBatch").start_array();
for item_34 in var_32 {
{
#[allow(unused_mut)]
let mut object_35 = array_33.value().start_object();
crate::json_ser::serialize_structure_crate_model_update_instruction(
&mut object_35,
item_34,
)?;
object_35.finish();
}
}
array_33.finish();
}
Ok(())
}
pub fn serialize_structure_crate_input_update_workspace_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::UpdateWorkspaceInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_36) = &input.account_access_type {
object.key("accountAccessType").string(var_36.as_str());
}
if let Some(var_37) = &input.organization_role_name {
object.key("organizationRoleName").string(var_37.as_str());
}
if let Some(var_38) = &input.permission_type {
object.key("permissionType").string(var_38.as_str());
}
if let Some(var_39) = &input.stack_set_name {
object.key("stackSetName").string(var_39.as_str());
}
if let Some(var_40) = &input.workspace_data_sources {
let mut array_41 = object.key("workspaceDataSources").start_array();
for item_42 in var_40 {
{
array_41.value().string(item_42.as_str());
}
}
array_41.finish();
}
if let Some(var_43) = &input.workspace_description {
object.key("workspaceDescription").string(var_43.as_str());
}
if let Some(var_44) = &input.workspace_name {
object.key("workspaceName").string(var_44.as_str());
}
if let Some(var_45) = &input.workspace_notification_destinations {
let mut array_46 = object
.key("workspaceNotificationDestinations")
.start_array();
for item_47 in var_45 {
{
array_46.value().string(item_47.as_str());
}
}
array_46.finish();
}
if let Some(var_48) = &input.workspace_organizational_units {
let mut array_49 = object.key("workspaceOrganizationalUnits").start_array();
for item_50 in var_48 {
{
array_49.value().string(item_50.as_str());
}
}
array_49.finish();
}
if let Some(var_51) = &input.workspace_role_arn {
object.key("workspaceRoleArn").string(var_51.as_str());
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for PermissionType
impl AsRef<str> for PermissionType
source§impl Clone for PermissionType
impl Clone for PermissionType
source§fn clone(&self) -> PermissionType
fn clone(&self) -> PermissionType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PermissionType
impl Debug for PermissionType
source§impl From<&str> for PermissionType
impl From<&str> for PermissionType
source§impl FromStr for PermissionType
impl FromStr for PermissionType
source§impl Hash for PermissionType
impl Hash for PermissionType
source§impl Ord for PermissionType
impl Ord for PermissionType
source§fn cmp(&self, other: &PermissionType) -> Ordering
fn cmp(&self, other: &PermissionType) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<PermissionType> for PermissionType
impl PartialEq<PermissionType> for PermissionType
source§fn eq(&self, other: &PermissionType) -> bool
fn eq(&self, other: &PermissionType) -> bool
source§impl PartialOrd<PermissionType> for PermissionType
impl PartialOrd<PermissionType> for PermissionType
source§fn partial_cmp(&self, other: &PermissionType) -> Option<Ordering>
fn partial_cmp(&self, other: &PermissionType) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Eq for PermissionType
impl StructuralEq for PermissionType
impl StructuralPartialEq for PermissionType
Auto Trait Implementations§
impl RefUnwindSafe for PermissionType
impl Send for PermissionType
impl Sync for PermissionType
impl Unpin for PermissionType
impl UnwindSafe for PermissionType
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.