summaryrefslogtreecommitdiffstats
path: root/rust/fatcat-api-spec/examples
diff options
context:
space:
mode:
Diffstat (limited to 'rust/fatcat-api-spec/examples')
-rw-r--r--rust/fatcat-api-spec/examples/client.rs30
-rw-r--r--rust/fatcat-api-spec/examples/server_lib/server.rs103
2 files changed, 97 insertions, 36 deletions
diff --git a/rust/fatcat-api-spec/examples/client.rs b/rust/fatcat-api-spec/examples/client.rs
index cb025d5c..1273d892 100644
--- a/rust/fatcat-api-spec/examples/client.rs
+++ b/rust/fatcat-api-spec/examples/client.rs
@@ -104,7 +104,9 @@ fn main() {
}
Some("GetContainer") => {
- let result = client.get_container("id_example".to_string(), Some("expand_example".to_string())).wait();
+ let result = client
+ .get_container("id_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("<none>")));
}
@@ -114,7 +116,7 @@ fn main() {
}
Some("LookupContainer") => {
- let result = client.lookup_container("issnl_example".to_string()).wait();
+ let result = client.lookup_container("issnl_example".to_string(), Some("hide_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
@@ -140,7 +142,9 @@ fn main() {
}
Some("GetCreator") => {
- let result = client.get_creator("id_example".to_string(), Some("expand_example".to_string())).wait();
+ let result = client
+ .get_creator("id_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("<none>")));
}
@@ -150,12 +154,12 @@ fn main() {
}
Some("GetCreatorReleases") => {
- let result = client.get_creator_releases("id_example".to_string()).wait();
+ let result = client.get_creator_releases("id_example".to_string(), Some("hide_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
Some("LookupCreator") => {
- let result = client.lookup_creator("orcid_example".to_string()).wait();
+ let result = client.lookup_creator("orcid_example".to_string(), Some("hide_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
@@ -220,7 +224,7 @@ fn main() {
}
Some("GetFile") => {
- let result = client.get_file("id_example".to_string(), Some("expand_example".to_string())).wait();
+ let result = client.get_file("id_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("<none>")));
}
@@ -230,7 +234,7 @@ fn main() {
}
Some("LookupFile") => {
- let result = client.lookup_file("sha1_example".to_string()).wait();
+ let result = client.lookup_file("sha1_example".to_string(), Some("hide_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
@@ -261,12 +265,14 @@ fn main() {
}
Some("GetRelease") => {
- let result = client.get_release("id_example".to_string(), Some("expand_example".to_string())).wait();
+ let result = client
+ .get_release("id_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("<none>")));
}
Some("GetReleaseFiles") => {
- let result = client.get_release_files("id_example".to_string()).wait();
+ let result = client.get_release_files("id_example".to_string(), Some("hide_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
@@ -276,7 +282,7 @@ fn main() {
}
Some("LookupRelease") => {
- let result = client.lookup_release("doi_example".to_string()).wait();
+ let result = client.lookup_release("doi_example".to_string(), Some("hide_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
@@ -296,7 +302,7 @@ fn main() {
}
Some("GetWork") => {
- let result = client.get_work("id_example".to_string(), Some("expand_example".to_string())).wait();
+ let result = client.get_work("id_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("<none>")));
}
@@ -306,7 +312,7 @@ fn main() {
}
Some("GetWorkReleases") => {
- let result = client.get_work_releases("id_example".to_string()).wait();
+ let result = client.get_work_releases("id_example".to_string(), Some("hide_example".to_string())).wait();
println!("{:?} (X-Span-ID: {:?})", result, client.context().x_span_id.clone().unwrap_or(String::from("<none>")));
}
diff --git a/rust/fatcat-api-spec/examples/server_lib/server.rs b/rust/fatcat-api-spec/examples/server_lib/server.rs
index dc669490..b11f26c3 100644
--- a/rust/fatcat-api-spec/examples/server_lib/server.rs
+++ b/rust/fatcat-api-spec/examples/server_lib/server.rs
@@ -63,9 +63,15 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_container(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetContainerResponse, Error = ApiError> + Send> {
+ fn get_container(&self, id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<Future<Item = GetContainerResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_container(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_container(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ id,
+ expand,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
@@ -80,9 +86,14 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn lookup_container(&self, issnl: String, context: &Context) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
+ fn lookup_container(&self, issnl: String, hide: Option<String>, context: &Context) -> Box<Future<Item = LookupContainerResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("lookup_container(\"{}\") - X-Span-ID: {:?}", issnl, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "lookup_container(\"{}\", {:?}) - X-Span-ID: {:?}",
+ issnl,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
@@ -138,9 +149,15 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_creator(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
+ fn get_creator(&self, id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<Future<Item = GetCreatorResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_creator(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_creator(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ id,
+ expand,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
@@ -155,15 +172,25 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_creator_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
+ fn get_creator_releases(&self, id: String, hide: Option<String>, context: &Context) -> Box<Future<Item = GetCreatorReleasesResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_creator_releases(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_creator_releases(\"{}\", {:?}) - X-Span-ID: {:?}",
+ id,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
- fn lookup_creator(&self, orcid: String, context: &Context) -> Box<Future<Item = LookupCreatorResponse, Error = ApiError> + Send> {
+ fn lookup_creator(&self, orcid: String, hide: Option<String>, context: &Context) -> Box<Future<Item = LookupCreatorResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("lookup_creator(\"{}\") - X-Span-ID: {:?}", orcid, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "lookup_creator(\"{}\", {:?}) - X-Span-ID: {:?}",
+ orcid,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
@@ -267,9 +294,15 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_file(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetFileResponse, Error = ApiError> + Send> {
+ fn get_file(&self, id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<Future<Item = GetFileResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_file(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_file(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ id,
+ expand,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
@@ -284,9 +317,9 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn lookup_file(&self, sha1: String, context: &Context) -> Box<Future<Item = LookupFileResponse, Error = ApiError> + Send> {
+ fn lookup_file(&self, sha1: String, hide: Option<String>, context: &Context) -> Box<Future<Item = LookupFileResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("lookup_file(\"{}\") - X-Span-ID: {:?}", sha1, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!("lookup_file(\"{}\", {:?}) - X-Span-ID: {:?}", sha1, hide, context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
}
@@ -353,15 +386,26 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_release(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
+ fn get_release(&self, id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<Future<Item = GetReleaseResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_release(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_release(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ id,
+ expand,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
- fn get_release_files(&self, id: String, context: &Context) -> Box<Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> {
+ fn get_release_files(&self, id: String, hide: Option<String>, context: &Context) -> Box<Future<Item = GetReleaseFilesResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_release_files(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_release_files(\"{}\", {:?}) - X-Span-ID: {:?}",
+ id,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
@@ -376,9 +420,9 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn lookup_release(&self, doi: String, context: &Context) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send> {
+ fn lookup_release(&self, doi: String, hide: Option<String>, context: &Context) -> Box<Future<Item = LookupReleaseResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("lookup_release(\"{}\") - X-Span-ID: {:?}", doi, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!("lookup_release(\"{}\", {:?}) - X-Span-ID: {:?}", doi, hide, context.x_span_id.unwrap_or(String::from("<none>")).clone());
Box::new(futures::failed("Generic failure".into()))
}
@@ -423,9 +467,15 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_work(&self, id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetWorkResponse, Error = ApiError> + Send> {
+ fn get_work(&self, id: String, expand: Option<String>, hide: Option<String>, context: &Context) -> Box<Future<Item = GetWorkResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_work(\"{}\", {:?}) - X-Span-ID: {:?}", id, expand, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_work(\"{}\", {:?}, {:?}) - X-Span-ID: {:?}",
+ id,
+ expand,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}
@@ -440,9 +490,14 @@ impl Api for Server {
Box::new(futures::failed("Generic failure".into()))
}
- fn get_work_releases(&self, id: String, context: &Context) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
+ fn get_work_releases(&self, id: String, hide: Option<String>, context: &Context) -> Box<Future<Item = GetWorkReleasesResponse, Error = ApiError> + Send> {
let context = context.clone();
- println!("get_work_releases(\"{}\") - X-Span-ID: {:?}", id, context.x_span_id.unwrap_or(String::from("<none>")).clone());
+ println!(
+ "get_work_releases(\"{}\", {:?}) - X-Span-ID: {:?}",
+ id,
+ hide,
+ context.x_span_id.unwrap_or(String::from("<none>")).clone()
+ );
Box::new(futures::failed("Generic failure".into()))
}