From 33a4cce0b97832f5f0301b318a0a50073ce6b615 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 May 2018 00:33:33 -0700 Subject: 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. --- rust/fatcat-api/src/lib.rs | 565 ++++++++++++++++++--------------------------- 1 file changed, 226 insertions(+), 339 deletions(-) (limited to 'rust/fatcat-api/src/lib.rs') diff --git a/rust/fatcat-api/src/lib.rs b/rust/fatcat-api/src/lib.rs index 36573537..e695daa7 100644 --- a/rust/fatcat-api/src/lib.rs +++ b/rust/fatcat-api/src/lib.rs @@ -1,12 +1,12 @@ -#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, - unused_extern_crates, non_camel_case_types)] +#![allow(missing_docs, trivial_casts, unused_variables, unused_mut, unused_imports, unused_extern_crates, non_camel_case_types)] extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; -extern crate chrono; extern crate futures; +extern crate chrono; + #[macro_use] extern crate lazy_static; #[macro_use] @@ -32,554 +32,441 @@ mod mimetypes; pub use swagger::{ApiError, Context, ContextWrapper}; -pub const BASE_PATH: &'static str = "/v0"; -pub const API_VERSION: &'static str = "0.1.0"; #[derive(Debug, PartialEq)] pub enum ContainerIdGetResponse { /// fetch a single container by id - FetchASingleContainerById(models::ContainerEntity), + FetchASingleContainerById ( models::ContainerEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum ContainerLookupGetResponse { /// find a single container by external identifer - FindASingleContainerByExternalIdentifer(models::ContainerEntity), + FindASingleContainerByExternalIdentifer ( models::ContainerEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// no such container - NoSuchContainer(models::Error), + NoSuchContainer ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum ContainerPostResponse { /// created - Created(models::EntityEdit), + Created ( models::EntityEdit ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum CreatorIdGetResponse { /// fetch a single creator by id - FetchASingleCreatorById(models::CreatorEntity), + FetchASingleCreatorById ( models::CreatorEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum CreatorLookupGetResponse { /// find a single creator by external identifer - FindASingleCreatorByExternalIdentifer(models::CreatorEntity), + FindASingleCreatorByExternalIdentifer ( models::CreatorEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// no such creator - NoSuchCreator(models::Error), + NoSuchCreator ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum CreatorPostResponse { /// created - Created(models::EntityEdit), + Created ( models::EntityEdit ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum EditgroupIdAcceptPostResponse { /// merged editgroup successfully (\"live\") - MergedEditgroupSuccessfully_(models::Success), + MergedEditgroupSuccessfully_ ( models::Success ) , /// editgroup is in an unmergable state - EditgroupIsInAnUnmergableState(models::Error), + EditgroupIsInAnUnmergableState ( models::Error ) , /// no such editgroup - NoSuchEditgroup(models::Error), + NoSuchEditgroup ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum EditgroupIdGetResponse { /// fetch editgroup by identifier - FetchEditgroupByIdentifier(models::Editgroup), + FetchEditgroupByIdentifier ( models::Editgroup ) , /// no such editgroup - NoSuchEditgroup(models::Error), + NoSuchEditgroup ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum EditgroupPostResponse { /// successfully created - SuccessfullyCreated(models::Editgroup), + SuccessfullyCreated ( models::Editgroup ) , /// invalid request parameters - InvalidRequestParameters(models::Error), + InvalidRequestParameters ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum EditorUsernameChangelogGetResponse { /// find changes (editgroups) by this editor which have been merged - FindChanges_(models::Changelogentry), + FindChanges_ ( models::Changelogentry ) , /// username not found - UsernameNotFound(models::Error), + UsernameNotFound ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum EditorUsernameGetResponse { /// fetch generic information about an editor - FetchGenericInformationAboutAnEditor(models::Editor), + FetchGenericInformationAboutAnEditor ( models::Editor ) , /// username not found - UsernameNotFound(models::Error), + UsernameNotFound ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum FileIdGetResponse { /// fetch a single file by id - FetchASingleFileById(models::FileEntity), + FetchASingleFileById ( models::FileEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum FileLookupGetResponse { /// find a single file by external identifer - FindASingleFileByExternalIdentifer(models::FileEntity), + FindASingleFileByExternalIdentifer ( models::FileEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// no such file - NoSuchFile(models::Error), + NoSuchFile ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum FilePostResponse { /// created - Created(models::EntityEdit), + Created ( models::EntityEdit ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum ReleaseIdGetResponse { /// fetch a single release by id - FetchASingleReleaseById(models::ReleaseEntity), + FetchASingleReleaseById ( models::ReleaseEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum ReleaseLookupGetResponse { /// find a single release by external identifer - FindASingleReleaseByExternalIdentifer(models::ReleaseEntity), + FindASingleReleaseByExternalIdentifer ( models::ReleaseEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// no such release - NoSuchRelease(models::Error), + NoSuchRelease ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum ReleasePostResponse { /// created - Created(models::EntityEdit), + Created ( models::EntityEdit ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum WorkIdGetResponse { /// fetch a single work by id - FetchASingleWorkById(models::WorkEntity), + FetchASingleWorkById ( models::WorkEntity ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } #[derive(Debug, PartialEq)] pub enum WorkPostResponse { /// created - Created(models::EntityEdit), + Created ( models::EntityEdit ) , /// bad request - BadRequest(models::Error), + BadRequest ( models::Error ) , /// generic error response - GenericErrorResponse(models::Error), + GenericErrorResponse ( models::Error ) , } + /// API pub trait Api { - fn container_id_get( - &self, - id: String, - context: &Context, - ) -> Box>; - - fn container_lookup_get( - &self, - issn: String, - context: &Context, - ) -> Box>; - - fn container_post( - &self, - body: Option, - context: &Context, - ) -> Box>; - - fn creator_id_get( - &self, - id: String, - context: &Context, - ) -> Box>; - - fn creator_lookup_get( - &self, - orcid: String, - context: &Context, - ) -> Box>; - - fn creator_post( - &self, - body: Option, - context: &Context, - ) -> Box>; - - fn editgroup_id_accept_post( - &self, - id: i32, - context: &Context, - ) -> Box>; - - fn editgroup_id_get( - &self, - id: i32, - context: &Context, - ) -> Box>; - - fn editgroup_post( - &self, - context: &Context, - ) -> Box>; - - fn editor_username_changelog_get( - &self, - username: String, - context: &Context, - ) -> Box>; - - fn editor_username_get( - &self, - username: String, - context: &Context, - ) -> Box>; - - fn file_id_get( - &self, - id: String, - context: &Context, - ) -> Box>; - - fn file_lookup_get( - &self, - sha1: String, - context: &Context, - ) -> Box>; - - fn file_post( - &self, - body: Option, - context: &Context, - ) -> Box>; - - fn release_id_get( - &self, - id: String, - context: &Context, - ) -> Box>; - - fn release_lookup_get( - &self, - doi: String, - context: &Context, - ) -> Box>; - - fn release_post( - &self, - body: Option, - context: &Context, - ) -> Box>; - - fn work_id_get( - &self, - id: String, - context: &Context, - ) -> Box>; - - fn work_post( - &self, - body: Option, - context: &Context, - ) -> Box>; + + + fn container_id_get(&self, id: String, context: &Context) -> Box + Send>; + + + fn container_lookup_get(&self, issn: String, context: &Context) -> Box + Send>; + + + fn container_post(&self, body: Option, context: &Context) -> Box + Send>; + + + fn creator_id_get(&self, id: String, context: &Context) -> Box + Send>; + + + fn creator_lookup_get(&self, orcid: String, context: &Context) -> Box + Send>; + + + fn creator_post(&self, body: Option, context: &Context) -> Box + Send>; + + + fn editgroup_id_accept_post(&self, id: i32, context: &Context) -> Box + Send>; + + + fn editgroup_id_get(&self, id: i32, context: &Context) -> Box + Send>; + + + fn editgroup_post(&self, context: &Context) -> Box + Send>; + + + fn editor_username_changelog_get(&self, username: String, context: &Context) -> Box + Send>; + + + fn editor_username_get(&self, username: String, context: &Context) -> Box + Send>; + + + fn file_id_get(&self, id: String, context: &Context) -> Box + Send>; + + + fn file_lookup_get(&self, sha1: String, context: &Context) -> Box + Send>; + + + fn file_post(&self, body: Option, context: &Context) -> Box + Send>; + + + fn release_id_get(&self, id: String, context: &Context) -> Box + Send>; + + + fn release_lookup_get(&self, doi: String, context: &Context) -> Box + Send>; + + + fn release_post(&self, body: Option, context: &Context) -> Box + Send>; + + + fn work_id_get(&self, id: String, context: &Context) -> Box + Send>; + + + fn work_post(&self, body: Option, context: &Context) -> Box + Send>; + } /// API without a `Context` pub trait ApiNoContext { - fn container_id_get( - &self, - id: String, - ) -> Box>; - - fn container_lookup_get( - &self, - issn: String, - ) -> Box>; - - fn container_post( - &self, - body: Option, - ) -> Box>; - - fn creator_id_get( - &self, - id: String, - ) -> Box>; - - fn creator_lookup_get( - &self, - orcid: String, - ) -> Box>; - - fn creator_post( - &self, - body: Option, - ) -> Box>; - - fn editgroup_id_accept_post( - &self, - id: i32, - ) -> Box>; - - fn editgroup_id_get( - &self, - id: i32, - ) -> Box>; - - fn editgroup_post(&self) -> Box>; - - fn editor_username_changelog_get( - &self, - username: String, - ) -> Box>; - - fn editor_username_get( - &self, - username: String, - ) -> Box>; - - fn file_id_get(&self, id: String) -> Box>; - - fn file_lookup_get( - &self, - sha1: String, - ) -> Box>; - - fn file_post( - &self, - body: Option, - ) -> Box>; - - fn release_id_get( - &self, - id: String, - ) -> Box>; - - fn release_lookup_get( - &self, - doi: String, - ) -> Box>; - - fn release_post( - &self, - body: Option, - ) -> Box>; - - fn work_id_get(&self, id: String) -> Box>; - - fn work_post( - &self, - body: Option, - ) -> Box>; + + + fn container_id_get(&self, id: String) -> Box + Send>; + + + fn container_lookup_get(&self, issn: String) -> Box + Send>; + + + fn container_post(&self, body: Option) -> Box + Send>; + + + fn creator_id_get(&self, id: String) -> Box + Send>; + + + fn creator_lookup_get(&self, orcid: String) -> Box + Send>; + + + fn creator_post(&self, body: Option) -> Box + Send>; + + + fn editgroup_id_accept_post(&self, id: i32) -> Box + Send>; + + + fn editgroup_id_get(&self, id: i32) -> Box + Send>; + + + fn editgroup_post(&self) -> Box + Send>; + + + fn editor_username_changelog_get(&self, username: String) -> Box + Send>; + + + fn editor_username_get(&self, username: String) -> Box + Send>; + + + fn file_id_get(&self, id: String) -> Box + Send>; + + + fn file_lookup_get(&self, sha1: String) -> Box + Send>; + + + fn file_post(&self, body: Option) -> Box + Send>; + + + fn release_id_get(&self, id: String) -> Box + Send>; + + + fn release_lookup_get(&self, doi: String) -> Box + Send>; + + + fn release_post(&self, body: Option) -> Box + Send>; + + + fn work_id_get(&self, id: String) -> Box + Send>; + + + fn work_post(&self, body: Option) -> Box + Send>; + } /// Trait to extend an API to make it easy to bind it to a context. -pub trait ContextWrapperExt<'a> -where - Self: Sized, -{ +pub trait ContextWrapperExt<'a> where Self: Sized { /// Binds this API to a context. fn with_context(self: &'a Self, context: Context) -> ContextWrapper<'a, Self>; } impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T { fn with_context(self: &'a T, context: Context) -> ContextWrapper<'a, T> { - ContextWrapper::::new(self, context) + ContextWrapper::::new(self, context) } } impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> { - fn container_id_get( - &self, - id: String, - ) -> Box> { + + + fn container_id_get(&self, id: String) -> Box + Send> { self.api().container_id_get(id, &self.context()) } - fn container_lookup_get( - &self, - issn: String, - ) -> Box> { + + fn container_lookup_get(&self, issn: String) -> Box + Send> { self.api().container_lookup_get(issn, &self.context()) } - fn container_post( - &self, - body: Option, - ) -> Box> { + + fn container_post(&self, body: Option) -> Box + Send> { self.api().container_post(body, &self.context()) } - fn creator_id_get( - &self, - id: String, - ) -> Box> { + + fn creator_id_get(&self, id: String) -> Box + Send> { self.api().creator_id_get(id, &self.context()) } - fn creator_lookup_get( - &self, - orcid: String, - ) -> Box> { + + fn creator_lookup_get(&self, orcid: String) -> Box + Send> { self.api().creator_lookup_get(orcid, &self.context()) } - fn creator_post( - &self, - body: Option, - ) -> Box> { + + fn creator_post(&self, body: Option) -> Box + Send> { self.api().creator_post(body, &self.context()) } - fn editgroup_id_accept_post( - &self, - id: i32, - ) -> Box> { + + fn editgroup_id_accept_post(&self, id: i32) -> Box + Send> { self.api().editgroup_id_accept_post(id, &self.context()) } - fn editgroup_id_get( - &self, - id: i32, - ) -> Box> { + + fn editgroup_id_get(&self, id: i32) -> Box + Send> { self.api().editgroup_id_get(id, &self.context()) } - fn editgroup_post(&self) -> Box> { + + fn editgroup_post(&self) -> Box + Send> { self.api().editgroup_post(&self.context()) } - fn editor_username_changelog_get( - &self, - username: String, - ) -> Box> { - self.api() - .editor_username_changelog_get(username, &self.context()) + + fn editor_username_changelog_get(&self, username: String) -> Box + Send> { + self.api().editor_username_changelog_get(username, &self.context()) } - fn editor_username_get( - &self, - username: String, - ) -> Box> { + + fn editor_username_get(&self, username: String) -> Box + Send> { self.api().editor_username_get(username, &self.context()) } - fn file_id_get(&self, id: String) -> Box> { + + fn file_id_get(&self, id: String) -> Box + Send> { self.api().file_id_get(id, &self.context()) } - fn file_lookup_get( - &self, - sha1: String, - ) -> Box> { + + fn file_lookup_get(&self, sha1: String) -> Box + Send> { self.api().file_lookup_get(sha1, &self.context()) } - fn file_post( - &self, - body: Option, - ) -> Box> { + + fn file_post(&self, body: Option) -> Box + Send> { self.api().file_post(body, &self.context()) } - fn release_id_get( - &self, - id: String, - ) -> Box> { + + fn release_id_get(&self, id: String) -> Box + Send> { self.api().release_id_get(id, &self.context()) } - fn release_lookup_get( - &self, - doi: String, - ) -> Box> { + + fn release_lookup_get(&self, doi: String) -> Box + Send> { self.api().release_lookup_get(doi, &self.context()) } - fn release_post( - &self, - body: Option, - ) -> Box> { + + fn release_post(&self, body: Option) -> Box + Send> { self.api().release_post(body, &self.context()) } - fn work_id_get(&self, id: String) -> Box> { + + fn work_id_get(&self, id: String) -> Box + Send> { self.api().work_id_get(id, &self.context()) } - fn work_post( - &self, - body: Option, - ) -> Box> { + + fn work_post(&self, body: Option) -> Box + Send> { self.api().work_post(body, &self.context()) } + } #[cfg(feature = "client")] @@ -594,6 +481,6 @@ pub mod server; // Re-export router() as a top-level name #[cfg(feature = "server")] -pub use self::server::Service; +pub use self::server::router; pub mod models; -- cgit v1.2.3