From 2c56f2b65bcf3b3f85db9d2a34501154c9c9404d Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 14 May 2018 23:17:26 -0700 Subject: regenerated and pseudo-integrated --- rust/fatcat-api/examples/server_lib/mod.rs | 26 +++ rust/fatcat-api/examples/server_lib/server.rs | 287 ++++++++++++++++++++++++++ 2 files changed, 313 insertions(+) create mode 100644 rust/fatcat-api/examples/server_lib/mod.rs create mode 100644 rust/fatcat-api/examples/server_lib/server.rs (limited to 'rust/fatcat-api/examples/server_lib') diff --git a/rust/fatcat-api/examples/server_lib/mod.rs b/rust/fatcat-api/examples/server_lib/mod.rs new file mode 100644 index 00000000..a45fbe50 --- /dev/null +++ b/rust/fatcat-api/examples/server_lib/mod.rs @@ -0,0 +1,26 @@ +//! Main library entry point for fatcat implementation. + +mod server; + +mod errors { + error_chain!{} +} + +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; + + /// Instantiate a new server. + fn new_service(&self) -> io::Result { + Ok(fatcat::server::Service::new(server::Server)) + } +} diff --git a/rust/fatcat-api/examples/server_lib/server.rs b/rust/fatcat-api/examples/server_lib/server.rs new file mode 100644 index 00000000..0dec7ed3 --- /dev/null +++ b/rust/fatcat-api/examples/server_lib/server.rs @@ -0,0 +1,287 @@ +//! Server implementation of fatcat. + +#![allow(unused_imports)] + +use chrono; +use futures::{self, Future}; + +use std::collections::HashMap; + +use swagger; + +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> { + let context = context.clone(); + println!( + "container_id_get(\"{}\") - X-Span-ID: {:?}", + id, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn container_lookup_get( + &self, + issn: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "container_lookup_get(\"{}\") - X-Span-ID: {:?}", + issn, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn container_post( + &self, + body: Option, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "container_post({:?}) - X-Span-ID: {:?}", + body, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn creator_id_get( + &self, + id: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "creator_id_get(\"{}\") - X-Span-ID: {:?}", + id, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn creator_lookup_get( + &self, + orcid: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "creator_lookup_get(\"{}\") - X-Span-ID: {:?}", + orcid, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn creator_post( + &self, + body: Option, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "creator_post({:?}) - X-Span-ID: {:?}", + body, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn editgroup_id_accept_post( + &self, + id: i32, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "editgroup_id_accept_post({}) - X-Span-ID: {:?}", + id, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn editgroup_id_get( + &self, + id: i32, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "editgroup_id_get({}) - X-Span-ID: {:?}", + id, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn editgroup_post( + &self, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "editgroup_post() - X-Span-ID: {:?}", + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn editor_username_changelog_get( + &self, + username: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "editor_username_changelog_get(\"{}\") - X-Span-ID: {:?}", + username, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn editor_username_get( + &self, + username: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "editor_username_get(\"{}\") - X-Span-ID: {:?}", + username, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn file_id_get( + &self, + id: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "file_id_get(\"{}\") - X-Span-ID: {:?}", + id, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn file_lookup_get( + &self, + sha1: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "file_lookup_get(\"{}\") - X-Span-ID: {:?}", + sha1, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn file_post( + &self, + body: Option, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "file_post({:?}) - X-Span-ID: {:?}", + body, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn release_id_get( + &self, + id: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "release_id_get(\"{}\") - X-Span-ID: {:?}", + id, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn release_lookup_get( + &self, + doi: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "release_lookup_get(\"{}\") - X-Span-ID: {:?}", + doi, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn release_post( + &self, + body: Option, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "release_post({:?}) - X-Span-ID: {:?}", + body, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn work_id_get( + &self, + id: String, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "work_id_get(\"{}\") - X-Span-ID: {:?}", + id, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } + + fn work_post( + &self, + body: Option, + context: &Context, + ) -> Box> { + let context = context.clone(); + println!( + "work_post({:?}) - X-Span-ID: {:?}", + body, + context.x_span_id.unwrap_or(String::from("")).clone() + ); + Box::new(futures::failed("Generic failure".into())) + } +} -- cgit v1.2.3