cloud-hypervisor-client 0.4.0+api-spec-0.3.0-2026-05-04

Unofficial Rust crate for accessing the cloud-hypervisor REST API.
Documentation
use std::fmt;
use std::fmt::Debug;

use hyper;
use hyper::http;
use hyper_util::client::legacy::connect::Connect;
use serde_json;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("ApiError: {0:?}")]
    Api(ApiError),
    #[error("InvalidHeaderValue: {0}")]
    Header(http::header::InvalidHeaderValue),
    #[error("Http: {0}")]
    Http(http::Error),
    #[error("Hyper: {0}")]
    Hyper(hyper::Error),
    #[error("HyperClient: {0}")]
    HyperClient(hyper_util::client::legacy::Error),
    #[error("serde_json::Error: {0}")]
    Serde(serde_json::Error),
    #[error("InvalidUri: {0}")]
    UriError(http::uri::InvalidUri),
}

pub struct ApiError {
    pub code: hyper::StatusCode,
    pub body: String,
}

impl Debug for ApiError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.debug_struct("ApiError")
            .field("code", &self.code)
            .field("body", &self.body)
            .finish()
    }
}

impl From<(hyper::StatusCode, String)> for Error {
    fn from(e: (hyper::StatusCode, String)) -> Self {
        Error::Api(ApiError {
            code: e.0,
            body: e.1,
        })
    }
}

impl From<http::Error> for Error {
    fn from(e: http::Error) -> Self {
        Error::Http(e)
    }
}

impl From<hyper_util::client::legacy::Error> for Error {
    fn from(e: hyper_util::client::legacy::Error) -> Self {
        Error::HyperClient(e)
    }
}

impl From<hyper::Error> for Error {
    fn from(e: hyper::Error) -> Self {
        Error::Hyper(e)
    }
}

impl From<serde_json::Error> for Error {
    fn from(e: serde_json::Error) -> Self {
        Error::Serde(e)
    }
}

mod request;

mod default_api;
pub use self::default_api::{DefaultApi, DefaultApiClient};

pub mod client;
pub mod configuration;