Enum aws_sdk_lambda::model::EventSourcePosition
source · #[non_exhaustive]
pub enum EventSourcePosition {
AtTimestamp,
Latest,
TrimHorizon,
Unknown(UnknownVariantValue),
}
Expand description
When writing a match expression against EventSourcePosition
, 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 eventsourceposition = unimplemented!();
match eventsourceposition {
EventSourcePosition::AtTimestamp => { /* ... */ },
EventSourcePosition::Latest => { /* ... */ },
EventSourcePosition::TrimHorizon => { /* ... */ },
other @ _ if other.as_str() == "NewFeature" => { /* handles a case for `NewFeature` */ },
_ => { /* ... */ },
}
The above code demonstrates that when eventsourceposition
represents
NewFeature
, the execution path will lead to the second last match arm,
even though the enum does not contain a variant EventSourcePosition::NewFeature
in the current version of SDK. The reason is that the variable other
,
created by the @
operator, is bound to
EventSourcePosition::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 EventSourcePosition::NewFeature
is defined.
Specifically, when eventsourceposition
represents NewFeature
,
the execution path will hit the second last match arm as before by virtue of
calling as_str
on EventSourcePosition::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
AtTimestamp
Latest
TrimHorizon
Unknown(UnknownVariantValue)
Unknown
contains new variants that have been added since this code was generated.
Implementations§
source§impl EventSourcePosition
impl EventSourcePosition
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
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
pub fn serialize_structure_crate_input_create_event_source_mapping_input(
object: &mut aws_smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CreateEventSourceMappingInput,
) -> Result<(), aws_smithy_http::operation::error::SerializationError> {
if let Some(var_24) = &input.amazon_managed_kafka_event_source_config {
#[allow(unused_mut)]
let mut object_25 = object
.key("AmazonManagedKafkaEventSourceConfig")
.start_object();
crate::json_ser::serialize_structure_crate_model_amazon_managed_kafka_event_source_config(
&mut object_25,
var_24,
)?;
object_25.finish();
}
if let Some(var_26) = &input.batch_size {
object.key("BatchSize").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_26).into()),
);
}
if let Some(var_27) = &input.bisect_batch_on_function_error {
object.key("BisectBatchOnFunctionError").boolean(*var_27);
}
if let Some(var_28) = &input.destination_config {
#[allow(unused_mut)]
let mut object_29 = object.key("DestinationConfig").start_object();
crate::json_ser::serialize_structure_crate_model_destination_config(
&mut object_29,
var_28,
)?;
object_29.finish();
}
if let Some(var_30) = &input.enabled {
object.key("Enabled").boolean(*var_30);
}
if let Some(var_31) = &input.event_source_arn {
object.key("EventSourceArn").string(var_31.as_str());
}
if let Some(var_32) = &input.filter_criteria {
#[allow(unused_mut)]
let mut object_33 = object.key("FilterCriteria").start_object();
crate::json_ser::serialize_structure_crate_model_filter_criteria(&mut object_33, var_32)?;
object_33.finish();
}
if let Some(var_34) = &input.function_name {
object.key("FunctionName").string(var_34.as_str());
}
if let Some(var_35) = &input.function_response_types {
let mut array_36 = object.key("FunctionResponseTypes").start_array();
for item_37 in var_35 {
{
array_36.value().string(item_37.as_str());
}
}
array_36.finish();
}
if let Some(var_38) = &input.maximum_batching_window_in_seconds {
object.key("MaximumBatchingWindowInSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_38).into()),
);
}
if let Some(var_39) = &input.maximum_record_age_in_seconds {
object.key("MaximumRecordAgeInSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_39).into()),
);
}
if let Some(var_40) = &input.maximum_retry_attempts {
object.key("MaximumRetryAttempts").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_40).into()),
);
}
if let Some(var_41) = &input.parallelization_factor {
object.key("ParallelizationFactor").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_41).into()),
);
}
if let Some(var_42) = &input.queues {
let mut array_43 = object.key("Queues").start_array();
for item_44 in var_42 {
{
array_43.value().string(item_44.as_str());
}
}
array_43.finish();
}
if let Some(var_45) = &input.self_managed_event_source {
#[allow(unused_mut)]
let mut object_46 = object.key("SelfManagedEventSource").start_object();
crate::json_ser::serialize_structure_crate_model_self_managed_event_source(
&mut object_46,
var_45,
)?;
object_46.finish();
}
if let Some(var_47) = &input.self_managed_kafka_event_source_config {
#[allow(unused_mut)]
let mut object_48 = object
.key("SelfManagedKafkaEventSourceConfig")
.start_object();
crate::json_ser::serialize_structure_crate_model_self_managed_kafka_event_source_config(
&mut object_48,
var_47,
)?;
object_48.finish();
}
if let Some(var_49) = &input.source_access_configurations {
let mut array_50 = object.key("SourceAccessConfigurations").start_array();
for item_51 in var_49 {
{
#[allow(unused_mut)]
let mut object_52 = array_50.value().start_object();
crate::json_ser::serialize_structure_crate_model_source_access_configuration(
&mut object_52,
item_51,
)?;
object_52.finish();
}
}
array_50.finish();
}
if let Some(var_53) = &input.starting_position {
object.key("StartingPosition").string(var_53.as_str());
}
if let Some(var_54) = &input.starting_position_timestamp {
object
.key("StartingPositionTimestamp")
.date_time(var_54, aws_smithy_types::date_time::Format::EpochSeconds)?;
}
if let Some(var_55) = &input.topics {
let mut array_56 = object.key("Topics").start_array();
for item_57 in var_55 {
{
array_56.value().string(item_57.as_str());
}
}
array_56.finish();
}
if let Some(var_58) = &input.tumbling_window_in_seconds {
object.key("TumblingWindowInSeconds").number(
#[allow(clippy::useless_conversion)]
aws_smithy_types::Number::NegInt((*var_58).into()),
);
}
Ok(())
}
Trait Implementations§
source§impl AsRef<str> for EventSourcePosition
impl AsRef<str> for EventSourcePosition
source§impl Clone for EventSourcePosition
impl Clone for EventSourcePosition
source§fn clone(&self) -> EventSourcePosition
fn clone(&self) -> EventSourcePosition
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for EventSourcePosition
impl Debug for EventSourcePosition
source§impl From<&str> for EventSourcePosition
impl From<&str> for EventSourcePosition
source§impl FromStr for EventSourcePosition
impl FromStr for EventSourcePosition
source§impl Hash for EventSourcePosition
impl Hash for EventSourcePosition
source§impl Ord for EventSourcePosition
impl Ord for EventSourcePosition
source§fn cmp(&self, other: &EventSourcePosition) -> Ordering
fn cmp(&self, other: &EventSourcePosition) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq<EventSourcePosition> for EventSourcePosition
impl PartialEq<EventSourcePosition> for EventSourcePosition
source§fn eq(&self, other: &EventSourcePosition) -> bool
fn eq(&self, other: &EventSourcePosition) -> bool
source§impl PartialOrd<EventSourcePosition> for EventSourcePosition
impl PartialOrd<EventSourcePosition> for EventSourcePosition
source§fn partial_cmp(&self, other: &EventSourcePosition) -> Option<Ordering>
fn partial_cmp(&self, other: &EventSourcePosition) -> 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 EventSourcePosition
impl StructuralEq for EventSourcePosition
impl StructuralPartialEq for EventSourcePosition
Auto Trait Implementations§
impl RefUnwindSafe for EventSourcePosition
impl Send for EventSourcePosition
impl Sync for EventSourcePosition
impl Unpin for EventSourcePosition
impl UnwindSafe for EventSourcePosition
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.