pub struct FileMessageBuilder { /* private fields */ }
Expand description
Builder for FileMessage
.
Implementations§
Source§impl FileMessageBuilder
impl FileMessageBuilder
Sourcepub fn new(
file_blob_id: BlobId,
blob_encryption_key: Key,
media_type: impl Into<String>,
file_size_bytes: u32,
) -> Self
pub fn new( file_blob_id: BlobId, blob_encryption_key: Key, media_type: impl Into<String>, file_size_bytes: u32, ) -> Self
Create a new FileMessage
builder.
Before calling this function, you need to symmetrically encrypt the
file data with encrypt_file_data
and
upload the ciphertext to the blob server with
blob_upload
.
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.
Sourcepub fn thumbnail(self, blob_id: BlobId, media_type: impl Into<String>) -> Self
pub fn thumbnail(self, blob_id: BlobId, media_type: impl Into<String>) -> Self
Set a thumbnail.
Before calling this function, you need to encrypt and upload the
thumbnail data along with the file data (as described in
FileMessageBuilder::new
).
Sourcepub fn thumbnail_opt(self, blob: Option<(BlobId, impl Into<String>)>) -> Self
pub fn thumbnail_opt(self, blob: Option<(BlobId, impl Into<String>)>) -> Self
Set a thumbnail from an Option.
Before calling this function, you need to encrypt and upload the
thumbnail data along with the file data (as described in
FileMessageBuilder::new
).
Sourcepub fn file_name(self, file_name: impl Into<String>) -> Self
pub fn file_name(self, file_name: impl Into<String>) -> Self
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
.
Sourcepub fn file_name_opt(self, file_name: Option<impl Into<String>>) -> Self
pub fn file_name_opt(self, file_name: Option<impl Into<String>>) -> Self
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
.
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Set the file description / caption.
Sourcepub fn description_opt(self, description: Option<impl Into<String>>) -> Self
pub fn description_opt(self, description: Option<impl Into<String>>) -> Self
Set the file description / caption from an Option.
Sourcepub fn rendering_type(self, rendering_type: RenderingType) -> Self
pub fn rendering_type(self, rendering_type: RenderingType) -> Self
Set the rendering type.
See RenderingType
docs for more information.
Sourcepub fn animated(self, animated: bool) -> Self
pub fn animated(self, animated: bool) -> Self
Mark this file message as animated.
May only be used for files with rendering type Media
or Sticker
.
Sourcepub fn dimensions(self, height: u32, width: u32) -> Self
pub fn dimensions(self, height: u32, width: u32) -> Self
Set the dimensions of this file message.
May only be used for files with rendering type Media
or Sticker
.
Sourcepub fn duration(self, seconds: f32) -> Self
pub fn duration(self, seconds: f32) -> Self
Set the duration (in seconds) of this file message.
May only be used for audio/video files with rendering type Media
.
Sourcepub fn build(self) -> Result<FileMessage, FileMessageBuilderError>
pub fn build(self) -> Result<FileMessage, FileMessageBuilderError>
Create a FileMessage
from this builder.