matrix_sdk: Use the internal types crate.

master
Damir Jelić 2020-04-29 10:40:27 +02:00
parent c5d833a14b
commit 4c760fca02
10 changed files with 37 additions and 42 deletions

View File

@ -24,18 +24,11 @@ url = "2.1.1"
async-trait = "0.1.30" async-trait = "0.1.30"
serde = "1.0.106" serde = "1.0.106"
serde_json = "1.0.51" serde_json = "1.0.51"
uuid = { version = "0.8.1", features = ["v4"] }
matrix-sdk-types = { path = "../matrix_sdk_types" } matrix-sdk-types = { path = "../matrix_sdk_types" }
matrix-sdk-crypto = { path = "../matrix_sdk_crypto", optional = true } matrix-sdk-crypto = { path = "../matrix_sdk_crypto", optional = true }
# Ruma dependencies
js_int = "0.1.5"
ruma-api = "0.16.0-rc.2"
ruma-client-api = { version = "0.8.0-rc.5" }
ruma-events = { version = "0.21.0-beta.1" }
ruma-identifiers = "0.16.0"
uuid = { version = "0.8.1", features = ["v4"] }
# Misc dependencies # Misc dependencies
thiserror = "1.0.14" thiserror = "1.0.14"
tracing = "0.1.13" tracing = "0.1.13"

View File

@ -36,14 +36,13 @@ use http::Response as HttpResponse;
use reqwest::header::{HeaderValue, InvalidHeaderValue}; use reqwest::header::{HeaderValue, InvalidHeaderValue};
use url::Url; use url::Url;
use ruma_api::Endpoint; use crate::events::room::message::MessageEventContent;
use ruma_events::room::message::MessageEventContent; use crate::events::{EventJson, EventType};
use ruma_events::EventJson; use crate::identifiers::{RoomId, RoomIdOrAliasId, UserId};
pub use ruma_events::EventType; use crate::Endpoint;
use ruma_identifiers::{RoomId, RoomIdOrAliasId, UserId};
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use ruma_identifiers::DeviceId; use crate::identifiers::DeviceId;
use crate::api; use crate::api;
use crate::base_client::Client as BaseClient; use crate::base_client::Client as BaseClient;
@ -589,7 +588,7 @@ impl AsyncClient {
/// # use matrix_sdk::api::r0::filter::RoomEventFilter; /// # use matrix_sdk::api::r0::filter::RoomEventFilter;
/// # use matrix_sdk::api::r0::message::get_message_events::Direction; /// # use matrix_sdk::api::r0::message::get_message_events::Direction;
/// # use url::Url; /// # use url::Url;
/// # use js_int::UInt; /// # use matrix_sdk::js_int::UInt;
/// ///
/// # let homeserver = Url::parse("http://example.com").unwrap(); /// # let homeserver = Url::parse("http://example.com").unwrap();
/// let mut builder = MessagesRequestBuilder::new(); /// let mut builder = MessagesRequestBuilder::new();
@ -870,7 +869,7 @@ impl AsyncClient {
} }
} }
async fn send<Request: Endpoint<ResponseError = ruma_client_api::Error> + std::fmt::Debug>( async fn send<Request: Endpoint<ResponseError = crate::api::Error> + std::fmt::Debug>(
&self, &self,
request: Request, request: Request,
) -> Result<Request::Response> { ) -> Result<Request::Response> {
@ -1285,15 +1284,15 @@ mod test {
let client = AsyncClient::new(homeserver, None).unwrap(); let client = AsyncClient::new(homeserver, None).unwrap();
if let Err(err) = client.login("example", "wordpass", None, None).await { if let Err(err) = client.login("example", "wordpass", None, None).await {
if let crate::Error::RumaResponse(ruma_api::error::FromHttpResponseError::Http( if let crate::Error::RumaResponse(crate::FromHttpResponseError::Http(
ruma_api::error::ServerError::Known(ruma_client_api::error::Error { crate::ServerError::Known(crate::api::Error {
kind, kind,
message, message,
status_code, status_code,
}), }),
)) = err )) = err
{ {
if let ruma_client_api::error::ErrorKind::Forbidden = kind { if let crate::api::error::ErrorKind::Forbidden = kind {
} else { } else {
panic!( panic!(
"found the wrong `ErrorKind` {:?}, expected `Forbidden", "found the wrong `ErrorKind` {:?}, expected `Forbidden",

View File

@ -42,18 +42,18 @@ use tokio::sync::Mutex;
use tokio::sync::RwLock; use tokio::sync::RwLock;
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use matrix_sdk_crypto::{OlmMachine, OneTimeKeys}; use crate::api::r0::client_exchange::send_event_to_device;
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use ruma_client_api::r0::client_exchange::send_event_to_device; use crate::api::r0::keys::{
#[cfg(feature = "encryption")]
use ruma_client_api::r0::keys::{
claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse, claim_keys::Response as KeysClaimResponse, get_keys::Response as KeysQueryResponse,
upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm, upload_keys::Response as KeysUploadResponse, DeviceKeys, KeyAlgorithm,
}; };
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use ruma_events::room::message::MessageEventContent; use crate::events::room::message::MessageEventContent;
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use ruma_identifiers::DeviceId; use crate::identifiers::DeviceId;
#[cfg(feature = "encryption")]
use matrix_sdk_crypto::{OlmMachine, OneTimeKeys};
pub type Token = String; pub type Token = String;

View File

@ -17,10 +17,10 @@
use std::io::Error as IoError; use std::io::Error as IoError;
use crate::api::Error as RumaClientError;
use crate::FromHttpResponseError as RumaResponseError;
use crate::IntoHttpError as RumaIntoHttpError;
use reqwest::Error as ReqwestError; use reqwest::Error as ReqwestError;
use ruma_api::error::FromHttpResponseError as RumaResponseError;
use ruma_api::error::IntoHttpError as RumaIntoHttpError;
use ruma_client_api::Error as RumaClientError;
use serde_json::Error as JsonError; use serde_json::Error as JsonError;
use thiserror::Error; use thiserror::Error;
use url::ParseError; use url::ParseError;

View File

@ -27,11 +27,8 @@
#![deny(missing_docs)] #![deny(missing_docs)]
pub use crate::{error::Error, error::Result, session::Session}; pub use crate::{error::Error, error::Result, session::Session};
pub use matrix_sdk_types::*;
pub use reqwest::header::InvalidHeaderValue; pub use reqwest::header::InvalidHeaderValue;
pub use ruma_api;
pub use ruma_client_api as api;
pub use ruma_events as events;
pub use ruma_identifiers as identifiers;
mod async_client; mod async_client;
mod base_client; mod base_client;

View File

@ -33,7 +33,7 @@ use crate::events::room::{
use crate::events::EventType; use crate::events::EventType;
use crate::identifiers::{RoomAliasId, RoomId, UserId}; use crate::identifiers::{RoomAliasId, RoomId, UserId};
use js_int::{Int, UInt}; use crate::js_int::{Int, UInt};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Default, PartialEq, Serialize, Deserialize)] #[derive(Debug, Default, PartialEq, Serialize, Deserialize)]
/// `RoomName` allows the calculation of a text room name. /// `RoomName` allows the calculation of a text room name.
@ -527,13 +527,16 @@ mod test {
assert!(room.power_levels.is_some()); assert!(room.power_levels.is_some());
assert_eq!( assert_eq!(
room.power_levels.as_ref().unwrap().kick, room.power_levels.as_ref().unwrap().kick,
js_int::Int::new(50).unwrap() crate::js_int::Int::new(50).unwrap()
); );
let admin = room let admin = room
.members .members
.get(&UserId::try_from("@example:localhost").unwrap()) .get(&UserId::try_from("@example:localhost").unwrap())
.unwrap(); .unwrap();
assert_eq!(admin.power_level.unwrap(), js_int::Int::new(100).unwrap()); assert_eq!(
admin.power_level.unwrap(),
crate::js_int::Int::new(100).unwrap()
);
} }
#[test] #[test]

View File

@ -23,7 +23,7 @@ use crate::events::room::{
}; };
use crate::identifiers::UserId; use crate::identifiers::UserId;
use js_int::{Int, UInt}; use crate::js_int::{Int, UInt};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
// Notes: if Alice invites Bob into a room we will get an event with the sender as Alice and the state key as Bob. // Notes: if Alice invites Bob into a room we will get an event with the sender as Alice and the state key as Bob.
@ -205,7 +205,7 @@ mod test {
use crate::identifiers::{RoomId, UserId}; use crate::identifiers::{RoomId, UserId};
use crate::test_builder::EventBuilder; use crate::test_builder::EventBuilder;
use js_int::{Int, UInt}; use crate::js_int::{Int, UInt};
use std::convert::TryFrom; use std::convert::TryFrom;

View File

@ -10,7 +10,7 @@ use api::r0::room::{
Visibility, Visibility,
}; };
use js_int::UInt; use crate::js_int::UInt;
/// A builder used to create rooms. /// A builder used to create rooms.
/// ///
@ -293,11 +293,11 @@ mod test {
use std::collections::BTreeMap; use std::collections::BTreeMap;
use super::*; use super::*;
use crate::api::r0::filter::{LazyLoadOptions, RoomEventFilter};
use crate::events::room::power_levels::NotificationPowerLevels; use crate::events::room::power_levels::NotificationPowerLevels;
use crate::js_int::Int;
use crate::{identifiers::RoomId, AsyncClient, Session}; use crate::{identifiers::RoomId, AsyncClient, Session};
use api::r0::filter::{LazyLoadOptions, RoomEventFilter};
use js_int::Int;
use mockito::{mock, Matcher}; use mockito::{mock, Matcher};
use std::convert::TryFrom; use std::convert::TryFrom;
use url::Url; use url::Url;

View File

@ -15,7 +15,7 @@
//! User sessions. //! User sessions.
use ruma_identifiers::UserId; use crate::identifiers::UserId;
/// A user session, containing an access token and information about the associated user account. /// A user session, containing an access token and information about the associated user account.
#[derive(Clone, Debug, Eq, Hash, PartialEq)] #[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct Session { pub struct Session {

View File

@ -1,5 +1,8 @@
pub use js_int; pub use js_int;
pub use ruma_api::Endpoint; pub use ruma_api::{
error::{FromHttpResponseError, IntoHttpError, ServerError},
Endpoint,
};
pub use ruma_client_api as api; pub use ruma_client_api as api;
pub use ruma_events as events; pub use ruma_events as events;
pub use ruma_identifiers as identifiers; pub use ruma_identifiers as identifiers;