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>A single conversation turn.</p>
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
pub struct Message {
    /// <p>The role of the participant that produced this turn. Valid values:</p>
    /// <ul>
    /// <li>
    /// <p><code>USER</code> - The user asked or said this turn.</p></li>
    /// <li>
    /// <p><code>ASSISTANT</code> - The assistant answered in this turn.</p></li>
    /// </ul>
    pub role: crate::types::MessageRole,
    /// <p>The turn's text content.</p>
    pub content: ::std::string::String,
}
impl Message {
    /// <p>The role of the participant that produced this turn. Valid values:</p>
    /// <ul>
    /// <li>
    /// <p><code>USER</code> - The user asked or said this turn.</p></li>
    /// <li>
    /// <p><code>ASSISTANT</code> - The assistant answered in this turn.</p></li>
    /// </ul>
    pub fn role(&self) -> &crate::types::MessageRole {
        &self.role
    }
    /// <p>The turn's text content.</p>
    pub fn content(&self) -> &str {
        use std::ops::Deref;
        self.content.deref()
    }
}
impl ::std::fmt::Debug for Message {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("Message");
        formatter.field("role", &self.role);
        formatter.field("content", &"*** Sensitive Data Redacted ***");
        formatter.finish()
    }
}
impl Message {
    /// Creates a new builder-style object to manufacture [`Message`](crate::types::Message).
    pub fn builder() -> crate::types::builders::MessageBuilder {
        crate::types::builders::MessageBuilder::default()
    }
}

/// A builder for [`Message`](crate::types::Message).
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
#[non_exhaustive]
pub struct MessageBuilder {
    pub(crate) role: ::std::option::Option<crate::types::MessageRole>,
    pub(crate) content: ::std::option::Option<::std::string::String>,
}
impl MessageBuilder {
    /// <p>The role of the participant that produced this turn. Valid values:</p>
    /// <ul>
    /// <li>
    /// <p><code>USER</code> - The user asked or said this turn.</p></li>
    /// <li>
    /// <p><code>ASSISTANT</code> - The assistant answered in this turn.</p></li>
    /// </ul>
    /// This field is required.
    pub fn role(mut self, input: crate::types::MessageRole) -> Self {
        self.role = ::std::option::Option::Some(input);
        self
    }
    /// <p>The role of the participant that produced this turn. Valid values:</p>
    /// <ul>
    /// <li>
    /// <p><code>USER</code> - The user asked or said this turn.</p></li>
    /// <li>
    /// <p><code>ASSISTANT</code> - The assistant answered in this turn.</p></li>
    /// </ul>
    pub fn set_role(mut self, input: ::std::option::Option<crate::types::MessageRole>) -> Self {
        self.role = input;
        self
    }
    /// <p>The role of the participant that produced this turn. Valid values:</p>
    /// <ul>
    /// <li>
    /// <p><code>USER</code> - The user asked or said this turn.</p></li>
    /// <li>
    /// <p><code>ASSISTANT</code> - The assistant answered in this turn.</p></li>
    /// </ul>
    pub fn get_role(&self) -> &::std::option::Option<crate::types::MessageRole> {
        &self.role
    }
    /// <p>The turn's text content.</p>
    /// This field is required.
    pub fn content(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
        self.content = ::std::option::Option::Some(input.into());
        self
    }
    /// <p>The turn's text content.</p>
    pub fn set_content(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
        self.content = input;
        self
    }
    /// <p>The turn's text content.</p>
    pub fn get_content(&self) -> &::std::option::Option<::std::string::String> {
        &self.content
    }
    /// Consumes the builder and constructs a [`Message`](crate::types::Message).
    /// This method will fail if any of the following fields are not set:
    /// - [`role`](crate::types::builders::MessageBuilder::role)
    /// - [`content`](crate::types::builders::MessageBuilder::content)
    pub fn build(self) -> ::std::result::Result<crate::types::Message, ::aws_smithy_types::error::operation::BuildError> {
        ::std::result::Result::Ok(crate::types::Message {
            role: self.role.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "role",
                    "role was not specified but it is required when building Message",
                )
            })?,
            content: self.content.ok_or_else(|| {
                ::aws_smithy_types::error::operation::BuildError::missing_field(
                    "content",
                    "content was not specified but it is required when building Message",
                )
            })?,
        })
    }
}
impl ::std::fmt::Debug for MessageBuilder {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        let mut formatter = f.debug_struct("MessageBuilder");
        formatter.field("role", &self.role);
        formatter.field("content", &"*** Sensitive Data Redacted ***");
        formatter.finish()
    }
}