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