aws-sdk-accessanalyzer 1.106.0

AWS SDK for Access Analyzer
Documentation
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.

/// <p>A reference to a substring of a literal string in a JSON document.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Substring {
    /// <p>The start index of the substring, starting from 0.</p>
    pub start: i32,
    /// <p>The length of the substring.</p>
    pub length: i32,
}
impl Substring {
    /// <p>The start index of the substring, starting from 0.</p>
    pub fn start(&self) -> i32 {
        self.start
    }
    /// <p>The length of the substring.</p>
    pub fn length(&self) -> i32 {
        self.length
    }
}
impl Substring {
    /// Creates a new builder-style object to manufacture [`Substring`](crate::types::Substring).
    pub fn builder() -> crate::types::builders::SubstringBuilder {
        crate::types::builders::SubstringBuilder::default()
    }
}

/// A builder for [`Substring`](crate::types::Substring).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct SubstringBuilder {
    pub(crate) start: ::std::option::Option<i32>,
    pub(crate) length: ::std::option::Option<i32>,
}
impl SubstringBuilder {
    /// <p>The start index of the substring, starting from 0.</p>
    /// This field is required.
    pub fn start(mut self, input: i32) -> Self {
        self.start = ::std::option::Option::Some(input);
        self
    }
    /// <p>The start index of the substring, starting from 0.</p>
    pub fn set_start(mut self, input: ::std::option::Option<i32>) -> Self {
        self.start = input;
        self
    }
    /// <p>The start index of the substring, starting from 0.</p>
    pub fn get_start(&self) -> &::std::option::Option<i32> {
        &self.start
    }
    /// <p>The length of the substring.</p>
    /// This field is required.
    pub fn length(mut self, input: i32) -> Self {
        self.length = ::std::option::Option::Some(input);
        self
    }
    /// <p>The length of the substring.</p>
    pub fn set_length(mut self, input: ::std::option::Option<i32>) -> Self {
        self.length = input;
        self
    }
    /// <p>The length of the substring.</p>
    pub fn get_length(&self) -> &::std::option::Option<i32> {
        &self.length
    }
    /// Consumes the builder and constructs a [`Substring`](crate::types::Substring).
    /// This method will fail if any of the following fields are not set:
    /// - [`start`](crate::types::builders::SubstringBuilder::start)
    /// - [`length`](crate::types::builders::SubstringBuilder::length)
    pub fn build(self) -> ::std::result::Result<crate::types::Substring, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Substring {
            start: self.start.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "start",
                    "start was not specified but it is required when building Substring",
                )
            })?,
            length: self.length.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "length",
                    "length was not specified but it is required when building Substring",
                )
            })?,
        })
    }
}