Unofficial Rust crate for interacting with the cloud-hypervisor REST API
The cloud-hypervisor-client
crate can be used for managing the endpoints provided by a cloud-hypervisor socket in your
Rust project.
The API client code of this crate has been auto-generated from the OpenAPI description for the cloud-hypervisor REST API using OpenAPI Generator.
A very basic example for listing all existing servers:
use cloud_hypervisor_client::apis::configuration::Configuration;
use cloud_hypervisor_client::apis::default_api::vm_info_get;
#[tokio::main]
async fn main() -> Result<(), String> {
let configuration = Configuration::new();
let vm_info = vm_info_get(&configuration)
.await
.map_err(|err| format!("API call to vm_info_get failed: {:?}", err))?;
println!("Received vm info: {vm_info:?}");
Ok(())
}
For more examples check out the examples folder in the Git repository.
The underlying TLS implementation for reqwest
can be selected
using Cargo features:
- default-tls (enabled by default): Provides TLS support to connect over HTTPS.
- native-tls: Enables TLS functionality provided by
native-tls
. - native-tls-vendored: Enables the
vendored
feature ofnative-tls
. - rustls-tls: Enables TLS functionality provided by
rustls
.
(Refer to Optional Features in the reqwest
documentation.)
Example for using the TLS functionality provided by rustls
:
[dependencies]
cloud_hypervisor_client = { version = "*", default-features = false, features = ["rustls-tls"] }
This crate was based on the great work done in: https://github.com/HenningHolmDE/hcloud-rust.