From f6b7f0afbee988f46ee8f23c8c81224c65407679 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 14 Dec 2018 17:36:08 +0800 Subject: rust codegen --- rust/fatcat-api-spec/examples/client.rs | 29 ++++++++++++++---- rust/fatcat-api-spec/examples/server_lib/mod.rs | 2 +- rust/fatcat-api-spec/examples/server_lib/server.rs | 34 ++++++++++++++++++---- 3 files changed, 52 insertions(+), 13 deletions(-) (limited to 'rust/fatcat-api-spec/examples') diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs index f2d7a859..91ac7a4e 100644 --- a/rust/fatcat-api-spec/examples/client.rs +++ b/rust/fatcat-api-spec/examples/client.rs @@ -85,9 +85,11 @@ fn main() { "GetWorkRedirects", "GetWorkReleases", "GetWorkRevision", - ]).required(true) + ]) + .required(true) .index(1), - ).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")) .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(); @@ -162,7 +164,12 @@ fn main() { Some("LookupContainer") => { let result = client - .lookup_container(Some("issnl_example".to_string()), Some("wikidata_qid_example".to_string()), Some("hide_example".to_string())) + .lookup_container( + Some("issnl_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + ) .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -229,7 +236,12 @@ fn main() { Some("LookupCreator") => { let result = client - .lookup_creator(Some("orcid_example".to_string()), Some("wikidata_qid_example".to_string()), Some("hide_example".to_string())) + .lookup_creator( + Some("orcid_example".to_string()), + Some("wikidata_qid_example".to_string()), + Some("expand_example".to_string()), + Some("hide_example".to_string()), + ) .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -332,8 +344,10 @@ fn main() { Some("md5_example".to_string()), Some("sha1_example".to_string()), Some("sha256_example".to_string()), + Some("expand_example".to_string()), Some("hide_example".to_string()), - ).wait(); + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } @@ -410,8 +424,11 @@ fn main() { Some("isbn13_example".to_string()), Some("pmid_example".to_string()), Some("pmcid_example".to_string()), + Some("core_id_example".to_string()), + Some("expand_example".to_string()), Some("hide_example".to_string()), - ).wait(); + ) + .wait(); println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from(""))); } diff --git a/rust/fatcat-api-spec/examples/server_lib/mod.rs b/rust/fatcat-api-spec/examples/server_lib/mod.rs index 5291637e..bf404d49 100644 --- a/rust/fatcat-api-spec/examples/server_lib/mod.rs +++ b/rust/fatcat-api-spec/examples/server_lib/mod.rs @@ -3,7 +3,7 @@ mod server; mod errors { - error_chain!{} + error_chain! {} } pub use self::errors::*; diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs index 7341e528..98358657 100644 --- a/rust/fatcat-api-spec/examples/server_lib/server.rs +++ b/rust/fatcat-api-spec/examples/server_lib/server.rs @@ -119,12 +119,20 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_container(&self, issnl: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send> { + fn lookup_container( + &self, + issnl: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + context: &Context, + ) -> Box + Send> { let context = context.clone(); println!( - "lookup_container({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_container({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", issnl, wikidata_qid, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -247,12 +255,20 @@ impl Api for Server { Box::new(futures::failed("Generic failure".into())) } - fn lookup_creator(&self, orcid: Option, wikidata_qid: Option, hide: Option, context: &Context) -> Box + Send> { + fn lookup_creator( + &self, + orcid: Option, + wikidata_qid: Option, + expand: Option, + hide: Option, + context: &Context, + ) -> Box + Send> { let context = context.clone(); println!( - "lookup_creator({:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_creator({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", orcid, wikidata_qid, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -417,15 +433,17 @@ impl Api for Server { md5: Option, sha1: Option, sha256: Option, + expand: Option, hide: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "lookup_file({:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_file({:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", md5, sha1, sha256, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); @@ -566,17 +584,21 @@ impl Api for Server { isbn13: Option, pmid: Option, pmcid: Option, + core_id: Option, + expand: Option, hide: Option, context: &Context, ) -> Box + Send> { let context = context.clone(); println!( - "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", + "lookup_release({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}) - X-Span-ID: {:?}", doi, wikidata_qid, isbn13, pmid, pmcid, + core_id, + expand, hide, context.x_span_id.unwrap_or(String::from("")).clone() ); -- cgit v1.2.3