From fbd9381eb9da20abdd6e3eafe37ebbc4460c53df Mon Sep 17 00:00:00 2001 From: librelois <elois@ifee.fr> Date: Sat, 11 May 2019 20:49:19 +0200 Subject: [PATCH] [ref] network: create SyncError --- lib/core/network/Cargo.toml | 1 + lib/core/network/lib.rs | 20 +++++++++++++++++++- lib/modules/ws2p/ws2p/src/lib.rs | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/core/network/Cargo.toml b/lib/core/network/Cargo.toml index 9a37748e..1b2f8428 100644 --- a/lib/core/network/Cargo.toml +++ b/lib/core/network/Cargo.toml @@ -14,6 +14,7 @@ dup-crypto = { path = "../../tools/crypto" } dubp-documents= { path = "../../tools/documents" } durs-module = { path = "../module" } durs-network-documents = { path = "../../tools/network-documents" } +failure = "0.1.5" serde = "1.0.*" serde_derive = "1.0.*" serde_json = "1.0.*" diff --git a/lib/core/network/lib.rs b/lib/core/network/lib.rs index bc286071..1b49e888 100644 --- a/lib/core/network/lib.rs +++ b/lib/core/network/lib.rs @@ -35,6 +35,7 @@ use durs_module::*; use durs_network_documents::network_endpoint::ApiFeatures; use durs_network_documents::network_head::NetworkHead; use durs_network_documents::*; +use failure::Fail; use std::fmt::Debug; use std::sync::mpsc; @@ -60,7 +61,7 @@ pub trait NetworkModule<DC: DursConfTrait, M: ModuleMessage>: ApiModule<DC, M> { module_conf: <Self as DursModule<DC, M>>::ModuleConf, main_sender: mpsc::Sender<RouterThreadMessage<M>>, sync_params: SyncOpt, - ) -> Result<(), ModuleInitError>; + ) -> Result<(), SyncError>; } /// Trait to be implemented by the configuration object of the module managing the inter-node network. @@ -74,3 +75,20 @@ pub enum NetworkConsensusError { /// The network module does not determine consensus, there is most likely a fork Fork(), } + +#[derive(Debug, Clone, Fail, PartialEq, Eq, Hash)] +/// Synchronization error +pub enum SyncError { + /// Invalid source + #[fail(display = "invalid source: {}", source)] + InvalidSource { + /// Source + source: String, + }, + /// Unreachable source + #[fail(display = "unreachable source: {}", source)] + UnreachableSource { + /// Source + source: String, + }, +} diff --git a/lib/modules/ws2p/ws2p/src/lib.rs b/lib/modules/ws2p/ws2p/src/lib.rs index 3cadeca7..e1ef857a 100644 --- a/lib/modules/ws2p/ws2p/src/lib.rs +++ b/lib/modules/ws2p/ws2p/src/lib.rs @@ -130,7 +130,7 @@ impl NetworkModule<DuRsConf, DursMsg> for WS2PModule { _conf: WS2PConf, _main_sender: mpsc::Sender<RouterThreadMessage<DursMsg>>, _sync_params: SyncOpt, - ) -> Result<(), ModuleInitError> { + ) -> Result<(), SyncError> { unimplemented!() } } -- GitLab