Skip to content

Commit d2f47f3

Browse files
committed
feat(sdk): introduce AbstractProgress for tracking media progress in pseudo units
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
1 parent 1c9436b commit d2f47f3

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

crates/matrix-sdk/src/http_client/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,21 @@ pub struct TransmissionProgress {
231231
pub total: usize,
232232
}
233233

234+
/// Progress of an operation in abstract units.
235+
///
236+
/// Contrary to [`TransmissionProgress`], this allows tracking the progress
237+
/// of sending or receiving a payload in estimated pseudo units representing a
238+
/// percentage. This is helpful in cases where the exact progress in bytes isn't
239+
/// known, for instance, because encryption (which changes the size) happens on
240+
/// the fly.
241+
#[derive(Clone, Copy, Debug, Default)]
242+
pub struct AbstractProgress {
243+
/// How many units were already transferred.
244+
pub current: usize,
245+
/// How many units there are in total.
246+
pub total: usize,
247+
}
248+
234249
async fn response_to_http_response(
235250
mut response: reqwest::Response,
236251
) -> Result<http::Response<Bytes>, reqwest::Error> {

crates/matrix-sdk/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub use error::{
7474
Error, HttpError, HttpResult, NotificationSettingsError, RefreshTokenError, Result,
7575
RumaApiError,
7676
};
77-
pub use http_client::TransmissionProgress;
77+
pub use http_client::{AbstractProgress, TransmissionProgress};
7878
#[cfg(all(feature = "e2e-encryption", feature = "sqlite"))]
7979
pub use matrix_sdk_sqlite::SqliteCryptoStore;
8080
#[cfg(feature = "sqlite")]

0 commit comments

Comments
 (0)