Skip to content

Commit

Permalink
Remove + Send from CallMethod trait, Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed May 3, 2023
1 parent 71b5507 commit 8682087
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
14 changes: 4 additions & 10 deletions bindings/core/src/method_handler/call_method.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

#[cfg(not(target_family = "wasm"))]
use std::pin::Pin;

#[cfg(not(target_family = "wasm"))]
use futures::Future;
use iota_sdk::{
client::{secret::SecretManager, Client},
Expand All @@ -22,37 +20,33 @@ use crate::{
UtilsMethod,
};

#[cfg(not(target_family = "wasm"))]
pub trait CallMethod {
type Method;

// This uses a manual async_trait-like impl because it's not worth it to import the lib for one trait
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + Send + 'a>>;
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + 'a>>;
}

#[cfg(not(target_family = "wasm"))]
impl CallMethod for Client {
type Method = ClientMethod;

fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + Send + 'a>> {
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + 'a>> {
Box::pin(call_client_method(self, method))
}
}

#[cfg(not(target_family = "wasm"))]
impl CallMethod for Wallet {
type Method = WalletMethod;

fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + Send + 'a>> {
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + 'a>> {
Box::pin(call_wallet_method(self, method))
}
}

#[cfg(not(target_family = "wasm"))]
impl CallMethod for SecretManager {
type Method = SecretManagerMethod;

fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + Send + 'a>> {
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + 'a>> {
Box::pin(call_secret_manager_method(self, method))
}
}
Expand Down
6 changes: 3 additions & 3 deletions bindings/core/src/method_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ mod secret_manager;
mod utils;
mod wallet;

#[cfg(not(target_family = "wasm"))]
pub use call_method::CallMethod;
pub use call_method::{call_client_method, call_secret_manager_method, call_utils_method, call_wallet_method};
pub use call_method::{
call_client_method, call_secret_manager_method, call_utils_method, call_wallet_method, CallMethod,
};
#[cfg(feature = "mqtt")]
pub use client::listen_mqtt;
2 changes: 1 addition & 1 deletion sdk/src/wallet/wallet/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl WalletBuilder {
#[cfg(feature = "storage")]
let read_manager_builder = storage_manager.lock().await.get_wallet_data().await?;
#[cfg(not(feature = "storage"))]
let read_manager_builder: Option<WalletBuilder> = None;
let read_manager_builder: Option<Self> = None;

// Prioritize provided client_options and secret_manager over stored ones
let new_provided_client_options = if self.client_options.is_none() {
Expand Down

0 comments on commit 8682087

Please sign in to comment.