Struct threema_gateway::FileMessageBuilder[][src]

pub struct FileMessageBuilder { /* fields omitted */ }

Builder for FileMessage.

Implementations

impl FileMessageBuilder[src]

pub fn new(
    file_blob_id: BlobId,
    blob_encryption_key: Key,
    media_type: Mime,
    file_size_bytes: u32
) -> Self
[src]

Create a new FileMessage builder.

Before calling this function, you need to symmetrically encrypt the file data (libsodium secretbox, random key) and upload the ciphertext to the blob server. Use the nonce 000...1 to encrypt the file data.

The file_blob_id must point to the blob id of the uploaded file data, encrypted with blob_encryption_key.

The file size needs to be specified in bytes. Note that the size is only used for download size displaying purposes and has no security implications.

pub fn thumbnail(self, blob_id: BlobId, media_type: Mime) -> Self[src]

Set a thumbnail.

Before calling this function, you need to symmetrically encrypt the thumbnail data (in JPEG format) with the same key used for the file data and with the nonce 000...2.

pub fn thumbnail_opt(self, blob: Option<(BlobId, Mime)>) -> Self[src]

Set a thumbnail from an Option.

Before calling this function, you need to symmetrically encrypt the thumbnail data (in JPEG format) with the same key used for the file data and with the nonce 000...2.

pub fn file_name(self, file_name: impl Into<String>) -> Self[src]

Set the file name.

Note that the file name will not be shown in the clients if the rendering type is not set to File.

pub fn file_name_opt(self, file_name: Option<impl Into<String>>) -> Self[src]

Set the file name from an Option.

Note that the file name will not be shown in the clients if the rendering type is not set to File.

pub fn description(self, description: impl Into<String>) -> Self[src]

Set the file description / caption.

pub fn description_opt(self, description: Option<impl Into<String>>) -> Self[src]

Set the file description / caption from an Option.

pub fn rendering_type(self, rendering_type: RenderingType) -> Self[src]

Set the rendering type.

See RenderingType docs for more information.

pub fn animated(self, animated: bool) -> Self[src]

Mark this file message as animated.

May only be used for files with rendering type Media or Sticker.

pub fn dimensions(self, height: u32, width: u32) -> Self[src]

Set the dimensions of this file message.

May only be used for files with rendering type Media or Sticker.

pub fn duration(self, seconds: f32) -> Self[src]

Set the duration (in seconds) of this file message.

May only be used for audio/video files with rendering type Media.

pub fn build(self) -> Result<FileMessage, FileMessageBuilderError>[src]

Create a FileMessage from this builder.

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T> Instrument 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.