aws-sdk-ebs 1.118.0

AWS SDK for Amazon Elastic Block Store
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>A block of data in an Amazon Elastic Block Store snapshot.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Block {
    /// <p>The block index.</p>
    pub block_index: ::std::option::Option<i32>,
    /// <p>The block token for the block index.</p>
    pub block_token: ::std::option::Option<::std::string::String>,
}
impl Block {
    /// <p>The block index.</p>
    pub fn block_index(&self) -> ::std::option::Option<i32> {
        self.block_index
    }
    /// <p>The block token for the block index.</p>
    pub fn block_token(&self) -> ::std::option::Option<&str> {
        self.block_token.as_deref()
    }
}
static BLOCK_MEMBER_BLOCK_INDEX: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ebs#Block$BlockIndex", "com.amazonaws.ebs", "Block"),
    ::aws_smithy_schema::ShapeType::Integer,
    "BlockIndex",
    0,
);
static BLOCK_MEMBER_BLOCK_TOKEN: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_member(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ebs#Block$BlockToken", "com.amazonaws.ebs", "Block"),
    ::aws_smithy_schema::ShapeType::String,
    "BlockToken",
    1,
);
static BLOCK_SCHEMA: ::aws_smithy_schema::Schema<'static> = ::aws_smithy_schema::Schema::new_struct(
    ::aws_smithy_schema::ShapeId::from_parts("com.amazonaws.ebs#Block", "com.amazonaws.ebs", "Block"),
    ::aws_smithy_schema::ShapeType::Structure,
    &[&BLOCK_MEMBER_BLOCK_INDEX, &BLOCK_MEMBER_BLOCK_TOKEN],
);
impl Block {
    /// The schema for this shape.
    pub const SCHEMA: &'static ::aws_smithy_schema::Schema<'static> = &BLOCK_SCHEMA;
}
impl ::aws_smithy_schema::serde::SerializableStruct for Block {
    fn schema(&self) -> &::aws_smithy_schema::Schema<'_> {
        Self::SCHEMA
    }

    #[allow(unused_variables, clippy::diverging_sub_expression)]
    fn serialize_members(
        &self,
        ser: &mut dyn ::aws_smithy_schema::serde::ShapeSerializer,
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
        if let Some(ref val) = self.block_index {
            ser.write_integer(&BLOCK_MEMBER_BLOCK_INDEX, *val)?;
        }
        if let Some(ref val) = self.block_token {
            ser.write_string(&BLOCK_MEMBER_BLOCK_TOKEN, val)?;
        }
        Ok(())
    }
}
impl crate::types::builders::BlockBuilder {
    #[allow(
        unused_variables,
        unreachable_code,
        clippy::single_match,
        clippy::match_single_binding,
        clippy::diverging_sub_expression
    )]
    pub(crate) fn deserialize_members(
        &mut self,
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
    ) -> ::std::result::Result<(), ::aws_smithy_schema::serde::SerdeError> {
        deserializer.read_struct(&BLOCK_SCHEMA, &mut |member, deser| {
            match member.member_index() {
                Some(0) => {
                    if deser.is_null() {
                        deser.read_null()?;
                    } else {
                        self.block_index = Some(deser.read_integer(member)?);
                    }
                }
                Some(1) => {
                    if deser.is_null() {
                        deser.read_null()?;
                    } else {
                        self.block_token = Some(deser.read_string(member)?);
                    }
                }
                _ => {}
            }
            Ok(())
        })
    }
}

impl Block {
    /// Deserializes this structure from a [`ShapeDeserializer`].
    pub fn deserialize(
        deserializer: &mut dyn ::aws_smithy_schema::serde::ShapeDeserializer,
    ) -> ::std::result::Result<Self, ::aws_smithy_schema::serde::SerdeError> {
        let mut builder = Self::builder();
        builder.deserialize_members(deserializer)?;
        Ok(builder.build())
    }
}
impl Block {
    /// Creates a new builder-style object to manufacture [`Block`](crate::types::Block).
    pub fn builder() -> crate::types::builders::BlockBuilder {
        crate::types::builders::BlockBuilder::default()
    }
}

/// A builder for [`Block`](crate::types::Block).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct BlockBuilder {
    pub(crate) block_index: ::std::option::Option<i32>,
    pub(crate) block_token: ::std::option::Option<::std::string::String>,
}
impl BlockBuilder {
    /// <p>The block index.</p>
    pub fn block_index(mut self, input: i32) -> Self {
        self.block_index = ::std::option::Option::Some(input);
        self
    }
    /// <p>The block index.</p>
    pub fn set_block_index(mut self, input: ::std::option::Option<i32>) -> Self {
        self.block_index = input;
        self
    }
    /// <p>The block index.</p>
    pub fn get_block_index(&self) -> &::std::option::Option<i32> {
        &self.block_index
    }
    /// <p>The block token for the block index.</p>
    pub fn block_token(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.block_token = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The block token for the block index.</p>
    pub fn set_block_token(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.block_token = input;
        self
    }
    /// <p>The block token for the block index.</p>
    pub fn get_block_token(&self) -> &::std::option::Option<::std::string::String> {
        &self.block_token
    }
    /// Consumes the builder and constructs a [`Block`](crate::types::Block).
    pub fn build(self) -> crate::types::Block {
        crate::types::Block {
            block_index: self.block_index,
            block_token: self.block_token,
        }
    }
}