aws-sdk-connectscheduling 1.2.0

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

/// <p>A length of time, expressed as a value and the unit it is counted in.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Duration {
    /// <p>The number of units of time. You can use a negative value to report an overdrawn balance. The value must be within 876,000 hours (100 years) of zero: at most 52,560,000 <code>MINUTES</code>, 876,000 <code>HOURS</code>, or 36,500 <code>DAYS</code>.</p>
    pub value: i32,
    /// <p>The unit the value is counted in.</p>
    pub unit: crate::types::DurationUnit,
}
impl Duration {
    /// <p>The number of units of time. You can use a negative value to report an overdrawn balance. The value must be within 876,000 hours (100 years) of zero: at most 52,560,000 <code>MINUTES</code>, 876,000 <code>HOURS</code>, or 36,500 <code>DAYS</code>.</p>
    pub fn value(&self) -> i32 {
        self.value
    }
    /// <p>The unit the value is counted in.</p>
    pub fn unit(&self) -> &crate::types::DurationUnit {
        &self.unit
    }
}
impl Duration {
    /// Creates a new builder-style object to manufacture [`Duration`](crate::types::Duration).
    pub fn builder() -> crate::types::builders::DurationBuilder {
        crate::types::builders::DurationBuilder::default()
    }
}

/// A builder for [`Duration`](crate::types::Duration).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct DurationBuilder {
    pub(crate) value: ::std::option::Option<i32>,
    pub(crate) unit: ::std::option::Option<crate::types::DurationUnit>,
}
impl DurationBuilder {
    /// <p>The number of units of time. You can use a negative value to report an overdrawn balance. The value must be within 876,000 hours (100 years) of zero: at most 52,560,000 <code>MINUTES</code>, 876,000 <code>HOURS</code>, or 36,500 <code>DAYS</code>.</p>
    /// This field is required.
    pub fn value(mut self, input: i32) -> Self {
        self.value = ::std::option::Option::Some(input);
        self
    }
    /// <p>The number of units of time. You can use a negative value to report an overdrawn balance. The value must be within 876,000 hours (100 years) of zero: at most 52,560,000 <code>MINUTES</code>, 876,000 <code>HOURS</code>, or 36,500 <code>DAYS</code>.</p>
    pub fn set_value(mut self, input: ::std::option::Option<i32>) -> Self {
        self.value = input;
        self
    }
    /// <p>The number of units of time. You can use a negative value to report an overdrawn balance. The value must be within 876,000 hours (100 years) of zero: at most 52,560,000 <code>MINUTES</code>, 876,000 <code>HOURS</code>, or 36,500 <code>DAYS</code>.</p>
    pub fn get_value(&self) -> &::std::option::Option<i32> {
        &self.value
    }
    /// <p>The unit the value is counted in.</p>
    /// This field is required.
    pub fn unit(mut self, input: crate::types::DurationUnit) -> Self {
        self.unit = ::std::option::Option::Some(input);
        self
    }
    /// <p>The unit the value is counted in.</p>
    pub fn set_unit(mut self, input: ::std::option::Option<crate::types::DurationUnit>) -> Self {
        self.unit = input;
        self
    }
    /// <p>The unit the value is counted in.</p>
    pub fn get_unit(&self) -> &::std::option::Option<crate::types::DurationUnit> {
        &self.unit
    }
    /// Consumes the builder and constructs a [`Duration`](crate::types::Duration).
    /// This method will fail if any of the following fields are not set:
    /// - [`value`](crate::types::builders::DurationBuilder::value)
    /// - [`unit`](crate::types::builders::DurationBuilder::unit)
    pub fn build(self) -> ::std::result::Result<crate::types::Duration, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Duration {
            value: self.value.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "value",
                    "value was not specified but it is required when building Duration",
                )
            })?,
            unit: self.unit.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "unit",
                    "unit was not specified but it is required when building Duration",
                )
            })?,
        })
    }
}