use semver::Version as Semver;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Version {
pub api: Semver,
pub server: Semver,
pub text: String,
pub nozzle_diameter: f32,
pub hostname: String,
pub capabilities: VersionCapabilities,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct VersionCapabilities {
#[serde(rename = "upload-by-put")]
pub upload_by_put: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct V1Info {
pub nozzle_diameter: f32,
pub mmu: bool,
pub serial: String,
pub hostname: String,
pub min_extrusion_temp: u32,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct V1Status {
pub storage: V1StorageStatus,
pub printer: V1PrinterStatus,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct V1StorageStatus {
pub path: String,
pub name: String,
pub read_only: bool,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
pub enum V1State {
Idle,
Busy,
Printing,
Paused,
Finished,
Stopped,
Error,
Attention,
Ready,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct V1PrinterStatus {
pub state: V1State,
pub temp_bed: f32,
pub target_bed: f32,
pub temp_nozzle: f32,
pub target_nozzle: f32,
pub axis_x: f32,
pub axis_y: f32,
pub axis_z: f32,
pub flow: u32,
pub speed: u32,
pub fan_hotend: u32,
pub fan_print: u32,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct V1Storage {
pub storage_list: Vec<StorageItem>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum StorageKind {
Usb,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct StorageItem {
pub path: String,
pub name: String,
#[serde(rename = "type")]
pub kind: StorageKind,
pub read_only: bool,
pub available: bool,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OctoPrinter {
pub telemetry: OctoTelemetry,
pub temperature: OctoTemperatures,
pub state: OctoState,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct OctoTelemetry {
pub temp_bed: f32,
pub temp_nozzle: f32,
pub print_speed: u32,
pub z_height: f32,
pub material: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OctoTemperatures {
pub tool0: OctoTemperature,
pub bed: OctoTemperature,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OctoTemperature {
pub actual: f32,
pub target: f32,
pub offset: f32,
pub display: Option<f32>,
}
#[derive(Debug, Clone, Deserialize)]
pub enum OctoStateText {
Printing,
Operational,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OctoState {
pub text: OctoStateText,
pub flags: OctoFlags,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum LinkState {
Busy,
Printing,
Paused,
Attention,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OctoFlags {
pub link_state: Option<LinkState>,
pub operational: bool,
pub paused: bool,
pub printing: bool,
pub cancelling: bool,
pub pausing: bool,
pub error: bool,
pub sd_ready: bool,
pub closed_on_error: bool,
pub ready: bool,
pub busy: bool,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub enum OctoJobState {
Unknown,
Printing,
CrashRecovery,
Pausing,
Resuming,
Cancelling,
Operational,
Error,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OctoJob {
pub state: OctoJobState,
pub job: Option<OctoJobDetails>,
pub progress: Option<OctoProgress>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OctoJobDetails {
pub estimated_print_time: String,
pub file: OctoFileMetadata,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OctoFileMetadata {
pub name: String,
pub path: String,
pub display: String,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct OctoProgress {
pub print_time_left: Option<u32>,
pub completion: f32,
pub print_time: u32,
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
pub enum V1JobState {
Printing,
Paused,
Finished,
Stopped,
Error,
}
#[derive(Debug, Clone, Deserialize)]
pub struct V1Job {
pub id: u32,
pub state: V1JobState,
pub progress: f32,
pub time_remaining: Option<u32>,
pub time_printing: u32,
pub file: V1JobFile,
}
#[derive(Debug, Clone, Deserialize)]
pub struct V1JobFile {
pub refs: V1JobFileRefs,
pub name: String,
pub display_name: String,
pub path: String,
pub size: Option<u32>,
pub m_timestamp: Option<u32>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct V1JobFileRefs {
pub icon: String,
pub thumbnail: String,
pub download: String,
}