firebase_rs_sdk/firestore/value/
map_value.rs1use std::collections::BTreeMap;
2
3use crate::firestore::value::FirestoreValue;
4
5#[derive(Clone, Debug, PartialEq)]
6pub struct MapValue {
7 fields: BTreeMap<String, FirestoreValue>,
8}
9
10impl MapValue {
11 pub fn new(fields: BTreeMap<String, FirestoreValue>) -> Self {
12 Self { fields }
13 }
14
15 pub fn fields(&self) -> &BTreeMap<String, FirestoreValue> {
16 &self.fields
17 }
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23
24 #[test]
25 fn stores_map_entries() {
26 let mut map = BTreeMap::new();
27 map.insert("foo".to_string(), FirestoreValue::from_integer(1));
28 let value = MapValue::new(map.clone());
29 assert_eq!(value.fields().get("foo"), map.get("foo"));
30 }
31}