async_client: name associated error type in AsyncClient::send
parent
c0e1ff1734
commit
07b7cbfe4e
|
@ -24,7 +24,7 @@ async-trait = "0.1.30"
|
||||||
|
|
||||||
# Ruma dependencies
|
# Ruma dependencies
|
||||||
js_int = "0.1.4"
|
js_int = "0.1.4"
|
||||||
ruma-api = "0.15.0"
|
ruma-api = "0.15.1"
|
||||||
ruma-client-api = { git = "https://github.com/matrix-org/ruma-client-api/", version = "0.7.0" }
|
ruma-client-api = { git = "https://github.com/matrix-org/ruma-client-api/", version = "0.7.0" }
|
||||||
ruma-events = { git = "https://github.com/matrix-org/ruma-events", version = "0.18.0" }
|
ruma-events = { git = "https://github.com/matrix-org/ruma-events", version = "0.18.0" }
|
||||||
ruma-identifiers = "0.14.1"
|
ruma-identifiers = "0.14.1"
|
||||||
|
|
|
@ -754,7 +754,7 @@ impl AsyncClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn send<Request: Endpoint + std::fmt::Debug>(
|
async fn send<Request: Endpoint<ResponseError = ruma_client_api::Error> + std::fmt::Debug>(
|
||||||
&self,
|
&self,
|
||||||
request: Request,
|
request: Request,
|
||||||
) -> Result<<Request::Response as Outgoing>::Incoming>
|
) -> Result<<Request::Response as Outgoing>::Incoming>
|
||||||
|
@ -815,21 +815,20 @@ impl AsyncClient {
|
||||||
trace!("Got response: {:?}", response);
|
trace!("Got response: {:?}", response);
|
||||||
|
|
||||||
let status = response.status();
|
let status = response.status();
|
||||||
let mut http_response = HttpResponse::builder().status(status);
|
let mut http_builder = HttpResponse::builder().status(status);
|
||||||
let headers = http_response.headers_mut().unwrap();
|
let headers = http_builder.headers_mut().unwrap();
|
||||||
|
|
||||||
for (k, v) in response.headers_mut().drain() {
|
for (k, v) in response.headers_mut().drain() {
|
||||||
if let Some(key) = k {
|
if let Some(key) = k {
|
||||||
headers.insert(key, v);
|
headers.insert(key, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = response.bytes().await?.as_ref().to_owned();
|
let body = response.bytes().await?.as_ref().to_owned();
|
||||||
let http_response = http_response.body(body).unwrap();
|
let http_response = http_builder.body(body).unwrap();
|
||||||
let response = <Request::Response as Outgoing>::Incoming::try_from(http_response)
|
|
||||||
.map_err(|e| Error::LoginError(format!("{:?}", e)))?;
|
|
||||||
|
|
||||||
Ok(response)
|
Ok(<Request::Response as Outgoing>::Incoming::try_from(
|
||||||
|
http_response,
|
||||||
|
)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a room message to the homeserver.
|
/// Send a room message to the homeserver.
|
||||||
|
|
|
@ -50,9 +50,6 @@ pub enum Error {
|
||||||
/// An error occurred during a E2EE operation.
|
/// An error occurred during a E2EE operation.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
OlmError(#[from] OlmError),
|
OlmError(#[from] OlmError),
|
||||||
/// An error occurred during log in.
|
|
||||||
#[error("can't login {0}.")]
|
|
||||||
LoginError(String),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RumaResponseError<RumaClientError>> for Error {
|
impl From<RumaResponseError<RumaClientError>> for Error {
|
||||||
|
|
Loading…
Reference in New Issue