Remove code for building full bodies from streams.
This commit is contained in:
parent
a27adc2f73
commit
e3cf7a38a1
@ -165,31 +165,17 @@ impl ToTokens for Api {
|
|||||||
let field_type = &field.ty;
|
let field_type = &field.ty;
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
let future_response = http_response.body()
|
let future_response =
|
||||||
.fold::<_, _, Result<_, ::std::io::Error>>(Vec::new(), |mut bytes, chunk| {
|
::serde_json::from_slice::<#field_type>(http_response.body().as_slice())
|
||||||
bytes.write_all(&chunk)?;
|
.into_future()
|
||||||
|
.map_err(::ruma_api::Error::from)
|
||||||
Ok(bytes)
|
|
||||||
})
|
|
||||||
.map_err(::ruma_api::Error::from)
|
|
||||||
.and_then(|bytes| {
|
|
||||||
::serde_json::from_slice::<#field_type>(bytes.as_slice())
|
|
||||||
.map_err(::ruma_api::Error::from)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else if self.response.has_body_fields() {
|
} else if self.response.has_body_fields() {
|
||||||
quote! {
|
quote! {
|
||||||
let future_response = http_response.body()
|
let future_response =
|
||||||
.fold::<_, _, Result<_, ::std::io::Error>>(Vec::new(), |mut bytes, chunk| {
|
::serde_json::from_slice::<ResponseBody>(http_response.body().as_slice())
|
||||||
bytes.write_all(&chunk)?;
|
.into_future()
|
||||||
|
.map_err(::ruma_api::Error::from)
|
||||||
Ok(bytes)
|
|
||||||
})
|
|
||||||
.map_err(::ruma_api::Error::from)
|
|
||||||
.and_then(|bytes| {
|
|
||||||
::serde_json::from_slice::<ResponseBody>(bytes.as_slice())
|
|
||||||
.map_err(::ruma_api::Error::from)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
@ -213,10 +199,7 @@ impl ToTokens for Api {
|
|||||||
|
|
||||||
tokens.append_all(quote! {
|
tokens.append_all(quote! {
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use std::io::Write as _Write;
|
use ::futures::{Future as _Future, IntoFuture as _IntoFuture};
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
use ::futures::{Future as _Future, Stream as _Stream};
|
|
||||||
use ::ruma_api::Endpoint as _RumaApiEndpoint;
|
use ::ruma_api::Endpoint as _RumaApiEndpoint;
|
||||||
|
|
||||||
/// The API endpoint.
|
/// The API endpoint.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user