refactor(sdk): Reduce the size of Error::SlidingSync.

This patch boxes the error in `Error::SlidingSync` to reduce the size of
this variant (from 72 bytes to 16 bytes).
This commit is contained in:
Ivan Enderlin
2025-04-04 12:19:54 +02:00
parent 47a1db9e16
commit 385df955c3
2 changed files with 9 additions and 3 deletions

View File

@@ -47,7 +47,7 @@ use url::ParseError as UrlParseError;
use crate::{
event_cache::EventCacheError, media::MediaError, room::reply::ReplyError,
store_locks::LockStoreError,
sliding_sync::Error as SlidingSyncError, store_locks::LockStoreError,
};
/// Result type of the matrix-sdk.
@@ -342,7 +342,7 @@ pub enum Error {
/// An error occurred within sliding-sync
#[error(transparent)]
SlidingSync(#[from] crate::sliding_sync::Error),
SlidingSync(Box<SlidingSyncError>),
/// Attempted to call a method on a room that requires the user to have a
/// specific membership state in the room, but the membership state is
@@ -477,6 +477,12 @@ impl From<ScanError> for Error {
}
}
impl From<SlidingSyncError> for Error {
fn from(error: SlidingSyncError) -> Self {
Error::SlidingSync(Box::new(error))
}
}
/// Error for the room key importing functionality.
#[cfg(feature = "e2e-encryption")]
#[derive(Error, Debug)]

View File

@@ -232,7 +232,7 @@ impl SlidingSyncBuilder {
let version = self.version.unwrap_or_else(|| client.sliding_sync_version());
if matches!(version, Version::None) {
return Err(crate::error::Error::SlidingSync(Error::VersionIsMissing));
return Err(crate::error::Error::SlidingSync(Box::new(Error::VersionIsMissing)));
}
let (internal_channel_sender, _internal_channel_receiver) = channel(8);