Module safe_network::client[][src]

Expand description

The Safe Network Client.

In order to connect to The Safe Network you’ll need to send messages back and forth to network nodes. The Client has everything needed to perform this communication, with APIs to enable working with data.

With these APIs you can easily:

  • Connect to The Safe Network
  • Read Public data from the network
  • Write data to the network (assuming you have a SafeCoin balance)

Basic Usage

Setting up a random client for read only access:

use safe_network::client::Client;
let client = Client::new(None, None, bootstrap_contacts).await?;
// Now for example you can perform read operations:
let _some_balance = client.get_balance().await?;

Or use a pre-existing SecretKey which has a SafeCoin balance to be able to write to the network:

use safe_network::client::Client;
use rand::rngs::OsRng;
use safe_network::types::Keypair;
let id = Keypair::new_ed25519(&mut OsRng);
let client = Client::new(Some(id), None, bootstrap_contacts).await?;
// Now for example you can perform read operations:
let _some_balance = client.get_balance().await?;

Re-exports

pub use client_api::Client;

Modules

client_api

Client trait and related constants.

config_handler

Config file handling.

utils

Utility functions.

Structs

QuicP2pConfig

QuicP2p configurations

Enums

Error

Client Errors

ErrorMessage

Main error type for the crate.

TransfersError

SafeNetwork Transfers error type