Expand description
Connect to and build on the Autonomi network.
§Example
use autonomi::{Bytes, Client, Wallet};
use autonomi::client::payment::PaymentOption;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::init().await?;
// Default wallet of testnet.
let key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
let wallet = Wallet::new_from_private_key(Default::default(), key)?;
let payment = PaymentOption::Wallet(wallet);
// Put and fetch data.
let (cost, data_addr) = client.data_put_public(Bytes::from("Hello, World"), payment.clone()).await?;
let _data_fetched = client.data_get_public(&data_addr).await?;
// Put and fetch directory from local file system.
let (cost, dir_addr) = client.dir_upload_public("files/to/upload".into(), payment).await?;
client.dir_download_public(&dir_addr, "files/downloaded".into()).await?;
Ok(())
}
§Data types
This API gives access to the four fundamental types on the network: Chunk
, Pointer
, Scratchpad
and GraphEntry
.
When we upload data, it’s split into chunks using self-encryption, yielding a ‘datamap’ allowing us to reconstruct the data again. Any two people that upload the exact same data will get the same datamap, as all chunks are content-addressed and self-encryption is deterministic.
§Features
loud
: Print debug information to stdout
Re-exports§
pub use client::data_types::chunk;
pub use client::data_types::graph;
pub use client::data_types::pointer;
pub use client::data_types::scratchpad;
pub use client::data;
pub use client::files;
pub use client::register;
pub use client::vault;
pub use bytes::Bytes;
pub use libp2p::Multiaddr;
Modules§
- client
- networking
- self_
encryption - version
- Network versioning
Structs§
- Atto
Tokens - An amount in SNT Atto. 10^18 Nanos = 1 SNT.
- Bootstrap
Cache Config - Configuration for the bootstrap cache
- Chunk
- Chunk, an immutable chunk of data
- Chunk
Address - Address of a
crate::storage::chunks::Chunk
. - Client
- Represents a client for the Autonomi network.
- Client
Config - Configuration for the
crate::Client
which can be provided through:crate::Client::init_with_config
. - Client
Operating Strategy - Strategy configuration for data operations by the client.
- Graph
Entry - A generic GraphEntry on the Network.
- Graph
Entry Address - Address of a
crate::storage::graph::GraphEntry
. - Initial
Peers Config - Configurations to fetch the initial peers which is used to bootstrap the network. This could optionally also be used as a command line argument struct.
- Pointer
- Pointer, a mutable address pointing to other data on the Network It is stored at the owner’s public key and can only be updated by the owner
- Pointer
Address - Address of a
crate::storage::pointer::Pointer
It is derived from the owner’s public key - Public
Key - A public key.
- Scratchpad
- Scratchpad, a mutable space for encrypted data on the Network
- Scratchpad
Address - Address of a
crate::storage::scratchpad::Scratchpad
It is derived from the owner’s public key - Secret
Key - A secret key; wraps a single prime field element. The field element is
heap allocated to avoid any stack copying that result when passing
SecretKey
s between stack frames. - Signature
- A signature.
- Transaction
Config - Wallet
- XorName
- A 256-bit number, viewed as a point in XOR space.
Enums§
Functions§
- get_
evm_ network - Initialize the EVM Network.