Files
nym/sdk/rust/nym-sdk/src/bandwidth.rs
T
Bogdan-Ștefan Neacşu 18891e5f20 Use ecash credential type for bandwidth value (#4840)
* Use ecash credential type for bandwidth value

* Fill explicit default value for args

* Use up-to-date values for tickets

* Fix sdk example default value

* Another default

* Fix sdk test

* Fix TicketTypeRepr default
2024-09-05 13:19:19 +02:00

46 lines
1.4 KiB
Rust

// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
//! The coconut bandwidth component of the Rust SDK for the Nym platform
//!
//!
//! # Basic example
//!
//! ```no_run
//! use nym_sdk::mixnet::{self, MixnetMessageSender};
//! use nym_credentials_interface::TicketType;
//!
//! #[tokio::main]
//! async fn main() {
//! let mixnet_client = mixnet::MixnetClientBuilder::new_ephemeral()
//! .enable_credentials_mode()
//! .build()
//! .unwrap();
//!
//! let bandwidth_client = mixnet_client.create_bandwidth_client(String::from("my super secret mnemonic"), TicketType::V1MixnetEntry).await.unwrap();
//!
//! // Get a bandwidth credential for the mixnet_client
//! bandwidth_client.acquire().await.unwrap();
//!
//! // Connect using paid bandwidth credential
//! let mut client = mixnet_client.connect_to_mixnet().await.unwrap();
//!
//! let our_address = client.nym_address();
//!
//! // Send a message throughout the mixnet to ourselves
//! client.send_plain_message(*our_address, "hello there").await.unwrap();
//!
//! println!("Waiting for message");
//! if let Some(received) = client.wait_for_messages().await {
//! for r in received {
//! println!("Received: {}", String::from_utf8_lossy(&r.message));
//! }
//! }
//!
//! client.disconnect().await;
//! }
//! ```
mod client;
pub use client::BandwidthAcquireClient;