influxdb2_structmap/lib.rs
1//! Implements the public traits that developers inherit from in order to properly utilize the
2//! derive macro's functionality in code conversion and generation.
3
4pub mod value;
5
6use std::collections::BTreeMap;
7
8// Alias for BTreeMap with String keys and generic values
9pub type GenericMap = BTreeMap<String, value::Value>;
10
11pub trait FromMap: Default {
12 /// Converts a `GenericMap` back into a structure.
13 /// __Constraints__: assumes that value types conform to the original types of the struct.
14 fn from_genericmap(map: GenericMap) -> Self;
15}
16
17pub trait ToMap: Default {
18 /// Generates a `GenericMap` where value types are all encapsulated under a sum type.
19 /// __Constraints__: currently only supports primitive types for genericized values.
20 #[allow(clippy::wrong_self_convention)]
21 fn to_genericmap(structure: Self) -> GenericMap;
22}
23