[][src]Struct egg_mode::media::UploadBuilder

pub struct UploadBuilder<'a> { /* fields omitted */ }

Represents a media upload before it is sent.

UploadBuilder is the entry point to uploading media to Twitter. It allows you to configure an upload and set the proper metadata.

To begin setting up an upload, call new with your data and its media type. (Convenience functions to create Mime instances for types Twitter is known to accept are available in the media_types module.) With that, you can configure the upload, and finally start the process using the call method. See a basic example of using UploadBuilder to upload an image and attach it to a Tweet in the module documentation.

To see more precise specifications for what media formats Twitter supports (resolution, file size, etc), see their API documentation. Note that UploadBuilder automatically sets the underlying media_category to tweet_gif or tweet_video for media_types of "image/gif" and "video/mp4" respectively. (Note that these are returned by media_types::image_gif and media_types::video_mp4 as a convenience.)

The lifetime parameter on UploadBuilder and UploadFuture is based on the data you hand to new and alt_text. Because they use std::borrow::Cow internally, if you hand them owned data (Vec or String), the resulting UploadFuture will have lifetime 'static.

Methods

impl<'a> UploadBuilder<'a>[src]

pub fn new<V: Into<Cow<'a, [u8]>>>(
    data: V,
    media_type: Mime
) -> UploadBuilder<'a>
[src]

Creates a new instance of UploadBuilder with the given data and media type.

For convenience functions to get known media_types that Twitter will accept, see the media_types module.

pub fn chunk_size(self, chunk_size: usize) -> Self[src]

Sets how many bytes to upload in one network call. By default this is set to 512 KiB.

UploadFuture uses Twitter's chunked media upload under-the-hood, and this allows you to set the size of each chunk. With a smaller chunk size, Twitter can "save" the data more often. However, there's also network overhead, since each chunk needs a separate HTTP request. Larger chunk sizes are better for stable network conditions, where you can reasonably expect a large upload to succeed. Note that once the UploadFuture is created, the chunk size cannot be changed.

pub fn alt_text<S: Into<Cow<'a, str>>>(self, alt_text: S) -> Self[src]

Applies the given alt text to the media when the upload is finished.

pub fn call(self, token: &Token) -> UploadFuture<'a>[src]

Starts the upload process and returns a Future that represents it.

Auto Trait Implementations

impl<'a> Send for UploadBuilder<'a>

impl<'a> Sync for UploadBuilder<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T> Same<T> for T

type Output = T

Should always be Self