Struct InputMedia

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

Construct and send albums.

Implementations§

Source§

impl InputMedia

Source

pub fn fmt_entities(self, entities: Vec<MessageEntity>) -> Self

The formatting entities within the caption (such as bold, italics, etc.).

Source

pub fn reply_to(self, reply_to: Option<i32>) -> Self

The album identifier to which this album should reply to, if any.

Otherwise, this album will not be a reply to any other.

Only the reply_to from the first media is used.

Source

pub fn photo(self, file: Uploaded) -> Self

Include the uploaded file as a photo in the album.

The Telegram server will compress the image and convert it to JPEG format if necessary.

The text will be the caption of the photo, which may be empty for no caption.

Source

pub fn photo_url(self, url: impl Into<String>) -> Self

Include an external photo in the album.

The Telegram server will download and compress the image and convert it to JPEG format if necessary.

The text will be the caption of the photo, which may be empty for no caption.

Source

pub fn document(self, file: Uploaded) -> Self

Include the uploaded file as a document in the album.

You can use this to send videos, stickers, audios, or uncompressed photos.

The text will be the caption of the document, which may be empty for no caption.

Source

pub fn thumbnail(self, thumb: Uploaded) -> Self

Include the video file with thumb in the album.

The text will be the caption of the document, which may be empty for no caption.

§Examples
async fn f(client: &mut grammers_client::Client) -> Result<(), Box<dyn std::error::Error>> {
    use grammers_client::{InputMedia};

    let video = client.upload_file("video.mp4").await?;
    let thumb = client.upload_file("thumb.png").await?;
    let media = InputMedia::caption("").document(video).thumbnail(thumb);
    Ok(())
}
Source

pub fn document_url(self, url: impl Into<String>) -> Self

Include an external file as a document in the album.

You can use this to send videos, stickers, audios, or uncompressed photos.

The Telegram server will be the one that downloads and includes the document as media.

The text will be the caption of the document, which may be empty for no caption.

Source

pub fn attribute(self, attr: Attribute) -> Self

Add additional attributes to the media.

This must be called after setting a file.

§Examples
use std::time::Duration;
use grammers_client::{types::Attribute, InputMedia};

let media = InputMedia::caption("").document(audio).attribute(
   Attribute::Audio {
       duration: Duration::new(123, 0),
       title: Some("Hello".to_string()),
       performer: Some("World".to_string()),
   }
);
Source

pub fn copy_media(self, media: &Media) -> Self

Copy media from an existing message.

You can use this to send media from another message without re-uploading it.

Source

pub fn file(self, file: Uploaded) -> Self

Include the uploaded file as a document file in the album.

You can use this to send any type of media as a simple document file.

The text will be the caption of the file, which may be empty for no caption.

Source

pub fn media_ttl(self, seconds: i32) -> Self

Change the media’s Time To Live (TTL).

For example, this enables you to send a photo that can only be viewed for a certain amount of seconds before it expires.

Not all media supports this feature.

This method should be called before setting any media, else it won’t have any effect.

Source

pub fn mime_type(self, mime_type: &str) -> Self

Change the media’s mime type.

This method will override the mime type that would otherwise be automatically inferred from the extension of the used file

If no mime type is set and it cannot be inferred, the mime type will be “application/octet-stream”.

This method should be called before setting any media, else it won’t have any effect.

Source

pub fn caption<T: AsRef<str>>(s: T) -> Self

Builds a new media using the given plaintext as the caption contents.

Trait Implementations§

Source§

impl Default for InputMedia

Source§

fn default() -> InputMedia

Returns the “default value” for a type. Read more

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

Source§

type Output = T

Should always be Self
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.