pub enum Data<T> {
Chat(ChatMessageCollection<T>),
Text(T),
}Expand description
An enum representing either a collection of chat messages or a single text.
Variants§
Implementations§
source§impl<T> Data<T>
impl<T> Data<T>
pub fn text(text: T) -> Self
sourcepub fn map<U, F: Fn(&T) -> U>(&self, f: F) -> Data<U>
pub fn map<U, F: Fn(&T) -> U>(&self, f: F) -> Data<U>
Maps the body of the chat messages or the text in the MessageOrText enum using the provided function.
Arguments
f- A function that takes a reference to the body of a chat message or the text and returns a value of typeU.
Returns
A new MessageOrText<U> with the body of the chat messages or the text mapped by the provided function.
sourcepub fn try_map<U, E, F: Fn(&T) -> Result<U, E>>(
&self,
f: F
) -> Result<Data<U>, E>
pub fn try_map<U, E, F: Fn(&T) -> Result<U, E>>( &self, f: F ) -> Result<Data<U>, E>
Maps the body of the chat messages or the text in the Data enum using the provided function that might fail.
Arguments
f- A function that takes a reference to the body of a chat message or the text and returns aResult<U, E>value.
Returns
A Result<Data<U>, E> with the body of the chat messages or the text mapped by the provided function.
If the provided function returns an error, the error will be propagated in the result.
source§impl Data<String>
impl Data<String>
pub fn to_chat(&self) -> ChatMessageCollection<String>
pub fn to_text(&self) -> String
sourcepub fn combine(&self, other: &Self) -> Self
pub fn combine(&self, other: &Self) -> Self
Combines two Data values into one.
If both values are Chat, the two chat collections will be combined.
If one value is Chat and the other is Text, the text will be added as a message to the chat collection.
Arguments
other- The otherDatavalue to combine with.
source§impl Data<StringTemplate>
impl Data<StringTemplate>
sourcepub async fn run<E: Executor>(
&self,
parameters: &Parameters,
executor: &E
) -> Result<E::Output, FormatAndExecuteError<E::Error>>
pub async fn run<E: Executor>( &self, parameters: &Parameters, executor: &E ) -> Result<E::Output, FormatAndExecuteError<E::Error>>
pub fn format( &self, parameters: &Parameters ) -> Result<Data<String>, StringTemplateError>
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Data<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Data<T>where T: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl<T> From<ChatMessage<T>> for Data<T>
impl<T> From<ChatMessage<T>> for Data<T>
source§fn from(chat: ChatMessage<T>) -> Self
fn from(chat: ChatMessage<T>) -> Self
source§impl<T> From<ChatMessageCollection<T>> for Data<T>
impl<T> From<ChatMessageCollection<T>> for Data<T>
source§fn from(chat: ChatMessageCollection<T>) -> Self
fn from(chat: ChatMessageCollection<T>) -> Self
Auto Trait Implementations§
impl<T> RefUnwindSafe for Data<T>where T: RefUnwindSafe,
impl<T> Send for Data<T>where T: Send,
impl<T> Sync for Data<T>where T: Sync,
impl<T> Unpin for Data<T>where T: Unpin,
impl<T> UnwindSafe for Data<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request