Build Directly in Rust

Build directly in Rust when you want your application to talk to the Autonomi Network without using antd. This approach gives your application direct access to networking, uploads, and downloads from your Rust code. The library that provides that interface is ant-core.

Prerequisites

  • Rust toolchain

  • A local checkout of ant-client

  • A new or existing Rust application

If you want a daemon-backed local gateway instead, see Build with the SDKs and Start the Local Daemon. If you want shell access instead of writing Rust code, see Use the CLI.

Steps

1. Create a Rust app and add ant-core

git clone https://github.com/WithAutonomi/ant-client.git
cargo new autonomi-rust-app
cd autonomi-rust-app

Update Cargo.toml:

[dependencies]
ant-core = { path = "../ant-client/ant-core", 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

This example starts a local Autonomi development network, 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 talked to the network through ant-core, without antd or a CLI wrapper. ant-core started a local devnet, created a funded client, handled self-encryption and payment, and gave you direct access to the upload and download results in Rust.

Next steps

Last updated