aws-sdk-devopsagent 1.4.0

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

/// A message in a conversation, either from the user or the assistant.
#[non_exhaustive]
#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
pub enum Message {
    /// A message from the assistant.
    AssistantMessage(::std::vec::Vec<crate::types::AssistantMessageBlock>),
    /// A message from the user.
    UserMessage(::std::vec::Vec<crate::types::UserMessageBlock>),
    /// The `Unknown` variant represents cases where new union variant was received. Consider upgrading the SDK to the latest available version.
    /// An unknown enum variant
    ///
    /// _Note: If you encounter this error, consider upgrading your SDK to the latest version._
    /// The `Unknown` variant represents cases where the server sent a value that wasn't recognized
    /// by the client. This can happen when the server adds new functionality, but the client has not been updated.
    /// To investigate this, consider turning on debug logging to print the raw HTTP response.
    #[non_exhaustive]
    Unknown,
}
impl Message {
    /// Tries to convert the enum instance into [`AssistantMessage`](crate::types::Message::AssistantMessage), extracting the inner [`Vec`](::std::vec::Vec).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_assistant_message(&self) -> ::std::result::Result<&::std::vec::Vec<crate::types::AssistantMessageBlock>, &Self> {
        if let Message::AssistantMessage(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`AssistantMessage`](crate::types::Message::AssistantMessage).
    pub fn is_assistant_message(&self) -> bool {
        self.as_assistant_message().is_ok()
    }
    /// Tries to convert the enum instance into [`UserMessage`](crate::types::Message::UserMessage), extracting the inner [`Vec`](::std::vec::Vec).
    /// Returns `Err(&Self)` if it can't be converted.
    pub fn as_user_message(&self) -> ::std::result::Result<&::std::vec::Vec<crate::types::UserMessageBlock>, &Self> {
        if let Message::UserMessage(val) = &self {
            ::std::result::Result::Ok(val)
        } else {
            ::std::result::Result::Err(self)
        }
    }
    /// Returns true if this is a [`UserMessage`](crate::types::Message::UserMessage).
    pub fn is_user_message(&self) -> bool {
        self.as_user_message().is_ok()
    }
    /// Returns true if the enum instance is the `Unknown` variant.
    pub fn is_unknown(&self) -> bool {
        matches!(self, Self::Unknown)
    }
}