aws-sdk-context 1.0.0

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

/// <p>Maps a span of the answer to the entities that support it. The span is answer\[startIndex:endIndex\].</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Citation {
    /// <p>The character offset in <code>answer</code> where the cited span begins.</p>
    pub start_index: i32,
    /// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
    pub end_index: i32,
    /// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
    pub references: ::std::vec::Vec<crate::types::Reference>,
}
impl Citation {
    /// <p>The character offset in <code>answer</code> where the cited span begins.</p>
    pub fn start_index(&self) -> i32 {
        self.start_index
    }
    /// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
    pub fn end_index(&self) -> i32 {
        self.end_index
    }
    /// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
    pub fn references(&self) -> &[crate::types::Reference] {
        use std::ops::Deref;
        self.references.deref()
    }
}
impl Citation {
    /// Creates a new builder-style object to manufacture [`Citation`](crate::types::Citation).
    pub fn builder() -> crate::types::builders::CitationBuilder {
        crate::types::builders::CitationBuilder::default()
    }
}

/// A builder for [`Citation`](crate::types::Citation).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct CitationBuilder {
    pub(crate) start_index: ::std::option::Option<i32>,
    pub(crate) end_index: ::std::option::Option<i32>,
    pub(crate) references: ::std::option::Option<::std::vec::Vec<crate::types::Reference>>,
}
impl CitationBuilder {
    /// <p>The character offset in <code>answer</code> where the cited span begins.</p>
    /// This field is required.
    pub fn start_index(mut self, input: i32) -> Self {
        self.start_index = ::std::option::Option::Some(input);
        self
    }
    /// <p>The character offset in <code>answer</code> where the cited span begins.</p>
    pub fn set_start_index(mut self, input: ::std::option::Option<i32>) -> Self {
        self.start_index = input;
        self
    }
    /// <p>The character offset in <code>answer</code> where the cited span begins.</p>
    pub fn get_start_index(&self) -> &::std::option::Option<i32> {
        &self.start_index
    }
    /// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
    /// This field is required.
    pub fn end_index(mut self, input: i32) -> Self {
        self.end_index = ::std::option::Option::Some(input);
        self
    }
    /// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
    pub fn set_end_index(mut self, input: ::std::option::Option<i32>) -> Self {
        self.end_index = input;
        self
    }
    /// <p>The character offset in <code>answer</code> where the cited span ends (exclusive).</p>
    pub fn get_end_index(&self) -> &::std::option::Option<i32> {
        &self.end_index
    }
    /// Appends an item to `references`.
    ///
    /// To override the contents of this collection use [`set_references`](Self::set_references).
    ///
    /// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
    pub fn references(mut self, input: crate::types::Reference) -> Self {
        let mut v = self.references.unwrap_or_default();
        v.push(input);
        self.references = ::std::option::Option::Some(v);
        self
    }
    /// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
    pub fn set_references(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Reference>>) -> Self {
        self.references = input;
        self
    }
    /// <p>The entities in retrievedContext that support the span, referenced by identity.</p>
    pub fn get_references(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Reference>> {
        &self.references
    }
    /// Consumes the builder and constructs a [`Citation`](crate::types::Citation).
    /// This method will fail if any of the following fields are not set:
    /// - [`start_index`](crate::types::builders::CitationBuilder::start_index)
    /// - [`end_index`](crate::types::builders::CitationBuilder::end_index)
    /// - [`references`](crate::types::builders::CitationBuilder::references)
    pub fn build(self) -> ::std::result::Result<crate::types::Citation, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Citation {
            start_index: self.start_index.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "start_index",
                    "start_index was not specified but it is required when building Citation",
                )
            })?,
            end_index: self.end_index.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "end_index",
                    "end_index was not specified but it is required when building Citation",
                )
            })?,
            references: self.references.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "references",
                    "references was not specified but it is required when building Citation",
                )
            })?,
        })
    }
}