mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-06 23:15:08 -04:00
refactor(sdk)!: rename PrepareEncryptedFile et al. to UploadEncryptedFile
Changelog: Renamed `PrepareEncryptedFile` and `Client::prepare_encrypted_file` to `UploadEncryptedFile` and `Client::upload_encrypted_file`.
This commit is contained in:
@@ -27,16 +27,16 @@ use ruma::events::room::{EncryptedFile, EncryptedFileInit};
|
||||
|
||||
use crate::{Client, Result, TransmissionProgress};
|
||||
|
||||
/// Future returned by [`Client::prepare_encrypted_file`].
|
||||
/// Future returned by [`Client::upload_encrypted_file`].
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct PrepareEncryptedFile<'a, R: ?Sized> {
|
||||
pub struct UploadEncryptedFile<'a, R: ?Sized> {
|
||||
client: &'a Client,
|
||||
content_type: &'a mime::Mime,
|
||||
reader: &'a mut R,
|
||||
send_progress: SharedObservable<TransmissionProgress>,
|
||||
}
|
||||
|
||||
impl<'a, R: ?Sized> PrepareEncryptedFile<'a, R> {
|
||||
impl<'a, R: ?Sized> UploadEncryptedFile<'a, R> {
|
||||
pub(crate) fn new(client: &'a Client, content_type: &'a mime::Mime, reader: &'a mut R) -> Self {
|
||||
Self { client, content_type, reader, send_progress: Default::default() }
|
||||
}
|
||||
@@ -63,7 +63,7 @@ impl<'a, R: ?Sized> PrepareEncryptedFile<'a, R> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, R> IntoFuture for PrepareEncryptedFile<'a, R>
|
||||
impl<'a, R> IntoFuture for UploadEncryptedFile<'a, R>
|
||||
where
|
||||
R: Read + Send + ?Sized + 'a,
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ use vodozemac::Curve25519PublicKey;
|
||||
|
||||
use self::{
|
||||
backups::{types::BackupClientState, Backups},
|
||||
futures::PrepareEncryptedFile,
|
||||
futures::UploadEncryptedFile,
|
||||
identities::{Device, DeviceUpdates, IdentityUpdates, UserDevices, UserIdentity},
|
||||
recovery::{Recovery, RecoveryState},
|
||||
secret_storage::SecretStorage,
|
||||
@@ -438,17 +438,17 @@ impl Client {
|
||||
/// # let client = Client::new(homeserver).await?;
|
||||
/// # let room = client.get_room(&room_id!("!test:example.com")).unwrap();
|
||||
/// let mut reader = std::io::Cursor::new(b"Hello, world!");
|
||||
/// let encrypted_file = client.prepare_encrypted_file(&mime::TEXT_PLAIN, &mut reader).await?;
|
||||
/// let encrypted_file = client.upload_encrypted_file(&mime::TEXT_PLAIN, &mut reader).await?;
|
||||
///
|
||||
/// room.send(CustomEventContent { encrypted_file }).await?;
|
||||
/// # anyhow::Ok(()) };
|
||||
/// ```
|
||||
pub fn prepare_encrypted_file<'a, R: Read + ?Sized + 'a>(
|
||||
pub fn upload_encrypted_file<'a, R: Read + ?Sized + 'a>(
|
||||
&'a self,
|
||||
content_type: &'a mime::Mime,
|
||||
reader: &'a mut R,
|
||||
) -> PrepareEncryptedFile<'a, R> {
|
||||
PrepareEncryptedFile::new(self, content_type, reader)
|
||||
) -> UploadEncryptedFile<'a, R> {
|
||||
UploadEncryptedFile::new(self, content_type, reader)
|
||||
}
|
||||
|
||||
/// Encrypt and upload the file and thumbnails, and return the source
|
||||
@@ -465,7 +465,7 @@ impl Client {
|
||||
|
||||
let upload_attachment = async {
|
||||
let mut cursor = Cursor::new(data);
|
||||
self.prepare_encrypted_file(content_type, &mut cursor)
|
||||
self.upload_encrypted_file(content_type, &mut cursor)
|
||||
.with_send_progress_observable(send_progress)
|
||||
.await
|
||||
};
|
||||
@@ -491,7 +491,7 @@ impl Client {
|
||||
let mut cursor = Cursor::new(thumbnail.data);
|
||||
|
||||
let file = self
|
||||
.prepare_encrypted_file(content_type, &mut cursor)
|
||||
.upload_encrypted_file(content_type, &mut cursor)
|
||||
.with_send_progress_observable(send_progress)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user