Update dependencies
This commit is contained in:
parent
8522f8ada9
commit
201ff8c185
16
Cargo.toml
16
Cargo.toml
@ -18,20 +18,20 @@ version = "0.3.0"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
futures-core = "0.3.4"
|
futures-core = "0.3.4"
|
||||||
futures-util = "0.3.4"
|
futures-util = "0.3.4"
|
||||||
http = "0.2.0"
|
http = "0.2.1"
|
||||||
hyper = "0.13.2"
|
hyper = "0.13.4"
|
||||||
hyper-tls = { version = "0.4.1", optional = true }
|
hyper-tls = { version = "0.4.1", optional = true }
|
||||||
ruma-api = "0.13.0"
|
ruma-api = "0.15.0"
|
||||||
ruma-client-api = "0.6.0"
|
ruma-client-api = "0.7.1"
|
||||||
ruma-events = "0.15.1"
|
ruma-events = "0.18.0"
|
||||||
ruma-identifiers = "0.14.1"
|
ruma-identifiers = "0.14.1"
|
||||||
serde = { version = "1.0.104", features = ["derive"] }
|
serde = { version = "1.0.106", features = ["derive"] }
|
||||||
serde_json = "1.0.47"
|
serde_json = "1.0.51"
|
||||||
serde_urlencoded = "0.6.1"
|
serde_urlencoded = "0.6.1"
|
||||||
url = "2.1.1"
|
url = "2.1.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "0.2.11", features = ["macros"] }
|
tokio = { version = "0.2.16", features = ["macros"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["tls"]
|
default = ["tls"]
|
||||||
|
@ -3,6 +3,7 @@ use std::{env, process::exit};
|
|||||||
use futures_util::stream::{StreamExt as _, TryStreamExt as _};
|
use futures_util::stream::{StreamExt as _, TryStreamExt as _};
|
||||||
use ruma_client::{
|
use ruma_client::{
|
||||||
self,
|
self,
|
||||||
|
api::r0::sync::sync_events::SetPresence,
|
||||||
events::{
|
events::{
|
||||||
collections::all::RoomEvent,
|
collections::all::RoomEvent,
|
||||||
room::message::{MessageEvent, MessageEventContent, TextMessageEventContent},
|
room::message::{MessageEvent, MessageEventContent, TextMessageEventContent},
|
||||||
@ -23,8 +24,8 @@ async fn log_messages(
|
|||||||
// TODO: This is a horrible way to obtain an initial next_batch token that generates way too
|
// TODO: This is a horrible way to obtain an initial next_batch token that generates way too
|
||||||
// much server load and network traffic. Fix this!
|
// much server load and network traffic. Fix this!
|
||||||
|
|
||||||
// vvvvvvvv Skip initial sync reponse
|
// Skip initial sync reponse vvvvvvvv
|
||||||
let mut sync_stream = Box::pin(client.sync(None, None, false).skip(1));
|
let mut sync_stream = Box::pin(client.sync(None, None, SetPresence::Online).skip(1));
|
||||||
|
|
||||||
while let Some(res) = sync_stream.try_next().await? {
|
while let Some(res) = sync_stream.try_next().await? {
|
||||||
// Only look at rooms the user hasn't left yet
|
// Only look at rooms the user hasn't left yet
|
||||||
|
12
src/error.rs
12
src/error.rs
@ -5,6 +5,8 @@ use std::fmt::{Display, Formatter, Result as FmtResult};
|
|||||||
|
|
||||||
use ruma_api::error::{FromHttpResponseError, IntoHttpError};
|
use ruma_api::error::{FromHttpResponseError, IntoHttpError};
|
||||||
|
|
||||||
|
use crate::api;
|
||||||
|
|
||||||
/// An error that can occur during client operations.
|
/// An error that can occur during client operations.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
@ -18,7 +20,7 @@ pub enum Error {
|
|||||||
/// Couldn't obtain an HTTP response (e.g. due to network or DNS issues).
|
/// Couldn't obtain an HTTP response (e.g. due to network or DNS issues).
|
||||||
Response(ResponseError),
|
Response(ResponseError),
|
||||||
/// Converting the HTTP response to one of ruma's types failed.
|
/// Converting the HTTP response to one of ruma's types failed.
|
||||||
FromHttpResponse(FromHttpResponseError),
|
FromHttpResponse(FromHttpResponseError<api::Error>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
@ -30,7 +32,9 @@ impl Display for Error {
|
|||||||
Self::IntoHttp(err) => write!(f, "HTTP request construction failed: {}", err),
|
Self::IntoHttp(err) => write!(f, "HTTP request construction failed: {}", err),
|
||||||
Self::Url(UrlError(err)) => write!(f, "Invalid URL: {}", err),
|
Self::Url(UrlError(err)) => write!(f, "Invalid URL: {}", err),
|
||||||
Self::Response(ResponseError(err)) => write!(f, "Couldn't obtain a response: {}", err),
|
Self::Response(ResponseError(err)) => write!(f, "Couldn't obtain a response: {}", err),
|
||||||
Self::FromHttpResponse(err) => write!(f, "HTTP response conversion failed: {}", err),
|
// FIXME: ruma-client-api's Error type currently doesn't implement
|
||||||
|
// `Display`, update this when it does.
|
||||||
|
Self::FromHttpResponse(_) => write!(f, "HTTP response conversion failed"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,8 +59,8 @@ impl From<hyper::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<FromHttpResponseError> for Error {
|
impl From<FromHttpResponseError<api::Error>> for Error {
|
||||||
fn from(err: FromHttpResponseError) -> Self {
|
fn from(err: FromHttpResponseError<api::Error>) -> Self {
|
||||||
Error::FromHttpResponse(err)
|
Error::FromHttpResponse(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
src/lib.rs
14
src/lib.rs
@ -297,18 +297,12 @@ where
|
|||||||
&self,
|
&self,
|
||||||
filter: Option<api::r0::sync::sync_events::Filter>,
|
filter: Option<api::r0::sync::sync_events::Filter>,
|
||||||
since: Option<String>,
|
since: Option<String>,
|
||||||
set_presence: bool,
|
set_presence: api::r0::sync::sync_events::SetPresence,
|
||||||
) -> impl Stream<Item = Result<api::r0::sync::sync_events::IncomingResponse, Error>>
|
) -> impl Stream<Item = Result<api::r0::sync::sync_events::IncomingResponse, Error>>
|
||||||
+ TryStream<Ok = api::r0::sync::sync_events::IncomingResponse, Error = Error> {
|
+ TryStream<Ok = api::r0::sync::sync_events::IncomingResponse, Error = Error> {
|
||||||
use api::r0::sync::sync_events;
|
use api::r0::sync::sync_events;
|
||||||
|
|
||||||
let client = self.clone();
|
let client = self.clone();
|
||||||
let set_presence = if set_presence {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(sync_events::SetPresence::Offline)
|
|
||||||
};
|
|
||||||
|
|
||||||
stream::try_unfold(since, move |since| {
|
stream::try_unfold(since, move |since| {
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
let filter = filter.clone();
|
let filter = filter.clone();
|
||||||
@ -318,7 +312,7 @@ where
|
|||||||
.request(sync_events::Request {
|
.request(sync_events::Request {
|
||||||
filter,
|
filter,
|
||||||
since,
|
since,
|
||||||
full_state: None,
|
full_state: false,
|
||||||
set_presence,
|
set_presence,
|
||||||
timeout: None,
|
timeout: None,
|
||||||
})
|
})
|
||||||
@ -331,7 +325,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Makes a request to a Matrix API endpoint.
|
/// Makes a request to a Matrix API endpoint.
|
||||||
pub fn request<Request: Endpoint>(
|
pub fn request<Request: Endpoint<ResponseError = api::Error>>(
|
||||||
&self,
|
&self,
|
||||||
request: Request,
|
request: Request,
|
||||||
) -> impl Future<Output = Result<<Request::Response as Outgoing>::Incoming, Error>>
|
) -> impl Future<Output = Result<<Request::Response as Outgoing>::Incoming, Error>>
|
||||||
@ -340,7 +334,7 @@ where
|
|||||||
where
|
where
|
||||||
Request::Incoming: TryFrom<http::Request<Vec<u8>>, Error = FromHttpRequestError>,
|
Request::Incoming: TryFrom<http::Request<Vec<u8>>, Error = FromHttpRequestError>,
|
||||||
<Request::Response as Outgoing>::Incoming:
|
<Request::Response as Outgoing>::Incoming:
|
||||||
TryFrom<http::Response<Vec<u8>>, Error = FromHttpResponseError>,
|
TryFrom<http::Response<Vec<u8>>, Error = FromHttpResponseError<api::Error>>,
|
||||||
{
|
{
|
||||||
let client = self.0.clone();
|
let client = self.0.clone();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user