From d89843c42d4be11f3de72f1a90d9fd060693b024 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 14 Feb 2020 16:32:42 +0100 Subject: [PATCH 1/6] Prepare core for no_std support --- core/Cargo.toml | 14 +++++++++----- core/src/client/core.rs | 30 ++++++++++++++++-------------- core/src/client/raw.rs | 6 ++++-- core/src/common/error.rs | 9 ++++++--- core/src/common/id.rs | 1 + core/src/common/params.rs | 1 + core/src/common/request.rs | 2 ++ core/src/common/response.rs | 2 ++ core/src/common/version.rs | 2 +- core/src/lib.rs | 5 +++++ core/src/local.rs | 18 ++++++++++++++---- core/src/server/batch.rs | 6 ++++-- core/src/server/batches.rs | 10 ++++++---- core/src/server/core.rs | 30 ++++++++++++++++++++---------- core/src/server/notification.rs | 2 +- core/src/server/params.rs | 4 +++- core/src/server/raw/join.rs | 4 +++- core/src/server/raw/traits.rs | 4 +++- core/src/server/typed_rp.rs | 2 +- 19 files changed, 102 insertions(+), 50 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index ab2b60425b..30a9101d48 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -6,16 +6,20 @@ authors = ["Pierre Krieger "] license = "MIT" edition = "2018" +[features] +default = ["std"] +std = ["futures/std"] + [dependencies] bs58 = "0.3.0" -err-derive = "0.1.5" fnv = "1.0" -futures = "0.3.1" +futures = { version = "0.3.4", default-features = false, features = ["async-await"] } +hashbrown = "0.7.0" log = "0.4" rand = "0.7" -serde = { version = "1.0.40", features = ["derive"] } -serde_json = "1.0.40" -smallvec = "0.6.10" +serde = { version = "1.0.101", default-features = false, features = ["derive"] } +serde_json = { version = "1.0.48", default-features = false, features = ["alloc"] } +smallvec = { version = "1.2.0", default-features = false } [dev-dependencies] async-std = "1.2.0" diff --git a/core/src/client/core.rs b/core/src/client/core.rs index 1f8e964a51..739b7225ad 100644 --- a/core/src/client/core.rs +++ b/core/src/client/core.rs @@ -25,12 +25,10 @@ // DEALINGS IN THE SOFTWARE. use crate::{client::raw::TransportClient, common}; -use fnv::FnvHashMap; -use std::{ - collections::{hash_map::Entry, HashMap, VecDeque}, - error, fmt, - future::Future, -}; + +use alloc::{collections::VecDeque, string::String, vec}; +use core::{fmt, future::Future}; +use hashbrown::{hash_map::Entry, HashMap}; /// Wraps around a [`TransportClient`](crate::TransportClient) and analyzes everything correctly. /// @@ -44,7 +42,7 @@ pub struct RawClient { /// List of requests and subscription requests that have been sent out and that are waiting /// for a response. - requests: FnvHashMap, + requests: HashMap, /// List of active subscriptions by ID (ID is chosen by the server). Note that this doesn't /// cover subscription requests that have been sent out but not answered yet, as these are in @@ -197,7 +195,7 @@ impl RawClient { RawClient { inner, next_request_id: RawClientRequestId(0), - requests: FnvHashMap::default(), + requests: HashMap::default(), subscriptions: HashMap::default(), events_queue: VecDeque::with_capacity(16), events_queue_max_size: 64, @@ -700,11 +698,13 @@ where } } -impl error::Error for RawClientError +#[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] +impl std::error::Error for RawClientError where - E: error::Error + 'static, + E: std::error::Error + 'static, { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { RawClientError::Inner(ref err) => Some(err), RawClientError::RequestError(ref err) => Some(err), @@ -741,11 +741,13 @@ where } } -impl error::Error for CloseError +#[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] +impl std::error::Error for CloseError where - E: error::Error + 'static, + E: std::error::Error + 'static, { - fn source(&self) -> Option<&(dyn error::Error + 'static)> { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { CloseError::TransportClient(err) => Some(err), CloseError::AlreadyClosing => None, diff --git a/core/src/client/raw.rs b/core/src/client/raw.rs index a756241b14..60d384e470 100644 --- a/core/src/client/raw.rs +++ b/core/src/client/raw.rs @@ -27,8 +27,10 @@ //! Traits for implementing request-making capabilities. use crate::common; + +use alloc::boxed::Box; +use core::{fmt, pin::Pin}; use futures::prelude::*; -use std::{error, pin::Pin}; /// Objects that can act as clients. /// @@ -42,7 +44,7 @@ use std::{error, pin::Pin}; /// pub trait TransportClient { /// Error that can happen during a request. - type Error: error::Error; + type Error: fmt::Display; /// Sends out out a request. Returns a `Future` that finishes when the request has been /// successfully sent. diff --git a/core/src/common/error.rs b/core/src/common/error.rs index c99df6eec6..c2d3a28445 100644 --- a/core/src/common/error.rs +++ b/core/src/common/error.rs @@ -25,10 +25,12 @@ // DEALINGS IN THE SOFTWARE. use super::JsonValue; + +use alloc::{borrow::ToOwned as _, format, string::{String, ToString as _}}; +use core::fmt; use serde::de::Deserializer; use serde::ser::Serializer; use serde::{Deserialize, Serialize}; -use std::fmt; /// JSONRPC error code #[derive(Debug, PartialEq, Clone)] @@ -191,10 +193,11 @@ impl From for Error { } } -impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}: {}", self.code.description(), self.message) } } +#[cfg(feature = "std")] impl std::error::Error for Error {} diff --git a/core/src/common/id.rs b/core/src/common/id.rs index b6733812ce..bcbd61622f 100644 --- a/core/src/common/id.rs +++ b/core/src/common/id.rs @@ -24,6 +24,7 @@ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +use alloc::string::String; use serde::{Deserialize, Serialize}; /// Request Id diff --git a/core/src/common/params.rs b/core/src/common/params.rs index a62f819944..2ddb5bb445 100644 --- a/core/src/common/params.rs +++ b/core/src/common/params.rs @@ -24,6 +24,7 @@ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +use alloc::{string::String, format, vec::Vec}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use serde_json; diff --git a/core/src/common/request.rs b/core/src/common/request.rs index 03aefc9a9c..2e0237389f 100644 --- a/core/src/common/request.rs +++ b/core/src/common/request.rs @@ -25,6 +25,8 @@ // DEALINGS IN THE SOFTWARE. use super::{Id, Params, Version}; + +use alloc::{string::String, vec::Vec}; use serde::{Deserialize, Serialize}; /// Represents jsonrpc request which is a method call. diff --git a/core/src/common/response.rs b/core/src/common/response.rs index 6ee7df870b..227c325438 100644 --- a/core/src/common/response.rs +++ b/core/src/common/response.rs @@ -25,6 +25,8 @@ // DEALINGS IN THE SOFTWARE. use super::{Error, Id, JsonValue, Version}; + +use alloc::{string::{String, ToString as _}, vec, vec::Vec}; use serde::{Deserialize, Serialize}; /// Synchronous response diff --git a/core/src/common/version.rs b/core/src/common/version.rs index 080edb7c9b..e815c8f937 100644 --- a/core/src/common/version.rs +++ b/core/src/common/version.rs @@ -24,9 +24,9 @@ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +use core::fmt; use serde::de::{self, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt; /// Protocol version. #[derive(Debug, PartialEq, Clone, Copy, Hash, Eq)] diff --git a/core/src/lib.rs b/core/src/lib.rs index fc994e7d1a..a0cf594aa1 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -48,9 +48,14 @@ #![deny(unsafe_code)] #![deny(intra_doc_link_resolution_failure)] #![warn(missing_docs)] +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; pub use crate::client::raw::TransportClient; pub use crate::client::{RawClient, RawClientError, RawClientEvent, RawClientRequestId}; +#[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] pub use crate::local::local_transport; pub use crate::server::raw::{TransportServer, TransportServerEvent}; pub use crate::server::{RawServer, RawServerEvent, RawServerRequestId, RawServerSubscriptionId}; diff --git a/core/src/local.rs b/core/src/local.rs index 731cd822b9..8bb7487c9d 100644 --- a/core/src/local.rs +++ b/core/src/local.rs @@ -60,11 +60,14 @@ //! ``` //! +#![cfg(feature = "std")] +#![cfg_attr(docsrs, doc(cfg(feature = "std")))] + use crate::{common, TransportClient, TransportServer, TransportServerEvent}; -use err_derive::*; + +use core::{fmt, pin::Pin}; use fnv::FnvHashSet; use futures::{channel::mpsc, prelude::*}; -use std::{fmt, pin::Pin}; /// Builds a new client and a new server that are connected to each other. pub fn local_transport() -> (LocalTransportClient, LocalTransportServer) { @@ -107,10 +110,9 @@ pub struct LocalTransportServer { } /// Error that can happen on the client side. -#[derive(Debug, Error)] +#[derive(Debug)] pub enum LocalTransportClientErr { /// The [`LocalTransportServer`] no longer exists. - #[error(display = "Server has been closed")] ServerClosed, } @@ -226,3 +228,11 @@ impl fmt::Debug for LocalTransportServer { f.debug_struct("LocalTransportServer").finish() } } + +impl fmt::Display for LocalTransportClientErr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + LocalTransportClientErr::ServerClosed => write!(f, "Server has been closed"), + } + } +} diff --git a/core/src/server/batch.rs b/core/src/server/batch.rs index 54a0ccf9d2..6cb0357c1d 100644 --- a/core/src/server/batch.rs +++ b/core/src/server/batch.rs @@ -25,8 +25,10 @@ // DEALINGS IN THE SOFTWARE. use crate::{common, server::Notification, server::Params}; + +use alloc::vec::Vec; +use core::{fmt, iter}; use smallvec::SmallVec; -use std::{fmt, iter}; /// Batch corresponding to a request from a [`TransportServer`](crate::TransportServer). /// @@ -195,7 +197,7 @@ impl BatchState { } let raw_response = if self.is_batch { - let list: Vec<_> = self.responses.drain().collect(); + let list: Vec<_> = self.responses.drain(..).collect(); if list.is_empty() { None } else { diff --git a/core/src/server/batches.rs b/core/src/server/batches.rs index 003da0b948..0424162ef3 100644 --- a/core/src/server/batches.rs +++ b/core/src/server/batches.rs @@ -25,8 +25,10 @@ // DEALINGS IN THE SOFTWARE. use crate::{common, server::batch, server::params::Params, server::Notification}; -use fnv::FnvHashMap; -use std::{collections::hash_map::Entry, fmt}; + +use alloc::vec::Vec; +use core::fmt; +use hashbrown::{hash_map::Entry, HashMap}; /// Collection of multiple batches. /// @@ -52,7 +54,7 @@ pub struct BatchesState { /// /// The identifier is lineraly increasing and is never leaked on the wire or outside of this /// module. Therefore there is no risk of hash collision. - batches: FnvHashMap, + batches: HashMap, } /// Event generated by [`next_event`](BatchesState::next_event). @@ -105,7 +107,7 @@ impl BatchesState { pub fn new() -> BatchesState { BatchesState { next_batch_id: 0, - batches: FnvHashMap::with_capacity_and_hasher(BATCHES_MIN_CAPACITY, Default::default()), + batches: HashMap::with_capacity_and_hasher(BATCHES_MIN_CAPACITY, Default::default()), } } diff --git a/core/src/server/core.rs b/core/src/server/core.rs index 17d97c312d..471053baf7 100644 --- a/core/src/server/core.rs +++ b/core/src/server/core.rs @@ -28,11 +28,10 @@ use crate::common::{self, JsonValue}; use crate::server::{ batches, raw::TransportServer, raw::TransportServerEvent, Notification, Params, }; -use err_derive::*; -use fnv::FnvHashMap; -use std::{ - collections::hash_map::Entry, collections::HashMap, fmt, hash::Hash, num::NonZeroUsize, vec, -}; + +use alloc::{borrow::ToOwned as _, string::String, vec, vec::Vec}; +use core::{fmt, hash::Hash, num::NonZeroUsize}; +use hashbrown::{hash_map::Entry, HashMap}; /// Wraps around a "raw server" and adds capabilities. /// @@ -50,7 +49,7 @@ pub struct RawServer { /// List of active subscriptions. /// The identifier is chosen randomly and uniformy distributed. It is never decided by the /// client. There is therefore no risk of hash collision attack. - subscriptions: FnvHashMap<[u8; 32], SubscriptionState>, + subscriptions: HashMap<[u8; 32], SubscriptionState, fnv::FnvBuildHasher>, /// For each raw request ID (i.e. client connection), the number of active subscriptions /// that are using it. @@ -101,7 +100,7 @@ pub struct RawServerRequest<'a, R, I> { raw: &'a mut R, /// Reference to the corresponding field in `RawServer`. - subscriptions: &'a mut FnvHashMap<[u8; 32], SubscriptionState>, + subscriptions: &'a mut HashMap<[u8; 32], SubscriptionState, fnv::FnvBuildHasher>, /// Reference to the corresponding field in `RawServer`. num_subscriptions: &'a mut HashMap, @@ -117,13 +116,11 @@ pub struct ServerSubscription<'a, R, I> { } /// Error that can happen when calling `into_subscription`. -#[derive(Debug, Error)] +#[derive(Debug)] pub enum IntoSubscriptionErr { /// Underlying server doesn't support subscriptions. - #[error(display = "Underlying server doesn't support subscriptions")] NotSupported, /// Request has already been closed by the client. - #[error(display = "Request is already closed")] Closed, } @@ -523,6 +520,19 @@ where } } +impl fmt::Display for IntoSubscriptionErr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + IntoSubscriptionErr::NotSupported => + write!(f, "Underlying server doesn't support subscriptions"), + IntoSubscriptionErr::Closed => write!(f, "Request is already closed"), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for IntoSubscriptionErr {} + impl Iterator for SubscriptionsReadyIter { type Item = RawServerSubscriptionId; diff --git a/core/src/server/notification.rs b/core/src/server/notification.rs index e868d32a6a..a1a88f6506 100644 --- a/core/src/server/notification.rs +++ b/core/src/server/notification.rs @@ -26,7 +26,7 @@ use crate::common; use crate::server::Params; -use std::fmt; +use core::fmt; /// Notification received on a server. /// diff --git a/core/src/server/params.rs b/core/src/server/params.rs index a76579d75e..dc5b940c3b 100644 --- a/core/src/server/params.rs +++ b/core/src/server/params.rs @@ -25,7 +25,9 @@ // DEALINGS IN THE SOFTWARE. use crate::common; -use std::fmt; + +use alloc::string::String; +use core::fmt; /// Access to the parameters of a request. #[derive(Copy, Clone)] diff --git a/core/src/server/raw/join.rs b/core/src/server/raw/join.rs index 6922c9d26e..c4149b549a 100644 --- a/core/src/server/raw/join.rs +++ b/core/src/server/raw/join.rs @@ -26,8 +26,10 @@ use super::{TransportServer, TransportServerEvent}; use crate::common; + +use alloc::boxed::Box; +use core::pin::Pin; use futures::prelude::*; -use std::pin::Pin; /// Joins two servers into one. /// diff --git a/core/src/server/raw/traits.rs b/core/src/server/raw/traits.rs index ad4d4cf661..7ad7339337 100644 --- a/core/src/server/raw/traits.rs +++ b/core/src/server/raw/traits.rs @@ -25,8 +25,10 @@ // DEALINGS IN THE SOFTWARE. use crate::common; + +use alloc::boxed::Box; +use core::{hash::Hash, pin::Pin}; use futures::prelude::*; -use std::{hash::Hash, pin::Pin}; /// Reference to a server that can produce JSON payloads for us to answer. /// diff --git a/core/src/server/typed_rp.rs b/core/src/server/typed_rp.rs index 23a235e933..2aeaa4c9ac 100644 --- a/core/src/server/typed_rp.rs +++ b/core/src/server/typed_rp.rs @@ -25,7 +25,7 @@ // DEALINGS IN THE SOFTWARE. use crate::server::{raw::TransportServer, RawServerRequest}; -use std::{hash::Hash, marker::PhantomData}; +use core::{hash::Hash, marker::PhantomData}; /// Allows responding to a server request in a more elegant and strongly-typed fashion. pub struct TypedResponder<'a, R, I, T> { From 76ef4f623ce2fa7f9b71dd3c869d9f264840b688 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 14 Feb 2020 16:36:42 +0100 Subject: [PATCH 2/6] Fix missing documentation thingies --- core/src/common/error.rs | 1 + core/src/server/core.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/core/src/common/error.rs b/core/src/common/error.rs index c2d3a28445..e5ae493a5a 100644 --- a/core/src/common/error.rs +++ b/core/src/common/error.rs @@ -200,4 +200,5 @@ impl fmt::Display for Error { } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for Error {} diff --git a/core/src/server/core.rs b/core/src/server/core.rs index 471053baf7..acd12f4949 100644 --- a/core/src/server/core.rs +++ b/core/src/server/core.rs @@ -531,6 +531,7 @@ impl fmt::Display for IntoSubscriptionErr { } #[cfg(feature = "std")] +#[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for IntoSubscriptionErr {} impl Iterator for SubscriptionsReadyIter { From 8645cfe0262023307e22a18bb9908757206be324 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 14 Feb 2020 16:43:10 +0100 Subject: [PATCH 3/6] Rustfmt --- core/src/common/error.rs | 6 +++++- core/src/common/params.rs | 2 +- core/src/common/response.rs | 6 +++++- core/src/server/core.rs | 5 +++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/core/src/common/error.rs b/core/src/common/error.rs index e5ae493a5a..f03b175bb6 100644 --- a/core/src/common/error.rs +++ b/core/src/common/error.rs @@ -26,7 +26,11 @@ use super::JsonValue; -use alloc::{borrow::ToOwned as _, format, string::{String, ToString as _}}; +use alloc::{ + borrow::ToOwned as _, + format, + string::{String, ToString as _}, +}; use core::fmt; use serde::de::Deserializer; use serde::ser::Serializer; diff --git a/core/src/common/params.rs b/core/src/common/params.rs index 2ddb5bb445..10a0c56394 100644 --- a/core/src/common/params.rs +++ b/core/src/common/params.rs @@ -24,7 +24,7 @@ // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -use alloc::{string::String, format, vec::Vec}; +use alloc::{format, string::String, vec::Vec}; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use serde_json; diff --git a/core/src/common/response.rs b/core/src/common/response.rs index 227c325438..e2faa77b54 100644 --- a/core/src/common/response.rs +++ b/core/src/common/response.rs @@ -26,7 +26,11 @@ use super::{Error, Id, JsonValue, Version}; -use alloc::{string::{String, ToString as _}, vec, vec::Vec}; +use alloc::{ + string::{String, ToString as _}, + vec, + vec::Vec, +}; use serde::{Deserialize, Serialize}; /// Synchronous response diff --git a/core/src/server/core.rs b/core/src/server/core.rs index acd12f4949..f58c1ba904 100644 --- a/core/src/server/core.rs +++ b/core/src/server/core.rs @@ -523,8 +523,9 @@ where impl fmt::Display for IntoSubscriptionErr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - IntoSubscriptionErr::NotSupported => - write!(f, "Underlying server doesn't support subscriptions"), + IntoSubscriptionErr::NotSupported => { + write!(f, "Underlying server doesn't support subscriptions") + } IntoSubscriptionErr::Closed => write!(f, "Request is already closed"), } } From 36fe813e803fa3c3f75ba92cfc0f7e8cf25d8435 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 14 Feb 2020 16:54:46 +0100 Subject: [PATCH 4/6] For some reason my local rustfmt didn't pick up these changes --- http/src/server/background.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/http/src/server/background.rs b/http/src/server/background.rs index 94b2fa36dc..503ebc5b59 100644 --- a/http/src/server/background.rs +++ b/http/src/server/background.rs @@ -167,7 +167,7 @@ async fn process_request( let json_body = match body_to_request(request.into_body()).await { Ok(b) => b, Err(_) => { - unimplemented!() // TODO: + unimplemented!() // TODO: } }; @@ -181,7 +181,9 @@ async fn process_request( } match rx.await { Ok(response) => response, - Err(_) => return response::internal_error("JSON request send back channel has shut down"), + Err(_) => { + return response::internal_error("JSON request send back channel has shut down") + } } } /*Method::POST if /*self.rest_api == RestApi::Unsecure &&*/ request.uri().path().split('/').count() > 2 => { From eefd7122ffb7436a61f4551583b223c3f8a99cd1 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 19 Feb 2020 12:07:04 +0100 Subject: [PATCH 5/6] Fix compilation --- Cargo.toml | 2 +- core/src/local.rs | 4 ++++ src/client.rs | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 468219cfe3..9dceedd490 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ async-std = "1.2.0" futures = "0.3.1" log = "0.4" parking_lot = "0.9" -jsonrpsee-core = { path = "core" } +jsonrpsee-core = { path = "core", default-features = false, features = ["std"] } jsonrpsee-http = { path = "http", optional = true } jsonrpsee-proc-macros = { path = "proc-macros" } jsonrpsee-ws = { path = "ws", optional = true } diff --git a/core/src/local.rs b/core/src/local.rs index 8bb7487c9d..8594865101 100644 --- a/core/src/local.rs +++ b/core/src/local.rs @@ -68,6 +68,7 @@ use crate::{common, TransportClient, TransportServer, TransportServerEvent}; use core::{fmt, pin::Pin}; use fnv::FnvHashSet; use futures::{channel::mpsc, prelude::*}; +use std::error; /// Builds a new client and a new server that are connected to each other. pub fn local_transport() -> (LocalTransportClient, LocalTransportServer) { @@ -229,6 +230,9 @@ impl fmt::Debug for LocalTransportServer { } } +impl error::Error for LocalTransportClientErr { +} + impl fmt::Display for LocalTransportClientErr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { diff --git a/src/client.rs b/src/client.rs index a3cdc61e34..908acafd64 100644 --- a/src/client.rs +++ b/src/client.rs @@ -121,7 +121,7 @@ impl Client { pub fn new(client: RawClient) -> Client where R: TransportClient + Send + 'static, - R::Error: Send + Sync, + R::Error: error::Error + Send + Sync, { let (to_back, from_front) = mpsc::channel(16); async_std::task::spawn(async move { @@ -222,7 +222,7 @@ impl Client { impl From> for Client where R: TransportClient + Send + 'static, - R::Error: Send + Sync, + R::Error: error::Error + Send + Sync, { fn from(client: RawClient) -> Client { Client::new(client) @@ -264,7 +264,7 @@ impl Drop for Subscription { async fn background_task(mut client: RawClient, mut from_front: mpsc::Receiver) where R: TransportClient + Send + 'static, - R::Error: Send + Sync, + R::Error: error::Error + Send + Sync, { // List of subscription requests that have been sent to the server, with the method name to // unsubscribe. From c9e2989adbf3a3f3fb490c228862602eef433639 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 19 Feb 2020 12:14:07 +0100 Subject: [PATCH 6/6] Rustfmt --- core/src/local.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/local.rs b/core/src/local.rs index 8594865101..03fc1cc4ec 100644 --- a/core/src/local.rs +++ b/core/src/local.rs @@ -230,8 +230,7 @@ impl fmt::Debug for LocalTransportServer { } } -impl error::Error for LocalTransportClientErr { -} +impl error::Error for LocalTransportClientErr {} impl fmt::Display for LocalTransportClientErr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {