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