diff --git a/rust-sdk/src/error.rs b/rust-sdk/src/error.rs new file mode 100644 index 0000000000..a2f3c57684 --- /dev/null +++ b/rust-sdk/src/error.rs @@ -0,0 +1,19 @@ +use matrix_sdk_common::identifiers::Error as RumaIdentifierError; + +use matrix_sdk_crypto::{store::CryptoStoreError as InnerStoreError, OlmError}; + +#[derive(Debug, thiserror::Error)] +pub enum MachineCreationError { + #[error(transparent)] + Identifier(#[from] RumaIdentifierError), + #[error(transparent)] + CryptoStore(#[from] InnerStoreError), +} + +#[derive(Debug, thiserror::Error)] +pub enum CryptoStoreError { + #[error(transparent)] + CryptoStore(#[from] InnerStoreError), + #[error(transparent)] + OlmError(#[from] OlmError), +} diff --git a/rust-sdk/src/lib.rs b/rust-sdk/src/lib.rs index f2a55309be..52becf3f1d 100644 --- a/rust-sdk/src/lib.rs +++ b/rust-sdk/src/lib.rs @@ -2,12 +2,11 @@ use std::sync::{Arc, Mutex}; use tracing_subscriber::{fmt::MakeWriter, EnvFilter}; +mod error; mod machine; -pub use machine::{ - CryptoStoreError, Device, DeviceLists, MachineCreationError, OlmMachine, Request, RequestType, - Sas, -}; +pub use error::*; +pub use machine::{Device, DeviceLists, OlmMachine, Request, RequestType, Sas}; pub trait Logger: Send { fn log(&self, log_line: String); diff --git a/rust-sdk/src/machine.rs b/rust-sdk/src/machine.rs index e83cd48670..4894fd7074 100644 --- a/rust-sdk/src/machine.rs +++ b/rust-sdk/src/machine.rs @@ -17,16 +17,17 @@ use matrix_sdk_common::{ }, sync::sync_events::{DeviceLists as RumaDeviceLists, ToDevice}, }, - identifiers::{DeviceKeyAlgorithm, Error as RumaIdentifierError, UserId}, + identifiers::{DeviceKeyAlgorithm, UserId}, uuid::Uuid, UInt, }; use matrix_sdk_crypto::{ - store::CryptoStoreError as InnerStoreError, IncomingResponse, OlmError, - OlmMachine as InnerMachine, OutgoingRequest, ToDeviceRequest, + IncomingResponse, OlmMachine as InnerMachine, OutgoingRequest, ToDeviceRequest, }; +use crate::error::{CryptoStoreError, MachineCreationError}; + pub struct OlmMachine { inner: InnerMachine, runtime: Runtime, @@ -88,22 +89,6 @@ impl<'a> Into> for &'a OwnedResponse { } } -#[derive(Debug, thiserror::Error)] -pub enum MachineCreationError { - #[error(transparent)] - Identifier(#[from] RumaIdentifierError), - #[error(transparent)] - CryptoStore(#[from] InnerStoreError), -} - -#[derive(Debug, thiserror::Error)] -pub enum CryptoStoreError { - #[error(transparent)] - CryptoStore(#[from] InnerStoreError), - #[error(transparent)] - OlmError(#[from] OlmError), -} - pub enum RequestType { KeysQuery, KeysUpload, @@ -334,4 +319,3 @@ impl OlmMachine { .unwrap(); } } -