Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to edition 2018 #368

Merged
merged 31 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
01f7c54
core: cargo fix --edition
ascjones Jan 29, 2019
a4fa04b
core: edition = 2018
ascjones Jan 29, 2019
e015f32
http: cargo fix --edition
ascjones Jan 29, 2019
02621c1
http: edition = 2018
ascjones Jan 29, 2019
30819ac
ipc: edition 2018
ascjones Jan 29, 2019
c7e49e2
pubsub: edition 2018
ascjones Jan 29, 2019
1f74eb6
pubsub: cargo fix --edition-idioms --broken-code, then fixed compile …
ascjones Jan 29, 2019
bb6e713
server-utils: cargo fix --edition
ascjones Jan 29, 2019
601e5dc
server-utils: edition 2018
ascjones Jan 29, 2019
7cae780
server-utils: cargo fix --edition-idioms --broken-code
ascjones Jan 29, 2019
d004ffb
stdio: edition 2018
ascjones Jan 29, 2019
2122c11
stdio: edition 2018 idioms
ascjones Jan 29, 2019
f0a531f
tcp: edition 2018
ascjones Jan 29, 2019
ea979bf
tcp: edition 2018 idioms
ascjones Jan 29, 2019
f7a859a
test: edition 2018
ascjones Jan 29, 2019
e73d851
test: edition 2018 idioms
ascjones Jan 29, 2019
fb934bf
ws: edition 2018
ascjones Jan 29, 2019
9e013de
ws: edition 2018 idioms
ascjones Jan 29, 2019
566f9c8
edition 2018: remove whitespaces from cargo fix
ascjones Jan 29, 2019
f5c972c
core: edition 2018 idioms
ascjones Jan 29, 2019
283052f
http: edition 2018 idioms
ascjones Jan 29, 2019
39542fb
derive: edition 2018 idioms
ascjones Jan 29, 2019
9add1fe
ipc: edition 2018 idioms
ascjones Jan 29, 2019
e300a76
pubsub: edition 2018 idioms
ascjones Jan 29, 2019
f4b945e
Remove more blank lines and unused
ascjones Jan 29, 2019
2c1c553
Remove all `dyn` keywords for trait objects
ascjones Jan 29, 2019
67f8f9b
Remove anonymous lifetimes
ascjones Jan 29, 2019
4a3d9ff
Replace `r#try` with `?`
ascjones Jan 29, 2019
4d6c607
Remove `extern crate` in doctests
ascjones Jan 29, 2019
ea20ab0
Remove `extern crate` in READMEs
ascjones Jan 29, 2019
3aa63ed
Convert doctest to use derive instead of macros
ascjones Jan 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version = "10.0.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
keywords = ["jsonrpc", "json-rpc", "json", "rpc", "serde"]
documentation = "https://paritytech.github.io/jsonrpc/jsonrpc_core/index.html"
edition = "2018"

categories = [
"asynchronous",
Expand Down
4 changes: 0 additions & 4 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jsonrpc-core = "4.0"
`main.rs`

```rust
extern crate jsonrpc_core;

use jsonrpc_core::*;

fn main() {
Expand All @@ -41,8 +39,6 @@ fn main() {
`main.rs`

```rust
extern crate jsonrpc_core;

use jsonrpc_core::*;
use jsonrpc_core::futures::Future;

Expand Down
2 changes: 0 additions & 2 deletions core/examples/async.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate jsonrpc_core;

use jsonrpc_core::*;
use jsonrpc_core::futures::Future;

Expand Down
2 changes: 0 additions & 2 deletions core/examples/basic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate jsonrpc_core;

use jsonrpc_core::*;

fn main() {
Expand Down
2 changes: 0 additions & 2 deletions core/examples/meta.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate jsonrpc_core;

use jsonrpc_core::*;
use jsonrpc_core::futures::Future;

Expand Down
2 changes: 0 additions & 2 deletions core/examples/middlewares.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate jsonrpc_core;

use std::time::Instant;
use std::sync::atomic::{self, AtomicUsize};
use jsonrpc_core::*;
Expand Down
4 changes: 2 additions & 2 deletions core/src/calls.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::fmt;
use std::sync::Arc;
use types::{Params, Value, Error};
use crate::types::{Params, Value, Error};
use futures::{Future, IntoFuture};
use BoxFuture;
use crate::BoxFuture;

/// Metadata trait
pub trait Metadata: Clone + Send + 'static {}
Expand Down
6 changes: 3 additions & 3 deletions core/src/delegates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
use std::sync::Arc;
use std::collections::HashMap;

use types::{Params, Value, Error};
use calls::{Metadata, RemoteProcedure, RpcMethod, RpcNotification};
use crate::types::{Params, Value, Error};
use crate::calls::{Metadata, RemoteProcedure, RpcMethod, RpcNotification};
use futures::IntoFuture;
use BoxFuture;
use crate::BoxFuture;

struct DelegateAsyncMethod<T, F> {
delegate: Arc<T>,
Expand Down
10 changes: 5 additions & 5 deletions core/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use std::ops::{Deref, DerefMut};
use serde_json;
use futures::{self, future, Future};

use calls::{RemoteProcedure, Metadata, RpcMethodSimple, RpcMethod, RpcNotificationSimple, RpcNotification};
use middleware::{self, Middleware};
use types::{Error, ErrorCode, Version};
use types::{Request, Response, Call, Output};
use crate::calls::{RemoteProcedure, Metadata, RpcMethodSimple, RpcMethod, RpcNotificationSimple, RpcNotification};
use crate::middleware::{self, Middleware};
use crate::types::{Error, ErrorCode, Version};
use crate::types::{Request, Response, Call, Output};

/// A type representing middleware or RPC response before serialization.
pub type FutureResponse = Box<Future<Item=Option<Response>, Error=()> + Send>;
Expand Down Expand Up @@ -372,7 +372,7 @@ fn write_response(response: Response) -> String {
#[cfg(test)]
mod tests {
use futures;
use types::{Value};
use crate::types::{Value};
use super::{IoHandler, Compatibility};

#[test]
Expand Down
15 changes: 6 additions & 9 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
//! Right now it supports only server side handling requests.
//!
//! ```rust
//! extern crate jsonrpc_core;
//!
//! use jsonrpc_core::*;
//! use jsonrpc_core::futures::Future;
//!
Expand All @@ -25,9 +23,8 @@

#[macro_use] extern crate log;
#[macro_use] extern crate serde_derive;
extern crate serde;

pub extern crate futures;
pub use futures;

#[doc(hidden)]
pub extern crate serde_json;
Expand All @@ -45,8 +42,8 @@ pub type BoxFuture<T> = Box<futures::Future<Item = T, Error = Error> + Send>;
/// A Result type.
pub type Result<T> = ::std::result::Result<T, Error>;

pub use calls::{RemoteProcedure, Metadata, RpcMethodSimple, RpcMethod, RpcNotificationSimple, RpcNotification};
pub use delegates::IoDelegate;
pub use io::{Compatibility, IoHandler, MetaIoHandler, FutureOutput, FutureResult, FutureResponse, FutureRpcResult};
pub use middleware::{Middleware, Noop as NoopMiddleware};
pub use types::*;
pub use crate::calls::{RemoteProcedure, Metadata, RpcMethodSimple, RpcMethod, RpcNotificationSimple, RpcNotification};
pub use crate::delegates::IoDelegate;
pub use crate::io::{Compatibility, IoHandler, MetaIoHandler, FutureOutput, FutureResult, FutureResponse, FutureRpcResult};
pub use crate::middleware::{Middleware, Noop as NoopMiddleware};
pub use crate::types::*;
4 changes: 2 additions & 2 deletions core/src/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! `IoHandler` middlewares

use calls::Metadata;
use types::{Request, Response, Call, Output};
use crate::calls::Metadata;
use crate::types::{Request, Response, Call, Output};
use futures::{future::Either, Future};

/// RPC middleware
Expand Down
2 changes: 1 addition & 1 deletion core/src/types/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl From<i64> for ErrorCode {
impl<'a> Deserialize<'a> for ErrorCode {
fn deserialize<D>(deserializer: D) -> Result<ErrorCode, D::Error>
where D: Deserializer<'a> {
let code: i64 = try!(Deserialize::deserialize(deserializer));
let code: i64 = Deserialize::deserialize(deserializer)?;
Ok(ErrorCode::from(code))
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/types/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Params {
mod tests {
use serde_json;
use super::Params;
use types::{Value, Error, ErrorCode};
use crate::types::{Value, Error, ErrorCode};

#[test]
fn params_deserialization() {
Expand Down
2 changes: 1 addition & 1 deletion core/src/types/response.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! jsonrpc response
use super::{Id, Value, Error, ErrorCode, Version};
use {Result as CoreResult};
use crate::{Result as CoreResult};

/// Successful response
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion derive/examples/generic-trait.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate jsonrpc_core;
use jsonrpc_core;

use jsonrpc_core::{IoHandler, Error, Result};
use jsonrpc_core::futures::future::{self, FutureResult};
Expand Down
2 changes: 1 addition & 1 deletion derive/tests/compiletests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate compiletest_rs as compiletest;
use compiletest_rs as compiletest;

use std::path::PathBuf;

Expand Down
6 changes: 3 additions & 3 deletions derive/tests/pubsub-macros.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate serde_json;
extern crate jsonrpc_core;
extern crate jsonrpc_pubsub;
use serde_json;
use jsonrpc_core;
use jsonrpc_pubsub;
#[macro_use]
extern crate jsonrpc_derive;

Expand Down
1 change: 1 addition & 0 deletions http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version = "10.0.0"
authors = ["debris <marek.kotewicz@gmail.com>"]
keywords = ["jsonrpc", "json-rpc", "json", "rpc", "server"]
documentation = "https://paritytech.github.io/jsonrpc/jsonrpc_http_server/index.html"
edition = "2018"

[dependencies]
hyper = "0.12"
Expand Down
2 changes: 0 additions & 2 deletions http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jsonrpc-http-server = "10.0"
`main.rs`

```rust
extern crate jsonrpc_http_server;

use jsonrpc_http_server::*;
use jsonrpc_http_server::jsonrpc_core::*;

Expand Down
2 changes: 0 additions & 2 deletions http/examples/http_async.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate jsonrpc_http_server;

use jsonrpc_http_server::{ServerBuilder, DomainsValidation, AccessControlAllowOrigin};
use jsonrpc_http_server::jsonrpc_core::*;

Expand Down
3 changes: 0 additions & 3 deletions http/examples/http_meta.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
extern crate jsonrpc_http_server;
extern crate unicase;

use jsonrpc_http_server::{ServerBuilder, hyper, RestApi, cors::AccessControlAllowHeaders};
use jsonrpc_http_server::jsonrpc_core::*;

Expand Down
2 changes: 0 additions & 2 deletions http/examples/http_middleware.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate jsonrpc_http_server;

use jsonrpc_http_server::{
hyper, ServerBuilder, DomainsValidation, AccessControlAllowOrigin, Response, RestApi
};
Expand Down
2 changes: 0 additions & 2 deletions http/examples/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate jsonrpc_http_server;

use jsonrpc_http_server::{ServerBuilder, DomainsValidation, AccessControlAllowOrigin, RestApi};
use jsonrpc_http_server::jsonrpc_core::*;

Expand Down
14 changes: 7 additions & 7 deletions http/src/handler.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use Rpc;
use crate::Rpc;

use std::{fmt, mem, str};
use std::sync::Arc;

use hyper::{self, service::Service, Body, Method};
use hyper::header::{self, HeaderMap, HeaderValue};

use jsonrpc::{self as core, middleware, FutureResult, Metadata, Middleware};
use jsonrpc::futures::{Future, Poll, Async, Stream, future};
use jsonrpc::serde_json;
use response::Response;
use server_utils::cors;
use crate::jsonrpc::{self as core, middleware, FutureResult, Metadata, Middleware};
use crate::jsonrpc::futures::{Future, Poll, Async, Stream, future};
use crate::jsonrpc::serde_json;
use crate::response::Response;
use crate::server_utils::cors;

use {utils, RequestMiddleware, RequestMiddlewareAction, CorsDomains, AllowedHosts, RestApi};
use crate::{utils, RequestMiddleware, RequestMiddlewareAction, CorsDomains, AllowedHosts, RestApi};

/// jsonrpc http request handler.
pub struct ServerHandler<M: Metadata = (), S: Middleware<M> = middleware::Noop> {
Expand Down
37 changes: 17 additions & 20 deletions http/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! jsonrpc http server.
//!
//! ```no_run
//! extern crate jsonrpc_core;
//! extern crate jsonrpc_http_server;
//!
//! use jsonrpc_core::*;
//! use jsonrpc_http_server::*;
//!
Expand All @@ -23,12 +20,12 @@

#![warn(missing_docs)]

extern crate unicase;
extern crate jsonrpc_server_utils as server_utils;
extern crate net2;

pub extern crate jsonrpc_core;
pub extern crate hyper;
use jsonrpc_server_utils as server_utils;
use net2;

pub use jsonrpc_core;
pub use hyper;

#[macro_use]
extern crate log;
Expand All @@ -46,17 +43,17 @@ use std::thread;

use hyper::{server, Body};
use jsonrpc_core as jsonrpc;
use jsonrpc::MetaIoHandler;
use jsonrpc::futures::{self, Future, Stream, future};
use jsonrpc::futures::sync::oneshot;
use server_utils::reactor::{Executor, UninitializedExecutor};

pub use server_utils::hosts::{Host, DomainsValidation};
pub use server_utils::cors::{self, AccessControlAllowOrigin, Origin, AllowCors};
pub use server_utils::{tokio, SuspendableStream};
pub use handler::ServerHandler;
pub use utils::{is_host_allowed, cors_allow_origin, cors_allow_headers};
pub use response::Response;
use crate::jsonrpc::MetaIoHandler;
use crate::jsonrpc::futures::{self, Future, Stream, future};
use crate::jsonrpc::futures::sync::oneshot;
use crate::server_utils::reactor::{Executor, UninitializedExecutor};

pub use crate::server_utils::hosts::{Host, DomainsValidation};
pub use crate::server_utils::cors::{self, AccessControlAllowOrigin, Origin, AllowCors};
pub use crate::server_utils::{tokio, SuspendableStream};
pub use crate::handler::ServerHandler;
pub use crate::utils::{is_host_allowed, cors_allow_origin, cors_allow_headers};
pub use crate::response::Response;

/// Action undertaken by a middleware.
pub enum RequestMiddlewareAction {
Expand Down Expand Up @@ -540,7 +537,7 @@ fn configure_port(reuse: bool, tcp: &net2::TcpBuilder) -> io::Result<()> {
use net2::unix::*;

if reuse {
try!(tcp.reuse_port(true));
tcp.reuse_port(true)?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion http/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate jsonrpc_core;
use jsonrpc_core;

use std::str::Lines;
use std::net::TcpStream;
Expand Down
2 changes: 1 addition & 1 deletion http/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use hyper::{self, header};

use server_utils::{cors, hosts};
use crate::server_utils::{cors, hosts};

/// Extracts string value of a single header in request.
fn read_header<'a>(req: &'a hyper::Request<hyper::Body>, header_name: &str) -> Option<&'a str> {
Expand Down
1 change: 1 addition & 0 deletions ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "MIT"
homepage = "https://github.com/paritytech/jsonrpc"
repository = "https://github.com/paritytech/jsonrpc"
documentation = "https://paritytech.github.io/jsonrpc/json_ipc_server/index.html"
edition = "2018"

[dependencies]
log = "0.4"
Expand Down
2 changes: 0 additions & 2 deletions ipc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jsonrpc-ipc-server = "10.0"
`main.rs`

```rust
extern crate jsonrpc_ipc_server;

use jsonrpc_ipc_server::Server;
use jsonrpc_ipc_server::jsonrpc_core::*;

Expand Down
2 changes: 1 addition & 1 deletion ipc/examples/ipc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate jsonrpc_ipc_server;
use jsonrpc_ipc_server;

use jsonrpc_ipc_server::jsonrpc_core::*;

Expand Down
13 changes: 5 additions & 8 deletions ipc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

#![warn(missing_docs)]

extern crate jsonrpc_server_utils as server_utils;
extern crate parity_tokio_ipc;
extern crate tokio_service;
extern crate parking_lot;
use jsonrpc_server_utils as server_utils;

pub extern crate jsonrpc_core;
pub use jsonrpc_core;

#[macro_use] extern crate log;

#[cfg(test)] #[macro_use] extern crate lazy_static;
#[cfg(test)] extern crate env_logger;

#[cfg(test)] mod logger;

mod server;
Expand All @@ -21,8 +18,8 @@ mod meta;

use jsonrpc_core as jsonrpc;

pub use meta::{MetaExtractor, NoopExtractor, RequestContext};
pub use server::{Server, ServerBuilder, CloseHandle,SecurityAttributes};
pub use crate::meta::{MetaExtractor, NoopExtractor, RequestContext};
pub use crate::server::{Server, ServerBuilder, CloseHandle,SecurityAttributes};

pub use self::server_utils::{tokio, codecs::Separator};
pub use self::server_utils::session::{SessionStats, SessionId};