Skip to main content

kproc_values/
lib.rs

1#![doc = include_str!("../README.MD")]
2#![warn(missing_docs)]
3
4use std::collections::HashMap;
5
6mod error;
7pub mod graph;
8
9pub use error::Error;
10
11/// Result type for kproc_values
12pub type Result<T> = std::result::Result<T, Error>;
13
14#[cfg(feature = "schemars")]
15use schemars::JsonSchema;
16
17/// Hold a number value in the graph
18#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
19#[serde(untagged)]
20#[cfg_attr(feature = "schemars", derive(JsonSchema))]
21#[allow(missing_docs)]
22pub enum Number
23{
24  UInt(u64),
25  /// Always less than zero.
26  Int(i64),
27  /// Always finite.
28  Float(f64),
29}
30
31/// Hold a value in the graph
32#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
33#[serde(untagged)]
34#[cfg_attr(feature = "schemars", derive(JsonSchema))]
35#[allow(missing_docs)]
36pub enum Value
37{
38  Null,
39  Bool(bool),
40  Number(Number),
41  String(String),
42  #[cfg(feature = "image")]
43  Image(Image),
44  Array(Vec<Value>),
45  Object(HashMap<String, Value>),
46}
47
48#[cfg(feature = "image")]
49pub(crate) mod image;
50
51#[cfg(feature = "image")]
52pub use image::Image;