Crate sn_client[][src]

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 sn_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 sn_client::Client;
use rand::rngs::OsRng;
use sn_data_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 self::client::map_info;
pub use self::client::Client;
pub use self::client::MapInfo;

Modules

client

Client trait and related constants.

config_handler

Config file handling.

crypto

Cryptographic utilities. Secret encryption and signing keys with more secure cloning semantics. These keys implement implicit sharing of the underlying sensitive data to avoid multiple copies of it stored in the memory, preventing certain class of attacks.

utils

Utility functions.

Macros

btree_map

Easily create a BTreeMap with the key => value syntax.

btree_set

Easily create a BTreeSet.

Structs

QuicP2pConfig

QuicP2p configurations

Enums

Error

Client Errors

ErrorMessage

Main error type for the crate.

TransfersError

SafeNetwork Transfers error type