Build Directly in Rust
Choose Direct Rust when you want your application to talk to the Autonomi Network without using antd. This interface gives your application direct access to networking, uploads, and downloads through ant-core.
This guide uses ant-core 0.10.0 with its devnet feature for local development. See the Rust Library Reference for the direct-network dependency.
Prerequisites
Rust 1.91 or later
Foundry with
anvilavailable onPATHA new or existing Rust application
To connect through a local background service instead, see Local-Daemon Clients and Start the Local Daemon. For shell access instead of writing Rust code, see Use the CLI.
Steps
1. Create a Rust app and add ant-core
cargo new autonomi-rust-app
cd autonomi-rust-app
anvil --versionThe final command must print an Anvil version before you continue. LocalDevnet starts an Anvil process for local Ethereum Virtual Machine (EVM) payments.
Update Cargo.toml:
[dependencies]
ant-core = { version = "=0.10.0", features = ["devnet"] }
bytes = "1"
tokio = { version = "1", features = ["full"] }2. Start a local devnet and upload data from Rust
Replace src/main.rs with:
3. Run the app
On success, the final output includes Stored <number> chunks. The exact number depends on self-encryption, but it is greater than zero.
This example starts a local development network for Autonomi, creates a funded Rust client with local payment approval already in place, uploads a payload, downloads it again, and shuts the devnet down.
What happened
Your Rust application used Direct Rust through ant-core, without antd or a CLI wrapper. ant-core started a local devnet, created a client funded by the local Anvil chain, handled self-encryption and local payment, and gave you direct access to the upload and download results in Rust.
Next steps
Last updated