FileBuilder

Struct FileBuilder 

Source
pub struct FileBuilder<'a, ExternalId> { /* private fields */ }
Expand description

Build an File block

Allows you to construct safely, with compile-time checks on required setter methods.

§Required Methods

FileBuilder::build() is only available if these methods have been called:

  • external_id
  • source

§Example

use slack_blocks::{blocks::File, elems::Image, text::ToSlackPlaintext};

let my_file_id: String = {
  // use Slack Web API: files.remote.add to upload a file
};

let block = File::builder().external_id(my_file_id).build();

Implementations§

Source§

impl<'a, Ext> FileBuilder<'a, Ext>

Source

pub fn new() -> Self

Create a new FileBuilder

Source

pub fn external_id<S>(self, external_id: S) -> FileBuilder<'a, Set<external_id>>
where S: Into<Cow<'a, str>>,

Set external_id (Required)

The external unique ID for a remote file 🔗.

Source

pub fn block_id<S>(self, block_id: S) -> Self
where S: Into<Cow<'a, str>>,

Set block_id (Optional)

A string acting as a unique identifier for a block.

You can use this block_id when you receive an interaction payload to identify the source of the action 🔗.

If not specified, a block_id will be generated.

Maximum length for this field is 255 characters.

Source§

impl<'a> FileBuilder<'a, Set<external_id>>

Source

pub fn build(self) -> File<'a>

All done building, now give me a darn actions block!

no method name 'build' found for struct 'FileBuilder<...>'? Make sure all required setter methods have been called. See docs for FileBuilder.

use slack_blocks::blocks::File;

let foo = File::builder().build(); // Won't compile!
use slack_blocks::{blocks::File,
                   compose::text::ToSlackPlaintext,
                   elems::Image};

let my_file_id: String = {
  // use Slack Web API: files.remote.add to upload a file
};

let block = File::builder().external_id(my_file_id).build();

Trait Implementations§

Source§

impl<'a, ExternalId: Debug> Debug for FileBuilder<'a, ExternalId>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, ExternalId> Freeze for FileBuilder<'a, ExternalId>

§

impl<'a, ExternalId> RefUnwindSafe for FileBuilder<'a, ExternalId>
where ExternalId: RefUnwindSafe,

§

impl<'a, ExternalId> Send for FileBuilder<'a, ExternalId>
where ExternalId: Send,

§

impl<'a, ExternalId> Sync for FileBuilder<'a, ExternalId>
where ExternalId: Sync,

§

impl<'a, ExternalId> Unpin for FileBuilder<'a, ExternalId>
where ExternalId: Unpin,

§

impl<'a, ExternalId> UnwindSafe for FileBuilder<'a, ExternalId>
where ExternalId: UnwindSafe,

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> IntoChild for T

Source§

fn into_child(self) -> Self

Available on crate feature blox only.
Identity function
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> ErasedDestructor for T
where T: 'static,