Skip to main content

Response

Struct Response 

Source
pub struct Response { /* private fields */ }
Expand description

Unified bot response builder

Represents a response that can be sent back to any platform. Each platform adapter converts this to platform-specific format.

Implementations§

Source§

impl Response

Source

pub fn empty() -> Self

Create an empty response (no reply)

Source

pub fn text(content: impl Into<String>) -> Self

Create a text response

Source

pub fn acknowledge() -> Self

Create an acknowledgement response (deferred)

Source

pub fn embed(embed: Embed) -> Self

Create a response with an embed

Source

pub fn with_embed(self, embed: Embed) -> Self

Add an embed to this response

Source

pub fn with_components(self, components: Vec<Component>) -> Self

Add components (buttons, select menus) to this response

Source

pub fn ephemeral(self) -> Self

Make this response ephemeral (only visible to the user)

Source

pub fn file(file: File) -> Self

Create a file response

Source

pub fn with_filename(self, name: impl Into<String>) -> Self

Set the filename for a file response

Source

pub fn with_caption(self, caption: impl Into<String>) -> Self

Set the caption for a file response

Source

pub fn is_empty(&self) -> bool

Check if this is an empty response

Source

pub fn is_acknowledge(&self) -> bool

Check if this is an acknowledge response

Source

pub fn content(&self) -> Option<&str>

Get response content if this is a text response

Source

pub fn embeds(&self) -> &[Embed]

Get embeds if this is a text response

Source

pub fn components(&self) -> &[Component]

Get components if this is a text response

Source

pub fn is_ephemeral(&self) -> bool

Check if this response is ephemeral

Source

pub fn is_file(&self) -> bool

Check if this is a file response

Source

pub fn take_file(&mut self) -> Option<FileResponse>

Take the file response data, leaving Empty in its place

This consumes the file data, so it can only be called once.

Trait Implementations§

Source§

impl IntoResponse for Response

Source§

fn into_response(self) -> Response

Convert this type into a bot response

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ChatActionSenderBounds for T
where T: Send + Sync + ?Sized,