aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api/examples/server_lib
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-15 00:33:33 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-15 00:33:36 -0700
commit33a4cce0b97832f5f0301b318a0a50073ce6b615 (patch)
tree1b6ba7ec5944d2be2d746510e743a7934f453cd0 /rust/fatcat-api/examples/server_lib
parent4a1d8f20ab91fda0f4794131144915d0c5214268 (diff)
downloadfatcat-33a4cce0b97832f5f0301b318a0a50073ce6b615.tar.gz
fatcat-33a4cce0b97832f5f0301b318a0a50073ce6b615.zip
revert to v2.3.1 codegen
This reverts back to something compatible with Iron and simple (blocking) parallelism, instead of the new async hyper 0.11 stuff.
Diffstat (limited to 'rust/fatcat-api/examples/server_lib')
-rw-r--r--rust/fatcat-api/examples/server_lib/mod.rs18
-rw-r--r--rust/fatcat-api/examples/server_lib/server.rs276
2 files changed, 84 insertions, 210 deletions
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()))
}
+
}