aws-sdk-kendra 1.95.0

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

/// <p>Provides information that you can use to highlight a search result so that your users can quickly identify terms in the response.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub struct Highlight {
    /// <p>The zero-based location in the response string where the highlight starts.</p>
    pub begin_offset: i32,
    /// <p>The zero-based location in the response string where the highlight ends.</p>
    pub end_offset: i32,
    /// <p>Indicates whether the response is the best response. True if this is the best response; otherwise, false.</p>
    pub top_answer: bool,
    /// <p>The highlight type.</p>
    pub r#type: ::std::option::Option<crate::types::HighlightType>,
}
impl Highlight {
    /// <p>The zero-based location in the response string where the highlight starts.</p>
    pub fn begin_offset(&self) -> i32 {
        self.begin_offset
    }
    /// <p>The zero-based location in the response string where the highlight ends.</p>
    pub fn end_offset(&self) -> i32 {
        self.end_offset
    }
    /// <p>Indicates whether the response is the best response. True if this is the best response; otherwise, false.</p>
    pub fn top_answer(&self) -> bool {
        self.top_answer
    }
    /// <p>The highlight type.</p>
    pub fn r#type(&self) -> ::std::option::Option<&crate::types::HighlightType> {
        self.r#type.as_ref()
    }
}
impl Highlight {
    /// Creates a new builder-style object to manufacture [`Highlight`](crate::types::Highlight).
    pub fn builder() -> crate::types::builders::HighlightBuilder {
        crate::types::builders::HighlightBuilder::default()
    }
}

/// A builder for [`Highlight`](crate::types::Highlight).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
#[non_exhaustive]
pub struct HighlightBuilder {
    pub(crate) begin_offset: ::std::option::Option<i32>,
    pub(crate) end_offset: ::std::option::Option<i32>,
    pub(crate) top_answer: ::std::option::Option<bool>,
    pub(crate) r#type: ::std::option::Option<crate::types::HighlightType>,
}
impl HighlightBuilder {
    /// <p>The zero-based location in the response string where the highlight starts.</p>
    /// This field is required.
    pub fn begin_offset(mut self, input: i32) -> Self {
        self.begin_offset = ::std::option::Option::Some(input);
        self
    }
    /// <p>The zero-based location in the response string where the highlight starts.</p>
    pub fn set_begin_offset(mut self, input: ::std::option::Option<i32>) -> Self {
        self.begin_offset = input;
        self
    }
    /// <p>The zero-based location in the response string where the highlight starts.</p>
    pub fn get_begin_offset(&self) -> &::std::option::Option<i32> {
        &self.begin_offset
    }
    /// <p>The zero-based location in the response string where the highlight ends.</p>
    /// This field is required.
    pub fn end_offset(mut self, input: i32) -> Self {
        self.end_offset = ::std::option::Option::Some(input);
        self
    }
    /// <p>The zero-based location in the response string where the highlight ends.</p>
    pub fn set_end_offset(mut self, input: ::std::option::Option<i32>) -> Self {
        self.end_offset = input;
        self
    }
    /// <p>The zero-based location in the response string where the highlight ends.</p>
    pub fn get_end_offset(&self) -> &::std::option::Option<i32> {
        &self.end_offset
    }
    /// <p>Indicates whether the response is the best response. True if this is the best response; otherwise, false.</p>
    pub fn top_answer(mut self, input: bool) -> Self {
        self.top_answer = ::std::option::Option::Some(input);
        self
    }
    /// <p>Indicates whether the response is the best response. True if this is the best response; otherwise, false.</p>
    pub fn set_top_answer(mut self, input: ::std::option::Option<bool>) -> Self {
        self.top_answer = input;
        self
    }
    /// <p>Indicates whether the response is the best response. True if this is the best response; otherwise, false.</p>
    pub fn get_top_answer(&self) -> &::std::option::Option<bool> {
        &self.top_answer
    }
    /// <p>The highlight type.</p>
    pub fn r#type(mut self, input: crate::types::HighlightType) -> Self {
        self.r#type = ::std::option::Option::Some(input);
        self
    }
    /// <p>The highlight type.</p>
    pub fn set_type(mut self, input: ::std::option::Option<crate::types::HighlightType>) -> Self {
        self.r#type = input;
        self
    }
    /// <p>The highlight type.</p>
    pub fn get_type(&self) -> &::std::option::Option<crate::types::HighlightType> {
        &self.r#type
    }
    /// Consumes the builder and constructs a [`Highlight`](crate::types::Highlight).
    /// This method will fail if any of the following fields are not set:
    /// - [`begin_offset`](crate::types::builders::HighlightBuilder::begin_offset)
    /// - [`end_offset`](crate::types::builders::HighlightBuilder::end_offset)
    pub fn build(self) -> ::std::result::Result<crate::types::Highlight, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Highlight {
            begin_offset: self.begin_offset.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "begin_offset",
                    "begin_offset was not specified but it is required when building Highlight",
                )
            })?,
            end_offset: self.end_offset.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "end_offset",
                    "end_offset was not specified but it is required when building Highlight",
                )
            })?,
            top_answer: self.top_answer.unwrap_or_default(),
            r#type: self.r#type,
        })
    }
}