WalletStandardDisconnect

Trait WalletStandardDisconnect 

Source
pub trait WalletStandardDisconnect: Wallet {
    // Required method
    fn disconnect<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), WalletError>> + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

Trait for wallets that support disconnecting.

This trait defines a method for disconnecting from a wallet, which revokes the app’s authorization to use the wallet’s accounts. After disconnecting, the app will need to connect again to use the wallet.

§Example Implementation

#[async_trait(?Send)]
impl WalletStandardDisconnect for MyWallet {
    async fn disconnect(&mut self) -> WalletResult<()> {
        // Clear the current account
        self.current_account = None;

        // Optionally, perform any cleanup or notify the wallet's backend
        self.notify_backend_of_disconnect().await?;

        Ok(())
    }
}

Required Methods§

Source

fn disconnect<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), WalletError>> + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Disconnect from the wallet.

This method revokes the app’s authorization to use the wallet’s accounts. It should clear the wallet’s current account and perform any necessary cleanup.

§Returns

A WalletResult containing () if the disconnection is successful, or a WalletError if the disconnection fails.

§Errors

This method may return errors such as:

  • WalletError::WalletDisconnection if the disconnection fails
  • WalletError::WalletDisconnected if the wallet is already disconnected

Implementors§