fedimint_api_client::api

Trait IRawFederationApi

Source
pub trait IRawFederationApi:
    Debug
    + MaybeSend
    + MaybeSync {
    // Required methods
    fn all_peers(&self) -> &BTreeSet<PeerId>;
    fn self_peer(&self) -> Option<PeerId>;
    fn with_module(&self, id: ModuleInstanceId) -> DynModuleApi;
    fn request_raw<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        peer_id: PeerId,
        method: &'life1 str,
        params: &'life2 [Value],
    ) -> Pin<Box<dyn Future<Output = Result<Value, JsonRpcClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

An API (module or global) that can query a federation

Required Methods§

Source

fn all_peers(&self) -> &BTreeSet<PeerId>

List of all federation peers for the purpose of iterating each peer in the federation.

The underlying implementation is responsible for knowing how many and PeerIds of each. The caller of this interface most probably have some idea as well, but passing this set across every API call to the federation would be inconvenient.

Source

fn self_peer(&self) -> Option<PeerId>

PeerId of the Guardian node, if set

This is for using Client in a “Admin” mode, making authenticated calls to own fedimintd instance.

Source

fn with_module(&self, id: ModuleInstanceId) -> DynModuleApi

Source

fn request_raw<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, peer_id: PeerId, method: &'life1 str, params: &'life2 [Value], ) -> Pin<Box<dyn Future<Output = Result<Value, JsonRpcClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Make request to a specific federation peer by peer_id

Implementors§

Source§

impl<C: JsonRpcClient + Debug + 'static> IRawFederationApi for WsFederationApi<C>

Implementation of API calls over WebSockets

Can function as either the global or module API

Source§

impl<T> IRawFederationApi for GlobalFederationApiWithCache<T>
where T: IRawFederationApi + MaybeSend + MaybeSync + 'static,