fauna-api 1.0.861

The Fauna SDK for Rust: accounts, Drive, groups, calendar, chats, payments, Parrot and live rooms.
Documentation
use serde::{Deserialize, Serialize};
use serde_json::Value;

/// A machine's size. vCPUs and memory are the most a machine gets; tflops and GPU memory the
/// least; storage at least the repository's disk.
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Spec {
    pub vcpus: u32,
    pub memory_bytes: u64,
    pub storage_bytes: u64,
    /// Dense BF16. 0 asks for no GPU.
    pub tflops: f64,
    pub gpu_memory_bytes: u64,
}

impl Spec {
    pub fn from_json(json: &Value) -> Spec {
        Spec {
            vcpus: json["vcpus"].as_f64().unwrap_or_default() as u32,
            memory_bytes: json["memoryBytes"].as_f64().unwrap_or_default() as u64,
            storage_bytes: json["storageBytes"].as_f64().unwrap_or_default() as u64,
            tflops: json["tflops"].as_f64().unwrap_or_default(),
            gpu_memory_bytes: json["gpuMemoryBytes"].as_f64().unwrap_or_default() as u64,
        }
    }
}

/// 2 vCPUs, 4 GiB of memory and 8 GiB of storage, with no GPU.
pub const STANDARD_SPEC: Spec = Spec {
    vcpus: 2,
    memory_bytes: 4 << 30,
    storage_bytes: 8 << 30,
    tflops: 0.0,
    gpu_memory_bytes: 0,
};