Expand description
§HyveOS SDK
This crate provides a high-level API for interacting with the HyveOS runtime.
Note: By default, the
Connection
struct assumes that it’s running inside a script docker container, started by the HyveOS runtime. To use the SDK elsewhere, the connection can be configured usingConnectionBuilder
.
§Crate Features
json
- Enables JSON (de-)serialization for data exchanged with other nodes.cbor
- Enables CBOR (de-)serialization for data exchanged with other nodes.
§Example
use futures::StreamExt as _;
use hyveos_sdk::Connection;
#[tokio::main]
async fn main() {
let connection = Connection::new().await.unwrap();
let mut dht_service = connection.dht();
let peer_id = dht_service
.get_providers("identification", "example")
.await
.unwrap()
.next()
.await
.unwrap()
.unwrap();
let mut req_resp_service = connection.req_resp();
let response = req_resp_service
.send_request(peer_id, "Hello, world!", None)
.await
.unwrap();
let data = Vec::try_from(response).unwrap();
println!("Received response: {}", String::from_utf8(data).unwrap());
}
Modules§
Structs§
- A connection to the HyveOS runtime.
- A builder for configuring a connection to the HyveOS runtime.
- Identifier of a peer of the network.
- Uri
network
The URI component of a request.
Enums§
- The error type for the SDK.