rust: Move the errors into a separate module

This commit is contained in:
Damir Jelić 2021-02-16 11:37:18 +01:00
parent 75838fda2a
commit 2d620e2ddf
3 changed files with 26 additions and 24 deletions

19
rust-sdk/src/error.rs Normal file
View File

@ -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),
}

View File

@ -2,12 +2,11 @@ use std::sync::{Arc, Mutex};
use tracing_subscriber::{fmt::MakeWriter, EnvFilter}; use tracing_subscriber::{fmt::MakeWriter, EnvFilter};
mod error;
mod machine; mod machine;
pub use machine::{ pub use error::*;
CryptoStoreError, Device, DeviceLists, MachineCreationError, OlmMachine, Request, RequestType, pub use machine::{Device, DeviceLists, OlmMachine, Request, RequestType, Sas};
Sas,
};
pub trait Logger: Send { pub trait Logger: Send {
fn log(&self, log_line: String); fn log(&self, log_line: String);

View File

@ -17,16 +17,17 @@ use matrix_sdk_common::{
}, },
sync::sync_events::{DeviceLists as RumaDeviceLists, ToDevice}, sync::sync_events::{DeviceLists as RumaDeviceLists, ToDevice},
}, },
identifiers::{DeviceKeyAlgorithm, Error as RumaIdentifierError, UserId}, identifiers::{DeviceKeyAlgorithm, UserId},
uuid::Uuid, uuid::Uuid,
UInt, UInt,
}; };
use matrix_sdk_crypto::{ use matrix_sdk_crypto::{
store::CryptoStoreError as InnerStoreError, IncomingResponse, OlmError, IncomingResponse, OlmMachine as InnerMachine, OutgoingRequest, ToDeviceRequest,
OlmMachine as InnerMachine, OutgoingRequest, ToDeviceRequest,
}; };
use crate::error::{CryptoStoreError, MachineCreationError};
pub struct OlmMachine { pub struct OlmMachine {
inner: InnerMachine, inner: InnerMachine,
runtime: Runtime, runtime: Runtime,
@ -88,22 +89,6 @@ impl<'a> Into<IncomingResponse<'a>> 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 { pub enum RequestType {
KeysQuery, KeysQuery,
KeysUpload, KeysUpload,
@ -334,4 +319,3 @@ impl OlmMachine {
.unwrap(); .unwrap();
} }
} }