Skip to content

Commit

Permalink
refactor(sdk)!: rename PrepareEncryptedFile et al. to `UploadEncryp…
Browse files Browse the repository at this point in the history
…tedFile`

Changelog: Renamed `PrepareEncryptedFile` and
`Client::prepare_encrypted_file` to `UploadEncryptedFile` and
`Client::upload_encrypted_file`.
  • Loading branch information
bnjbvr committed Oct 17, 2024
1 parent e154a03 commit b89e609
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions crates/matrix-sdk/src/encryption/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
Expand All @@ -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,
{
Expand Down
14 changes: 7 additions & 7 deletions crates/matrix-sdk/src/encryption/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
};
Expand All @@ -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?;

Expand Down

0 comments on commit b89e609

Please sign in to comment.