Struct tg_flows::InputFile

source ·
pub struct InputFile { /* private fields */ }
Expand description

This object represents the contents of a file to be uploaded.

The official docs.

Implementations§

source§

impl InputFile

source

pub fn url(url: Url) -> Self

Creates an InputFile from an url.

Notes:

  • When sending by URL the target file must have the correct MIME type (e.g., audio/mpeg for SendAudio, etc.).
  • In SendDocument, sending by URL will currently only work for GIF, PDF and ZIP files.
  • To use SendVoice, the file must have the type audio/ogg and be no more than 1MB in size. 1-20MB voice notes will be sent as files.
  • Other configurations may work but we can’t guarantee that they will.
source

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

Creates an InputFile from a file id.

File id can be obtained from

Notes:

  • It is not possible to change the file type when resending by file id. I.e. a video can’t be sent as a photo, a photo can’t be sent as a document, etc.
  • It is not possible to resend thumbnails.
  • Resending a photo by file id will send all of its sizes.
  • file id is unique for each individual bot and can’t be transferred from one bot to another.
  • file id uniquely identifies a file, but a file can have different valid file_ids even for the same bot.
source

pub fn file(path: impl Into<PathBuf>) -> Self

Creates an InputFile from a file path.

source

pub fn memory(data: impl Into<Bytes>) -> Self

Creates an InputFile from a in-memory bytes.

source

pub fn file_name(self, name: impl Into<Cow<'static, str>>) -> Self

Set the file name for this file.

source

pub fn read(it: impl AsyncRead + Send + Unpin + 'static) -> Self

Creates an InputFile from a in-memory bytes.

Note: in some cases (e.g. sending the same InputFile multiple times) this may read the whole impl AsyncRead into memory.

Trait Implementations§

source§

impl Clone for InputFile

source§

fn clone(&self) -> InputFile

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for InputFile

source§

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

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

impl From<InputMedia> for InputFile

source§

fn from(media: InputMedia) -> InputFile

Converts to this type from the input type.
source§

impl Serialize for InputFile

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Erasable for T

§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
§

const ACK_1_1_0: bool = true

Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more