Skip to main content

feldera_types/
lib.rs

1pub mod adapter_stats;
2pub mod checkpoint;
3pub mod circuit;
4pub mod completion_token;
5pub mod config;
6pub mod config_diagnostics;
7pub mod constants;
8pub mod coordination;
9pub mod deployment;
10pub mod display_url;
11pub mod duration;
12pub mod error;
13pub mod format;
14pub mod json_strings;
15pub mod memory_pressure;
16pub mod pipeline_diff;
17pub mod postprocess;
18pub mod preprocess;
19pub mod program_schema;
20pub mod query;
21pub mod query_params;
22pub mod runtime_status;
23pub mod secret_redaction;
24pub mod secret_ref;
25pub mod secret_resolver;
26pub mod sensitive;
27pub mod serde_with_context;
28pub mod size;
29pub mod suspend;
30pub mod time_series;
31pub mod transaction;
32pub mod transport;
33pub mod variant;
34
35mod serde_via_value {
36    use serde::{
37        Deserialize, Deserializer, Serialize, Serializer,
38        de::{DeserializeOwned, Error},
39        ser::Error as _,
40    };
41
42    /// Use this as a serde deserialization function to work around
43    /// [`serde_json` issues] with nested `f64`.  It works in two steps, first
44    /// deserializing a `serde_json::Value` from `deserializer`, then
45    /// deserializing `T` from that `serde_json::Value`.
46    ///
47    /// Use this and `serialize` as serde de/serialization functions to work
48    /// around [`serde_yaml` issues] deserializing an enum variant with a
49    /// payload that is enclosed directly or indirectly within a flattened
50    /// struct.
51    ///
52    /// [`serde_json` issues]: https://github.com/serde-rs/json/issues/1157
53    /// [`serde_yaml` issues]: https://github.com/dtolnay/serde-yaml/issues/395
54    pub fn deserialize<'de, D, T>(deserializer: D) -> Result<T, D::Error>
55    where
56        D: Deserializer<'de>,
57        T: DeserializeOwned,
58    {
59        serde_json::from_value(serde_json::Value::deserialize(deserializer)?)
60            .map_err(D::Error::custom)
61    }
62
63    pub fn serialize<T, S>(value: &T, serializer: S) -> Result<S::Ok, S::Error>
64    where
65        T: Serialize,
66        S: Serializer,
67    {
68        serde_json::to_value(value)
69            .map_err(S::Error::custom)?
70            .serialize(serializer)
71    }
72}