-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2023 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use std::pin::Pin; | ||
|
||
use futures::Future; | ||
use iota_sdk::{ | ||
client::{secret::SecretManager, Client}, | ||
wallet::Wallet, | ||
}; | ||
|
||
use crate::{ | ||
call_client_method, call_secret_manager_method, call_wallet_method, ClientMethod, Response, SecretManagerMethod, | ||
WalletMethod, | ||
}; | ||
|
||
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>>; | ||
} | ||
|
||
impl CallMethod for Client { | ||
type Method = ClientMethod; | ||
|
||
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + Send + 'a>> { | ||
Box::pin(call_client_method(self, method)) | ||
} | ||
} | ||
|
||
impl CallMethod for Wallet { | ||
type Method = WalletMethod; | ||
|
||
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + Send + 'a>> { | ||
Box::pin(call_wallet_method(self, method)) | ||
} | ||
} | ||
|
||
impl CallMethod for SecretManager { | ||
type Method = SecretManagerMethod; | ||
|
||
fn call_method<'a>(&'a self, method: Self::Method) -> Pin<Box<dyn Future<Output = Response> + Send + 'a>> { | ||
Box::pin(call_secret_manager_method(self, method)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters