Skip to main content

feldera_types/
lib.rs

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