diff options
Diffstat (limited to 'rust/fatcat-api/examples')
-rw-r--r-- | rust/fatcat-api/examples/client.rs | 415 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server.rs | 64 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server_lib/mod.rs | 18 | ||||
-rw-r--r-- | rust/fatcat-api/examples/server_lib/server.rs | 276 |
4 files changed, 244 insertions, 529 deletions
diff --git a/rust/fatcat-api/examples/client.rs b/rust/fatcat-api/examples/client.rs index 6f7aa151..6693a3b1 100644 --- a/rust/fatcat-api/examples/client.rs +++ b/rust/fatcat-api/examples/client.rs @@ -1,350 +1,201 @@ #![allow(missing_docs, unused_variables, trivial_casts)] -extern crate clap; extern crate fatcat; #[allow(unused_extern_crates)] extern crate futures; #[allow(unused_extern_crates)] extern crate swagger; -extern crate tokio_core; #[allow(unused_extern_crates)] extern crate uuid; +extern crate clap; -use clap::{App, Arg}; #[allow(unused_imports)] -use fatcat::{ApiError, ApiNoContext, ContainerIdGetResponse, ContainerLookupGetResponse, - ContainerPostResponse, ContextWrapperExt, CreatorIdGetResponse, - CreatorLookupGetResponse, CreatorPostResponse, EditgroupIdAcceptPostResponse, - EditgroupIdGetResponse, EditgroupPostResponse, EditorUsernameChangelogGetResponse, - EditorUsernameGetResponse, FileIdGetResponse, FileLookupGetResponse, - FilePostResponse, ReleaseIdGetResponse, ReleaseLookupGetResponse, - ReleasePostResponse, WorkIdGetResponse, WorkPostResponse}; +use futures::{Future, future, Stream, stream}; #[allow(unused_imports)] -use futures::{future, stream, Future, Stream}; -use tokio_core::reactor; +use fatcat::{ApiNoContext, ContextWrapperExt, + ApiError, + ContainerIdGetResponse, + ContainerLookupGetResponse, + ContainerPostResponse, + CreatorIdGetResponse, + CreatorLookupGetResponse, + CreatorPostResponse, + EditgroupIdAcceptPostResponse, + EditgroupIdGetResponse, + EditgroupPostResponse, + EditorUsernameChangelogGetResponse, + EditorUsernameGetResponse, + FileIdGetResponse, + FileLookupGetResponse, + FilePostResponse, + ReleaseIdGetResponse, + ReleaseLookupGetResponse, + ReleasePostResponse, + WorkIdGetResponse, + WorkPostResponse + }; +use clap::{App, Arg}; fn main() { let matches = App::new("client") - .arg( - Arg::with_name("operation") - .help("Sets the operation to run") - .possible_values(&[ - "ContainerIdGet", - "ContainerLookupGet", - "ContainerPost", - "CreatorIdGet", - "CreatorLookupGet", - "CreatorPost", - "EditgroupIdAcceptPost", - "EditgroupIdGet", - "EditgroupPost", - "EditorUsernameChangelogGet", - "EditorUsernameGet", - "FileIdGet", - "FileLookupGet", - "FilePost", - "ReleaseIdGet", - "ReleaseLookupGet", - "ReleasePost", - "WorkIdGet", - "WorkPost", - ]) - .required(true) - .index(1), - ) - .arg( - Arg::with_name("https") - .long("https") - .help("Whether to use HTTPS or not"), - ) - .arg( - Arg::with_name("host") - .long("host") - .takes_value(true) - .default_value("api.fatcat.wiki") - .help("Hostname to contact"), - ) - .arg( - Arg::with_name("port") - .long("port") - .takes_value(true) - .default_value("8080") - .help("Port to contact"), - ) + .arg(Arg::with_name("operation") + .help("Sets the operation to run") + .possible_values(&[ + "ContainerIdGet", + "ContainerLookupGet", + "ContainerPost", + "CreatorIdGet", + "CreatorLookupGet", + "CreatorPost", + "EditgroupIdAcceptPost", + "EditgroupIdGet", + "EditgroupPost", + "EditorUsernameChangelogGet", + "EditorUsernameGet", + "FileIdGet", + "FileLookupGet", + "FilePost", + "ReleaseIdGet", + "ReleaseLookupGet", + "ReleasePost", + "WorkIdGet", + "WorkPost", +]) + .required(true) + .index(1)) + .arg(Arg::with_name("https") + .long("https") + .help("Whether to use HTTPS or not")) + .arg(Arg::with_name("host") + .long("host") + .takes_value(true) + .default_value("api.fatcat.wiki") + .help("Hostname to contact")) + .arg(Arg::with_name("port") + .long("port") + .takes_value(true) + .default_value("8080") + .help("Port to contact")) .get_matches(); - let mut core = reactor::Core::new().unwrap(); let is_https = matches.is_present("https"); - let base_url = format!( - "{}://{}:{}", - if is_https { "https" } else { "http" }, - matches.value_of("host").unwrap(), - matches.value_of("port").unwrap() - ); - let client = if matches.is_present("https") { + let base_url = format!("{}://{}:{}", + if is_https { "https" } else { "http" }, + matches.value_of("host").unwrap(), + matches.value_of("port").unwrap()); + let client = if is_https { // Using Simple HTTPS - fatcat::Client::try_new_https(core.handle(), &base_url, "examples/ca.pem") + fatcat::Client::try_new_https(&base_url, "examples/ca.pem") .expect("Failed to create HTTPS client") } else { // Using HTTP - fatcat::Client::try_new_http(core.handle(), &base_url) + fatcat::Client::try_new_http(&base_url) .expect("Failed to create HTTP client") }; // Using a non-default `Context` is not required; this is just an example! - let client = client.with_context(fatcat::Context::new_with_span_id( - self::uuid::Uuid::new_v4().to_string(), - )); + let client = client.with_context(fatcat::Context::new_with_span_id(self::uuid::Uuid::new_v4().to_string())); match matches.value_of("operation") { + Some("ContainerIdGet") => { - let result = core.run(client.container_id_get("id_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.container_id_get("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("ContainerLookupGet") => { - let result = core.run(client.container_lookup_get("issn_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.container_lookup_get("issn_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("ContainerPost") => { - let result = core.run(client.container_post(None)); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.container_post(None).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("CreatorIdGet") => { - let result = core.run(client.creator_id_get("id_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.creator_id_get("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("CreatorLookupGet") => { - let result = core.run(client.creator_lookup_get("orcid_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.creator_lookup_get("orcid_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("CreatorPost") => { - let result = core.run(client.creator_post(None)); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.creator_post(None).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("EditgroupIdAcceptPost") => { - let result = core.run(client.editgroup_id_accept_post(56)); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.editgroup_id_accept_post(56).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("EditgroupIdGet") => { - let result = core.run(client.editgroup_id_get(56)); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.editgroup_id_get(56).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("EditgroupPost") => { - let result = core.run(client.editgroup_post()); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.editgroup_post().wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("EditorUsernameChangelogGet") => { - let result = - core.run(client.editor_username_changelog_get("username_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.editor_username_changelog_get("username_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("EditorUsernameGet") => { - let result = core.run(client.editor_username_get("username_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.editor_username_get("username_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("FileIdGet") => { - let result = core.run(client.file_id_get("id_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.file_id_get("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("FileLookupGet") => { - let result = core.run(client.file_lookup_get("sha1_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.file_lookup_get("sha1_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("FilePost") => { - let result = core.run(client.file_post(None)); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.file_post(None).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("ReleaseIdGet") => { - let result = core.run(client.release_id_get("id_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.release_id_get("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("ReleaseLookupGet") => { - let result = core.run(client.release_lookup_get("doi_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.release_lookup_get("doi_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("ReleasePost") => { - let result = core.run(client.release_post(None)); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.release_post(None).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("WorkIdGet") => { - let result = core.run(client.work_id_get("id_example".to_string())); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.work_id_get("id_example".to_string()).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, Some("WorkPost") => { - let result = core.run(client.work_post(None)); - println!( - "{:?} (X-Span-ID: {:?})", - result, - client - .context() - .x_span_id - .clone() - .unwrap_or(String::from("<none>")) - ); - } + let result = client.work_post(None).wait(); + println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>"))); + }, - _ => panic!("Invalid operation provided"), + _ => { + panic!("Invalid operation provided") + } } } + diff --git a/rust/fatcat-api/examples/server.rs b/rust/fatcat-api/examples/server.rs index f9b8617c..79d7367e 100644 --- a/rust/fatcat-api/examples/server.rs +++ b/rust/fatcat-api/examples/server.rs @@ -4,35 +4,32 @@ // Imports required by this file. // extern crate <name of this crate>; -extern crate clap; extern crate fatcat; -extern crate hyper; -extern crate native_tls; -extern crate openssl; extern crate swagger; -extern crate tokio_proto; -extern crate tokio_tls; +extern crate iron; +extern crate hyper_openssl; +extern crate clap; // Imports required by server library. // extern crate fatcat; // extern crate swagger; -extern crate chrono; extern crate futures; +extern crate chrono; #[macro_use] extern crate error_chain; +use hyper_openssl::OpensslServer; +use hyper_openssl::openssl::x509::X509_FILETYPE_PEM; +use hyper_openssl::openssl::ssl::{SslAcceptorBuilder, SslMethod}; +use hyper_openssl::openssl::error::ErrorStack; use clap::{App, Arg}; -use hyper::server::Http; -use openssl::error::ErrorStack; -use openssl::ssl::{SslAcceptorBuilder, SslMethod}; -use openssl::x509::X509_FILETYPE_PEM; -use swagger::auth::AllowAllAuthenticator; -use tokio_proto::TcpServer; +use iron::{Iron, Chain}; +use swagger::auth::AllowAllMiddleware; mod server_lib; -// Builds an SSL implementation for Simple HTTPS from some hard-coded file names -fn ssl() -> Result<SslAcceptorBuilder, ErrorStack> { +/// Builds an SSL implementation for Simple HTTPS from some hard-coded file names +fn ssl() -> Result<OpensslServer, ErrorStack> { let mut ssl = SslAcceptorBuilder::mozilla_intermediate_raw(SslMethod::tls())?; // Server authentication @@ -40,39 +37,32 @@ fn ssl() -> Result<SslAcceptorBuilder, ErrorStack> { ssl.set_certificate_chain_file("examples/server-chain.pem")?; ssl.check_private_key()?; - Ok(ssl) + Ok(OpensslServer::from(ssl.build())) } /// Create custom server, wire it to the autogenerated router, /// and pass it to the web server. fn main() { let matches = App::new("server") - .arg( - Arg::with_name("https") - .long("https") - .help("Whether to use HTTPS or not"), - ) + .arg(Arg::with_name("https") + .long("https") + .help("Whether to use HTTPS or not")) .get_matches(); - let service_fn = fatcat::server::auth::NewService::new(AllowAllAuthenticator::new( - server_lib::NewService, - "cosmo", - )); + let server = server_lib::server().unwrap(); + let router = fatcat::router(server); + + let mut chain = Chain::new(router); + chain.link_before(fatcat::server::ExtractAuthData); + // add authentication middlewares into the chain here + // for the purpose of this example, pretend we have authenticated a user + chain.link_before(AllowAllMiddleware::new("cosmo")); - let addr = "127.0.0.1:8080" - .parse() - .expect("Failed to parse bind address"); if matches.is_present("https") { - let ssl = ssl().expect("Failed to load SSL keys"); - let builder: native_tls::TlsAcceptorBuilder = - native_tls::backend::openssl::TlsAcceptorBuilderExt::from_openssl(ssl); - let tls_acceptor = builder.build().expect("Failed to build TLS acceptor"); - TcpServer::new( - tokio_tls::proto::Server::new(Http::new(), tls_acceptor), - addr, - ).serve(service_fn); + // Using Simple HTTPS + Iron::new(chain).https("localhost:8080", ssl().expect("Failed to load SSL keys")).expect("Failed to start HTTPS server"); } else { // Using HTTP - TcpServer::new(Http::new(), addr).serve(service_fn); + Iron::new(chain).http("localhost:8080").expect("Failed to start HTTP server"); } } diff --git a/rust/fatcat-api/examples/server_lib/mod.rs b/rust/fatcat-api/examples/server_lib/mod.rs index a45fbe50..5291637e 100644 --- a/rust/fatcat-api/examples/server_lib/mod.rs +++ b/rust/fatcat-api/examples/server_lib/mod.rs @@ -7,20 +7,8 @@ mod errors { } pub use self::errors::*; -use fatcat; -use hyper; -use std::io; -pub struct NewService; - -impl hyper::server::NewService for NewService { - type Request = (hyper::Request, fatcat::Context); - type Response = hyper::Response; - type Error = hyper::Error; - type Instance = fatcat::server::Service<server::Server>; - - /// Instantiate a new server. - fn new_service(&self) -> io::Result<Self::Instance> { - Ok(fatcat::server::Service::new(server::Server)) - } +/// Instantiate a new server. +pub fn server() -> Result<server::Server> { + Ok(server::Server {}) } diff --git a/rust/fatcat-api/examples/server_lib/server.rs b/rust/fatcat-api/examples/server_lib/server.rs index 0dec7ed3..58414e31 100644 --- a/rust/fatcat-api/examples/server_lib/server.rs +++ b/rust/fatcat-api/examples/server_lib/server.rs @@ -2,286 +2,172 @@ #![allow(unused_imports)] -use chrono; use futures::{self, Future}; +use chrono; use std::collections::HashMap; use swagger; +use fatcat::{Api, ApiError, Context, + ContainerIdGetResponse, + ContainerLookupGetResponse, + ContainerPostResponse, + CreatorIdGetResponse, + CreatorLookupGetResponse, + CreatorPostResponse, + EditgroupIdAcceptPostResponse, + EditgroupIdGetResponse, + EditgroupPostResponse, + EditorUsernameChangelogGetResponse, + EditorUsernameGetResponse, + FileIdGetResponse, + FileLookupGetResponse, + FilePostResponse, + ReleaseIdGetResponse, + ReleaseLookupGetResponse, + ReleasePostResponse, + WorkIdGetResponse, + WorkPostResponse +}; use fatcat::models; -use fatcat::{Api, ApiError, ContainerIdGetResponse, ContainerLookupGetResponse, - ContainerPostResponse, Context, CreatorIdGetResponse, CreatorLookupGetResponse, - CreatorPostResponse, EditgroupIdAcceptPostResponse, EditgroupIdGetResponse, - EditgroupPostResponse, EditorUsernameChangelogGetResponse, EditorUsernameGetResponse, - FileIdGetResponse, FileLookupGetResponse, FilePostResponse, ReleaseIdGetResponse, - ReleaseLookupGetResponse, ReleasePostResponse, WorkIdGetResponse, WorkPostResponse}; #[derive(Copy, Clone)] pub struct Server; impl Api for Server { - fn container_id_get( - &self, - id: String, - context: &Context, - ) -> Box<Future<Item = ContainerIdGetResponse, Error = ApiError>> { + + + fn container_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ContainerIdGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "container_id_get(\"{}\") - X-Span-ID: {:?}", - id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("container_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn container_lookup_get( - &self, - issn: String, - context: &Context, - ) -> Box<Future<Item = ContainerLookupGetResponse, Error = ApiError>> { + + fn container_lookup_get(&self, issn: String, context: &Context) -> Box<Future<Item=ContainerLookupGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "container_lookup_get(\"{}\") - X-Span-ID: {:?}", - issn, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("container_lookup_get(\"{}\") - X-Span-ID: {:?}", issn, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn container_post( - &self, - body: Option<models::ContainerEntity>, - context: &Context, - ) -> Box<Future<Item = ContainerPostResponse, Error = ApiError>> { + + fn container_post(&self, body: Option<models::ContainerEntity>, context: &Context) -> Box<Future<Item=ContainerPostResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "container_post({:?}) - X-Span-ID: {:?}", - body, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("container_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn creator_id_get( - &self, - id: String, - context: &Context, - ) -> Box<Future<Item = CreatorIdGetResponse, Error = ApiError>> { + + fn creator_id_get(&self, id: String, context: &Context) -> Box<Future<Item=CreatorIdGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "creator_id_get(\"{}\") - X-Span-ID: {:?}", - id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("creator_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn creator_lookup_get( - &self, - orcid: String, - context: &Context, - ) -> Box<Future<Item = CreatorLookupGetResponse, Error = ApiError>> { + + fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box<Future<Item=CreatorLookupGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "creator_lookup_get(\"{}\") - X-Span-ID: {:?}", - orcid, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("creator_lookup_get(\"{}\") - X-Span-ID: {:?}", orcid, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn creator_post( - &self, - body: Option<models::CreatorEntity>, - context: &Context, - ) -> Box<Future<Item = CreatorPostResponse, Error = ApiError>> { + + fn creator_post(&self, body: Option<models::CreatorEntity>, context: &Context) -> Box<Future<Item=CreatorPostResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "creator_post({:?}) - X-Span-ID: {:?}", - body, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("creator_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn editgroup_id_accept_post( - &self, - id: i32, - context: &Context, - ) -> Box<Future<Item = EditgroupIdAcceptPostResponse, Error = ApiError>> { + + fn editgroup_id_accept_post(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdAcceptPostResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "editgroup_id_accept_post({}) - X-Span-ID: {:?}", - id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("editgroup_id_accept_post({}) - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn editgroup_id_get( - &self, - id: i32, - context: &Context, - ) -> Box<Future<Item = EditgroupIdGetResponse, Error = ApiError>> { + + fn editgroup_id_get(&self, id: i32, context: &Context) -> Box<Future<Item=EditgroupIdGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "editgroup_id_get({}) - X-Span-ID: {:?}", - id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("editgroup_id_get({}) - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn editgroup_post( - &self, - context: &Context, - ) -> Box<Future<Item = EditgroupPostResponse, Error = ApiError>> { + + fn editgroup_post(&self, context: &Context) -> Box<Future<Item=EditgroupPostResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "editgroup_post() - X-Span-ID: {:?}", - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("editgroup_post() - X-Span-ID: {:?}", context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn editor_username_changelog_get( - &self, - username: String, - context: &Context, - ) -> Box<Future<Item = EditorUsernameChangelogGetResponse, Error = ApiError>> { + + fn editor_username_changelog_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameChangelogGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "editor_username_changelog_get(\"{}\") - X-Span-ID: {:?}", - username, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("editor_username_changelog_get(\"{}\") - X-Span-ID: {:?}", username, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn editor_username_get( - &self, - username: String, - context: &Context, - ) -> Box<Future<Item = EditorUsernameGetResponse, Error = ApiError>> { + + fn editor_username_get(&self, username: String, context: &Context) -> Box<Future<Item=EditorUsernameGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "editor_username_get(\"{}\") - X-Span-ID: {:?}", - username, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("editor_username_get(\"{}\") - X-Span-ID: {:?}", username, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn file_id_get( - &self, - id: String, - context: &Context, - ) -> Box<Future<Item = FileIdGetResponse, Error = ApiError>> { + + fn file_id_get(&self, id: String, context: &Context) -> Box<Future<Item=FileIdGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "file_id_get(\"{}\") - X-Span-ID: {:?}", - id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("file_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn file_lookup_get( - &self, - sha1: String, - context: &Context, - ) -> Box<Future<Item = FileLookupGetResponse, Error = ApiError>> { + + fn file_lookup_get(&self, sha1: String, context: &Context) -> Box<Future<Item=FileLookupGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "file_lookup_get(\"{}\") - X-Span-ID: {:?}", - sha1, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("file_lookup_get(\"{}\") - X-Span-ID: {:?}", sha1, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn file_post( - &self, - body: Option<models::FileEntity>, - context: &Context, - ) -> Box<Future<Item = FilePostResponse, Error = ApiError>> { + + fn file_post(&self, body: Option<models::FileEntity>, context: &Context) -> Box<Future<Item=FilePostResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "file_post({:?}) - X-Span-ID: {:?}", - body, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("file_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn release_id_get( - &self, - id: String, - context: &Context, - ) -> Box<Future<Item = ReleaseIdGetResponse, Error = ApiError>> { + + fn release_id_get(&self, id: String, context: &Context) -> Box<Future<Item=ReleaseIdGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "release_id_get(\"{}\") - X-Span-ID: {:?}", - id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("release_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn release_lookup_get( - &self, - doi: String, - context: &Context, - ) -> Box<Future<Item = ReleaseLookupGetResponse, Error = ApiError>> { + + fn release_lookup_get(&self, doi: String, context: &Context) -> Box<Future<Item=ReleaseLookupGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "release_lookup_get(\"{}\") - X-Span-ID: {:?}", - doi, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("release_lookup_get(\"{}\") - X-Span-ID: {:?}", doi, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn release_post( - &self, - body: Option<models::ReleaseEntity>, - context: &Context, - ) -> Box<Future<Item = ReleasePostResponse, Error = ApiError>> { + + fn release_post(&self, body: Option<models::ReleaseEntity>, context: &Context) -> Box<Future<Item=ReleasePostResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "release_post({:?}) - X-Span-ID: {:?}", - body, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("release_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn work_id_get( - &self, - id: String, - context: &Context, - ) -> Box<Future<Item = WorkIdGetResponse, Error = ApiError>> { + + fn work_id_get(&self, id: String, context: &Context) -> Box<Future<Item=WorkIdGetResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "work_id_get(\"{}\") - X-Span-ID: {:?}", - id, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("work_id_get(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } - fn work_post( - &self, - body: Option<models::WorkEntity>, - context: &Context, - ) -> Box<Future<Item = WorkPostResponse, Error = ApiError>> { + + fn work_post(&self, body: Option<models::WorkEntity>, context: &Context) -> Box<Future<Item=WorkPostResponse, Error=ApiError> + Send> { let context = context.clone(); - println!( - "work_post({:?}) - X-Span-ID: {:?}", - body, - context.x_span_id.unwrap_or(String::from("<none>")).clone() - ); + println!("work_post({:?}) - X-Span-ID: {:?}", body, context.x_span_id.unwrap_or(String::from("<none>")).clone()); Box::new(futures::failed("Generic failure".into())) } + } |