Fix unused import warnings for wasm

master
Jonas Platte 2021-06-23 14:10:23 +02:00
parent 089ab20e7c
commit aabda60e9f
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
3 changed files with 20 additions and 16 deletions

View File

@ -13,11 +13,12 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#[cfg(all(feature = "encryption", not(target_arch = "wasm32")))]
use std::path::PathBuf;
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use std::{ use std::{
collections::BTreeMap, collections::BTreeMap,
io::{Cursor, Write}, io::{Cursor, Write},
path::PathBuf,
}; };
#[cfg(feature = "sso_login")] #[cfg(feature = "sso_login")]
use std::{ use std::{
@ -39,10 +40,12 @@ use futures_timer::Delay as sleep;
use http::HeaderValue; use http::HeaderValue;
#[cfg(feature = "sso_login")] #[cfg(feature = "sso_login")]
use http::Response; use http::Response;
#[cfg(all(feature = "encryption", not(target_arch = "wasm32")))]
use matrix_sdk_base::crypto::{decrypt_key_export, encrypt_key_export, olm::InboundGroupSession};
#[cfg(feature = "encryption")] #[cfg(feature = "encryption")]
use matrix_sdk_base::crypto::{ use matrix_sdk_base::crypto::{
decrypt_key_export, encrypt_key_export, olm::InboundGroupSession, store::CryptoStoreError, store::CryptoStoreError, AttachmentDecryptor, OutgoingRequests, RoomMessageRequest,
AttachmentDecryptor, OutgoingRequests, RoomMessageRequest, ToDeviceRequest, ToDeviceRequest,
}; };
use matrix_sdk_base::{ use matrix_sdk_base::{
deserialized_responses::SyncResponse, deserialized_responses::SyncResponse,
@ -64,7 +67,7 @@ use tracing::{error, info, instrument};
use url::Url; use url::Url;
#[cfg(feature = "sso_login")] #[cfg(feature = "sso_login")]
use warp::Filter; use warp::Filter;
#[cfg(feature = "encryption")] #[cfg(all(feature = "encryption", not(target_arch = "wasm32")))]
use zeroize::Zeroizing; use zeroize::Zeroizing;
/// Enum controlling if a loop running callbacks should continue or abort. /// Enum controlling if a loop running callbacks should continue or abort.
@ -2427,8 +2430,7 @@ impl Client {
/// .expect("Can't export keys."); /// .expect("Can't export keys.");
/// # }); /// # });
/// ``` /// ```
#[cfg(feature = "encryption")] #[cfg(all(feature = "encryption", not(target_arch = "wasm32")))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(feature = "docs", doc(cfg(all(encryption, not(target_arch = "wasm32")))))] #[cfg_attr(feature = "docs", doc(cfg(all(encryption, not(target_arch = "wasm32")))))]
pub async fn export_keys( pub async fn export_keys(
&self, &self,
@ -2487,8 +2489,7 @@ impl Client {
/// .expect("Can't import keys"); /// .expect("Can't import keys");
/// # }); /// # });
/// ``` /// ```
#[cfg(feature = "encryption")] #[cfg(all(feature = "encryption", not(target_arch = "wasm32")))]
#[cfg(not(target_arch = "wasm32"))]
#[cfg_attr(feature = "docs", doc(cfg(all(encryption, not(target_arch = "wasm32")))))] #[cfg_attr(feature = "docs", doc(cfg(all(encryption, not(target_arch = "wasm32")))))]
pub async fn import_keys(&self, path: PathBuf, passphrase: &str) -> Result<(usize, usize)> { pub async fn import_keys(&self, path: PathBuf, passphrase: &str) -> Result<(usize, usize)> {
let olm = self.base_client.olm_machine().await.ok_or(Error::AuthenticationRequired)?; let olm = self.base_client.olm_machine().await.ok_or(Error::AuthenticationRequired)?;

View File

@ -12,16 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#[cfg(all(not(target_arch = "wasm32")))]
use std::sync::atomic::{AtomicU64, Ordering};
use std::{convert::TryFrom, fmt::Debug, sync::Arc}; use std::{convert::TryFrom, fmt::Debug, sync::Arc};
#[cfg(all(not(target_arch = "wasm32")))]
use backoff::{future::retry, Error as RetryError, ExponentialBackoff};
use bytes::{Bytes, BytesMut}; use bytes::{Bytes, BytesMut};
#[cfg(all(not(target_arch = "wasm32")))] use http::Response as HttpResponse;
use http::StatusCode;
use http::{HeaderValue, Response as HttpResponse};
use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps}; use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps};
use reqwest::{Client, Response}; use reqwest::{Client, Response};
use ruma::api::{ use ruma::api::{
@ -236,6 +230,8 @@ pub(crate) fn client_with_config(config: &ClientConfig) -> Result<Client, HttpEr
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
let http_client = { let http_client = {
use http::HeaderValue;
let http_client = if config.disable_ssl_verification { let http_client = if config.disable_ssl_verification {
http_client.danger_accept_invalid_certs(true) http_client.danger_accept_invalid_certs(true)
} else { } else {
@ -304,6 +300,11 @@ async fn send_request(
request: http::Request<Bytes>, request: http::Request<Bytes>,
config: RequestConfig, config: RequestConfig,
) -> Result<http::Response<Bytes>, HttpError> { ) -> Result<http::Response<Bytes>, HttpError> {
use std::sync::atomic::{AtomicU64, Ordering};
use backoff::{future::retry, Error as RetryError, ExponentialBackoff};
use http::StatusCode;
let mut backoff = ExponentialBackoff::default(); let mut backoff = ExponentialBackoff::default();
let mut request = reqwest::Request::try_from(request)?; let mut request = reqwest::Request::try_from(request)?;
let retry_limit = config.retry_limit; let retry_limit = config.retry_limit;

View File

@ -16,7 +16,7 @@ use std::{convert::TryFrom, sync::Arc};
use dashmap::DashMap; use dashmap::DashMap;
use matrix_sdk_common::{locks::Mutex, uuid::Uuid}; use matrix_sdk_common::{locks::Mutex, uuid::Uuid};
use ruma::{uint, DeviceId, MilliSecondsSinceUnixEpoch, UInt, UserId}; use ruma::{DeviceId, MilliSecondsSinceUnixEpoch, UserId};
use tracing::{info, trace, warn}; use tracing::{info, trace, warn};
use super::{ use super::{
@ -123,6 +123,8 @@ impl VerificationMachine {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
fn is_timestamp_valid(timestamp: &MilliSecondsSinceUnixEpoch) -> bool { fn is_timestamp_valid(timestamp: &MilliSecondsSinceUnixEpoch) -> bool {
use ruma::{uint, UInt};
// The event should be ignored if the event is older than 10 minutes // The event should be ignored if the event is older than 10 minutes
let old_timestamp_threshold: UInt = uint!(600); let old_timestamp_threshold: UInt = uint!(600);
// The event should be ignored if the event is 5 minutes or more into the // The event should be ignored if the event is 5 minutes or more into the