Skip to main content

InputMedia

Struct InputMedia 

Source
pub struct InputMedia<'a> { /* private fields */ }
Expand description

A file to send, with its kind and the options that kind takes.

Create one with a constructor such as photo and pass it to a send or edit method. The setters below apply only to the kinds that use them, and the others ignore them.

Implementations§

Source§

impl<'a> InputMedia<'a>

Source

pub fn photo(photo: impl Into<FileSource<'a>>) -> Self

Creates a photo.

Source

pub fn live_photo( photo: impl Into<FileSource<'a>>, video: impl Into<FileSource<'a>>, ) -> Self

Creates a live photo: a still photo with the video that plays when it’s held.

Source

pub fn video(video: impl Into<FileSource<'a>>) -> Self

Creates a video.

Source

pub fn animation(animation: impl Into<FileSource<'a>>) -> Self

Creates a GIF or a silent looping video.

Source

pub fn audio(audio: impl Into<FileSource<'a>>) -> Self

Creates an audio file, shown in the music player.

Source

pub fn voice(voice: impl Into<FileSource<'a>>) -> Self

Creates a voice note.

Source

pub fn document(document: impl Into<FileSource<'a>>) -> Self

Creates a file sent as a document.

Source

pub fn video_note(video_note: impl Into<FileSource<'a>>) -> Self

Creates a round video message.

Source

pub fn sticker(sticker: impl Into<FileSource<'a>>) -> Self

Creates a sticker.

Source§

impl InputMedia<'_>

Source

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

Adds a caption to the media.

Source§

impl InputMedia<'_>

Source

pub fn html(self) -> Self

Parses the text or caption as HTML.

Source

pub fn markdown(self) -> Self

Parses the text or caption as Markdown.

Source

pub fn parse_mode(self, mode: ParseMode) -> Self

Sets how the text or caption is parsed. Without it the client’s default parse mode applies.

Source§

impl<'a> InputMedia<'a>

Source

pub fn thumb(self, thumb: impl Into<Upload<'a>>) -> Self

Uploads a JPEG thumbnail of at most 320×320 and 200 KB. Telegram ignores a bigger one.

Source§

impl<'a> InputMedia<'a>

Source

pub fn cover(self, cover: impl Into<FileSource<'a>>) -> Self

Shows this image as the video’s cover.

Source§

impl InputMedia<'_>

Source

pub fn has_spoiler(self) -> Self

Hides the media behind a spoiler until the user taps it.

Source§

impl InputMedia<'_>

Source

pub fn show_caption_above_media(self) -> Self

Puts the caption above the media instead of below it.

Source§

impl InputMedia<'_>

Source

pub fn supports_streaming(self) -> Self

Marks the video as suitable for streaming while it downloads.

Source§

impl InputMedia<'_>

Source

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

Tells Telegram the media’s duration, in seconds.

Source§

impl InputMedia<'_>

Source

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

Starts the video’s playback at this second.

Source§

impl InputMedia<'_>

Source

pub fn width(self, width: i32) -> Self

Tells Telegram the media’s width, in pixels.

Source§

impl InputMedia<'_>

Source

pub fn height(self, height: i32) -> Self

Tells Telegram the media’s height, in pixels.

Source§

impl InputMedia<'_>

Source

pub fn length(self, length: i32) -> Self

Tells Telegram a video note’s diameter, in pixels, as both its width and its height.

Source§

impl InputMedia<'_>

Source

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

Shows this performer for the audio in the music player.

Source§

impl InputMedia<'_>

Source

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

Shows this title for the audio in the music player.

Source§

impl InputMedia<'_>

Source

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

Ties the sticker to this emoji.

Source§

impl InputMedia<'_>

Source

pub fn disable_content_type_detection(self) -> Self

Keeps a video, GIF or audio file a plain document instead of letting Telegram convert it.

Source§

impl InputMedia<'_>

Source

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

Names an uploaded file, instead of the path’s or bytes’ own name. The name also picks the MIME type. Ignored for a file id or a URL.

Source§

impl InputMedia<'_>

Source

pub fn mask_position(self, position: MaskPosition) -> Self

Places a sticker on a face, which makes it a mask. Ignored unless the media is a sticker being uploaded. A file id, a URL or any other kind of media sends no mask.

Trait Implementations§

Source§

impl<'a> Clone for InputMedia<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for InputMedia<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> From<InputMedia<'a>> for InputPollMedia<'a>

Source§

fn from(media: InputMedia<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Forget for InputMedia<'a>

§

impl<'a> Freeze for InputMedia<'a>

§

impl<'a> Move for InputMedia<'a>

§

impl<'a> RefUnwindSafe for InputMedia<'a>

§

impl<'a> Send for InputMedia<'a>

§

impl<'a> Sync for InputMedia<'a>

§

impl<'a> Unpin for InputMedia<'a>

§

impl<'a> UnsafeUnpin for InputMedia<'a>

§

impl<'a> UnwindSafe for InputMedia<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.