From 525f21c871f4947196dc8348019d941e84bf6e3c Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 15 May 2018 15:07:12 -0700 Subject: make cargo fmt succeed by default --- rust/fatcat-api/src/client.rs | 948 +++++++++--------------------------------- 1 file changed, 205 insertions(+), 743 deletions(-) (limited to 'rust/fatcat-api/src/client.rs') diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 1219e01b..06633ad9 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -34,18 +34,12 @@ use swagger; use swagger::{ApiError, Context, XSpanId}; use models; -use {Api, ContainerIdGetResponse, ContainerLookupGetResponse, ContainerPostResponse, - CreatorIdGetResponse, CreatorLookupGetResponse, CreatorPostResponse, - EditgroupIdAcceptPostResponse, EditgroupIdGetResponse, EditgroupPostResponse, - EditorUsernameChangelogGetResponse, EditorUsernameGetResponse, FileIdGetResponse, - FileLookupGetResponse, FilePostResponse, ReleaseIdGetResponse, ReleaseLookupGetResponse, - ReleasePostResponse, WorkIdGetResponse, WorkPostResponse}; +use {Api, ContainerIdGetResponse, ContainerLookupGetResponse, ContainerPostResponse, CreatorIdGetResponse, CreatorLookupGetResponse, CreatorPostResponse, EditgroupIdAcceptPostResponse, + EditgroupIdGetResponse, EditgroupPostResponse, EditorUsernameChangelogGetResponse, EditorUsernameGetResponse, FileIdGetResponse, FileLookupGetResponse, FilePostResponse, ReleaseIdGetResponse, + ReleaseLookupGetResponse, ReleasePostResponse, WorkIdGetResponse, WorkPostResponse}; /// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. -fn into_base_path( - input: T, - correct_scheme: Option<&'static str>, -) -> Result { +fn into_base_path(input: T, correct_scheme: Option<&'static str>) -> Result { // First convert to Url, since a base path is a subset of Url. let url = input.into_url()?; @@ -96,8 +90,7 @@ impl Client { let https_hyper_client = move || { // SSL implementation - let mut ssl = - openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap(); + let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap(); // Server authentication ssl.set_ca_file(ca_certificate.clone()).unwrap(); @@ -113,12 +106,7 @@ impl Client { }) } - pub fn try_new_https_mutual( - base_path: T, - ca_certificate: CA, - client_key: K, - client_certificate: C, - ) -> Result + pub fn try_new_https_mutual(base_path: T, ca_certificate: CA, client_key: K, client_certificate: C) -> Result where T: IntoUrl, CA: AsRef, @@ -131,17 +119,14 @@ impl Client { let https_mutual_hyper_client = move || { // SSL implementation - let mut ssl = - openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap(); + let mut ssl = openssl::ssl::SslConnectorBuilder::new(openssl::ssl::SslMethod::tls()).unwrap(); // Server authentication ssl.set_ca_file(ca_certificate.clone()).unwrap(); // Client authentication - ssl.set_private_key_file(client_key.clone(), openssl::x509::X509_FILETYPE_PEM) - .unwrap(); - ssl.set_certificate_chain_file(client_certificate.clone()) - .unwrap(); + ssl.set_private_key_file(client_key.clone(), openssl::x509::X509_FILETYPE_PEM).unwrap(); + ssl.set_certificate_chain_file(client_certificate.clone()).unwrap(); ssl.check_private_key().unwrap(); let ssl = hyper_openssl::OpensslClient::from(ssl.build()); @@ -164,10 +149,7 @@ impl Client { /// The reason for this function's existence is to support legacy test code, which did mocking at the hyper layer. /// This is not a recommended way to write new tests. If other reasons are found for using this function, they /// should be mentioned here. - pub fn try_new_with_hyper_client( - base_path: T, - hyper_client: Arc hyper::client::Client + Sync + Send>, - ) -> Result + pub fn try_new_with_hyper_client(base_path: T, hyper_client: Arc hyper::client::Client + Sync + Send>) -> Result where T: IntoUrl, { @@ -179,56 +161,37 @@ impl Client { } impl Api for Client { - fn container_id_get( - &self, - param_id: String, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/container/{id}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); + fn container_id_get(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/container/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerIdGetResponse::FetchASingleContainerById(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerIdGetResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerIdGetResponse::GenericErrorResponse(body)) @@ -238,90 +201,60 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn container_lookup_get( - &self, - param_issn: String, - context: &Context, - ) -> Box + Send> { + fn container_lookup_get(&self, param_issn: String, context: &Context) -> Box + Send> { // Query parameters let query_issn = format!("issn={issn}&", issn = param_issn.to_string()); - let url = format!( - "{}/v0/container/lookup?{issn}", - self.base_path, - issn = utf8_percent_encode(&query_issn, QUERY_ENCODE_SET) - ); + let url = format!("{}/v0/container/lookup?{issn}", self.base_path, issn = utf8_percent_encode(&query_issn, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerLookupGetResponse::FindASingleContainerByExternalIdentifer(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerLookupGetResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerLookupGetResponse::NoSuchContainer(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerLookupGetResponse::GenericErrorResponse(body)) @@ -331,37 +264,23 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn container_post( - &self, - param_body: Option, - context: &Context, - ) -> Box + Send> { + fn container_post(&self, param_body: Option, context: &Context) -> Box + Send> { let url = format!("{}/v0/container", self.base_path); - let body = param_body - .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); @@ -372,41 +291,30 @@ impl Api for Client { }; custom_headers.set(ContentType(mimetypes::requests::CONTAINER_POST.clone())); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 201 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerPostResponse::Created(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerPostResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ContainerPostResponse::GenericErrorResponse(body)) @@ -416,78 +324,50 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn creator_id_get( - &self, - param_id: String, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/creator/{id}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); + fn creator_id_get(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/creator/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorIdGetResponse::FetchASingleCreatorById(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorIdGetResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorIdGetResponse::GenericErrorResponse(body)) @@ -497,90 +377,60 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn creator_lookup_get( - &self, - param_orcid: String, - context: &Context, - ) -> Box + Send> { + fn creator_lookup_get(&self, param_orcid: String, context: &Context) -> Box + Send> { // Query parameters let query_orcid = format!("orcid={orcid}&", orcid = param_orcid.to_string()); - let url = format!( - "{}/v0/creator/lookup?{orcid}", - self.base_path, - orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET) - ); + let url = format!("{}/v0/creator/lookup?{orcid}", self.base_path, orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorLookupGetResponse::FindASingleCreatorByExternalIdentifer(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorLookupGetResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorLookupGetResponse::NoSuchCreator(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorLookupGetResponse::GenericErrorResponse(body)) @@ -590,37 +440,23 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn creator_post( - &self, - param_body: Option, - context: &Context, - ) -> Box + Send> { + fn creator_post(&self, param_body: Option, context: &Context) -> Box + Send> { let url = format!("{}/v0/creator", self.base_path); - let body = param_body - .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); @@ -631,41 +467,30 @@ impl Api for Client { }; custom_headers.set(ContentType(mimetypes::requests::CREATOR_POST.clone())); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 201 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorPostResponse::Created(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorPostResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(CreatorPostResponse::GenericErrorResponse(body)) @@ -675,89 +500,57 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn editgroup_id_accept_post( - &self, - param_id: i32, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{id}/accept", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); + fn editgroup_id_accept_post(&self, param_id: i32, context: &Context) -> Box + Send> { + let url = format!("{}/v0/editgroup/{id}/accept", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(EditgroupIdAcceptPostResponse::MergedEditgroupSuccessfully_( - body, - )) + Ok(EditgroupIdAcceptPostResponse::MergedEditgroupSuccessfully_(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupIdAcceptPostResponse::EditgroupIsInAnUnmergableState(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupIdAcceptPostResponse::NoSuchEditgroup(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupIdAcceptPostResponse::GenericErrorResponse(body)) @@ -767,78 +560,50 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn editgroup_id_get( - &self, - param_id: i32, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/editgroup/{id}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); + fn editgroup_id_get(&self, param_id: i32, context: &Context) -> Box + Send> { + let url = format!("{}/v0/editgroup/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupIdGetResponse::FetchEditgroupByIdentifier(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupIdGetResponse::NoSuchEditgroup(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupIdGetResponse::GenericErrorResponse(body)) @@ -848,73 +613,50 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn editgroup_post( - &self, - context: &Context, - ) -> Box + Send> { + fn editgroup_post(&self, context: &Context) -> Box + Send> { let url = format!("{}/v0/editgroup", self.base_path); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 201 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupPostResponse::SuccessfullyCreated(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupPostResponse::InvalidRequestParameters(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditgroupPostResponse::GenericErrorResponse(body)) @@ -924,33 +666,20 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn editor_username_changelog_get( - &self, - param_username: String, - context: &Context, - ) -> Box + Send> { + fn editor_username_changelog_get(&self, param_username: String, context: &Context) -> Box + Send> { let url = format!( "{}/v0/editor/{username}/changelog", self.base_path, @@ -961,79 +690,53 @@ impl Api for Client { let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditorUsernameChangelogGetResponse::FindChanges_(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditorUsernameChangelogGetResponse::UsernameNotFound(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(EditorUsernameChangelogGetResponse::GenericErrorResponse( - body, - )) + Ok(EditorUsernameChangelogGetResponse::GenericErrorResponse(body)) } code => { let mut buf = [0; 100]; let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn editor_username_get( - &self, - param_username: String, - context: &Context, - ) -> Box + Send> { + fn editor_username_get(&self, param_username: String, context: &Context) -> Box + Send> { let url = format!( "{}/v0/editor/{username}", self.base_path, @@ -1044,41 +747,30 @@ impl Api for Client { let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditorUsernameGetResponse::FetchGenericInformationAboutAnEditor(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditorUsernameGetResponse::UsernameNotFound(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(EditorUsernameGetResponse::GenericErrorResponse(body)) @@ -1088,78 +780,50 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn file_id_get( - &self, - param_id: String, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/file/{id}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); + fn file_id_get(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/file/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FileIdGetResponse::FetchASingleFileById(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FileIdGetResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FileIdGetResponse::GenericErrorResponse(body)) @@ -1169,92 +833,60 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn file_lookup_get( - &self, - param_sha1: String, - context: &Context, - ) -> Box + Send> { + fn file_lookup_get(&self, param_sha1: String, context: &Context) -> Box + Send> { // Query parameters let query_sha1 = format!("sha1={sha1}&", sha1 = param_sha1.to_string()); - let url = format!( - "{}/v0/file/lookup?{sha1}", - self.base_path, - sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET) - ); + let url = format!("{}/v0/file/lookup?{sha1}", self.base_path, sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; - Ok(FileLookupGetResponse::FindASingleFileByExternalIdentifer( - body, - )) + Ok(FileLookupGetResponse::FindASingleFileByExternalIdentifer(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FileLookupGetResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FileLookupGetResponse::NoSuchFile(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FileLookupGetResponse::GenericErrorResponse(body)) @@ -1264,37 +896,23 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn file_post( - &self, - param_body: Option, - context: &Context, - ) -> Box + Send> { + fn file_post(&self, param_body: Option, context: &Context) -> Box + Send> { let url = format!("{}/v0/file", self.base_path); - let body = param_body - .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); @@ -1305,41 +923,30 @@ impl Api for Client { }; custom_headers.set(ContentType(mimetypes::requests::FILE_POST.clone())); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 201 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FilePostResponse::Created(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FilePostResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(FilePostResponse::GenericErrorResponse(body)) @@ -1349,78 +956,50 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn release_id_get( - &self, - param_id: String, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/release/{id}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); + fn release_id_get(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/release/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleaseIdGetResponse::FetchASingleReleaseById(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleaseIdGetResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleaseIdGetResponse::GenericErrorResponse(body)) @@ -1430,90 +1009,60 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn release_lookup_get( - &self, - param_doi: String, - context: &Context, - ) -> Box + Send> { + fn release_lookup_get(&self, param_doi: String, context: &Context) -> Box + Send> { // Query parameters let query_doi = format!("doi={doi}&", doi = param_doi.to_string()); - let url = format!( - "{}/v0/release/lookup?{doi}", - self.base_path, - doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET) - ); + let url = format!("{}/v0/release/lookup?{doi}", self.base_path, doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleaseLookupGetResponse::FindASingleReleaseByExternalIdentifer(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleaseLookupGetResponse::BadRequest(body)) } 404 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleaseLookupGetResponse::NoSuchRelease(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleaseLookupGetResponse::GenericErrorResponse(body)) @@ -1523,37 +1072,23 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn release_post( - &self, - param_body: Option, - context: &Context, - ) -> Box + Send> { + fn release_post(&self, param_body: Option, context: &Context) -> Box + Send> { let url = format!("{}/v0/release", self.base_path); - let body = param_body - .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); @@ -1564,41 +1099,30 @@ impl Api for Client { }; custom_headers.set(ContentType(mimetypes::requests::RELEASE_POST.clone())); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 201 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleasePostResponse::Created(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleasePostResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(ReleasePostResponse::GenericErrorResponse(body)) @@ -1608,78 +1132,50 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn work_id_get( - &self, - param_id: String, - context: &Context, - ) -> Box + Send> { - let url = format!( - "{}/v0/work/{id}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET) - ); + fn work_id_get(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/work/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); let mut custom_headers = hyper::header::Headers::new(); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 200 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(WorkIdGetResponse::FetchASingleWorkById(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(WorkIdGetResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(WorkIdGetResponse::GenericErrorResponse(body)) @@ -1689,37 +1185,23 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } - fn work_post( - &self, - param_body: Option, - context: &Context, - ) -> Box + Send> { + fn work_post(&self, param_body: Option, context: &Context) -> Box + Send> { let url = format!("{}/v0/work", self.base_path); - let body = param_body - .map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); + let body = param_body.map(|ref body| serde_json::to_string(body).expect("impossible to fail to serialize")); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Post, &url); let mut custom_headers = hyper::header::Headers::new(); @@ -1730,41 +1212,30 @@ impl Api for Client { }; custom_headers.set(ContentType(mimetypes::requests::WORK_POST.clone())); - context - .x_span_id - .as_ref() - .map(|header| custom_headers.set(XSpanId(header.clone()))); + context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); let request = request.headers(custom_headers); // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists). - fn parse_response( - mut response: hyper::client::response::Response, - ) -> Result { + fn parse_response(mut response: hyper::client::response::Response) -> Result { match response.status.to_u16() { 201 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(WorkPostResponse::Created(body)) } 400 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(WorkPostResponse::BadRequest(body)) } 0 => { let mut buf = String::new(); - response - .read_to_string(&mut buf) - .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; + response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?; let body = serde_json::from_str::(&buf)?; Ok(WorkPostResponse::GenericErrorResponse(body)) @@ -1774,25 +1245,16 @@ impl Api for Client { let debug_body = match response.read(&mut buf) { Ok(len) => match str::from_utf8(&buf[..len]) { Ok(body) => Cow::from(body), - Err(_) => Cow::from(format!( - "", - &buf[..len].to_vec() - )), + Err(_) => Cow::from(format!("", &buf[..len].to_vec())), }, Err(e) => Cow::from(format!("", e)), }; - Err(ApiError(format!( - "Unexpected response code {}:\n{:?}\n\n{}", - code, response.headers, debug_body - ))) + Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body))) } } } - let result = request - .send() - .map_err(|e| ApiError(format!("No response received: {}", e))) - .and_then(parse_response); + let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response); Box::new(futures::done(result)) } } -- cgit v1.2.3