crates/monetize-server/examples/estate_svg.rs
//! Draw an estate and print the SVG to stdout.
//!
//! cargo run -p monetize-server --example estate_svg > estate.svg
//!
//! The shape below is the gunnar.rs estate as it stands: a front, an appliance,
//! and a twin that is not answering. It is written out here rather than read off
//! a config so that the example stands alone: the SERVER reads the same picture
//! off `[machines]` through `estate_svg::from_config` and serves it over
//! `EstateAdmin.Draw`, and no number here is typed by hand there.
//!
//! Provider ids are deliberately fake. This file is in the OPEN repository.
use monetize_server::estate_svg::{estate_svg, CloudRow, Disk, Estate, Liveness, Machine, Role};
fn main() {
let estate = Estate {
product: "gunnar".into(),
tenants: Some(11),
machines: vec![
Machine {
id: "front".into(),
role: Role::Front,
title: "caddy · gunnar-ui · monetize".into(),
cloud: "upcloud".into(),
server_id: "0000-front".into(),
plan: Some("STARTER-4xCPU-8GB".into()),
declared_vcpu: Some(4),
declared_ram_mb: Some(8192),
disk: Some(Disk { used_bytes: 9 << 30, total_bytes: 40 << 30, growable: false }),
liveness: Liveness::Up,
measured_cpu_millicores: None,
measured_ram_bytes: None,
note: String::new(),
headline: String::new(),
},
Machine {
id: "main".into(),
role: Role::Appliance,
title: "the forge, no shell".into(),
cloud: "upcloud".into(),
server_id: "0000-appliance".into(),
plan: Some("STARTER-4xCPU-16GB".into()),
declared_vcpu: Some(4),
declared_ram_mb: Some(16384),
// Measured 2026-09-18: 4x10 GiB raid0, 39.8 GiB free of 37.8 servable.
disk: Some(Disk {
used_bytes: 43_714_560,
total_bytes: 40_588_369_920,
growable: false,
}),
liveness: Liveness::Up,
// Admin.Capacity's own ceilings, measured off the box.
measured_cpu_millicores: Some(4000),
measured_ram_bytes: Some(16 << 30),
note: "grows in place; this boot stack carries no engine".into(),
headline: String::new(),
},
Machine {
id: "twin".into(),
role: Role::Twin,
title: "the log-holder, no shell".into(),
cloud: "upcloud".into(),
server_id: "0000-twin".into(),
plan: Some("STARTER-1xCPU-1GB".into()),
declared_vcpu: Some(1),
declared_ram_mb: Some(1024),
// One 20 GB hdd volume, xfs. Not measured: the twin is dark.
disk: None,
liveness: Liveness::Silent,
measured_cpu_millicores: None,
measured_ram_bytes: None,
note: "has not polled since this server started".into(),
headline: String::new(),
},
],
clouds: vec![
CloudRow { name: "upcloud".into(), spends: true, is_default: true },
CloudRow { name: "server".into(), spends: false, is_default: false },
],
..Estate::default()
};
print!("{}", estate_svg(&estate));
}