1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Provides custom Serde serializers and deserializers for converting between
//! Rust types and Firestore's native data representation.
//!
//! This module is central to enabling idiomatic Rust struct usage with Firestore.
//! It handles the mapping of Rust types (like `String`, `i64`, `bool`, `Vec`, `HashMap`,
//! and custom structs) to Firestore's `Value` protobuf message, and vice-versa.
//!
//! Key components:
//! - [`FirestoreValueSerializer`](serializer::FirestoreValueSerializer): Implements `serde::Serializer`
//! to convert Rust types into [`FirestoreValue`](crate::FirestoreValue).
//! - [`FirestoreValueDeserializer`](deserializer::FirestoreValueDeserializer): Implements `serde::Deserializer`
//! to convert [`FirestoreValue`](crate::FirestoreValue) back into Rust types.
//! - Helper modules (e.g., `timestamp_serializers`, `latlng_serializers`) provide
//! `#[serde(with = "...")]` compatible functions for specific Firestore types like
//! Timestamps and GeoPoints.
//!
//! The primary public functions re-exported here are:
//! - [`firestore_document_to_serializable`]: Deserializes a Firestore document into a Rust struct.
//! - [`firestore_document_from_serializable`]: Serializes a Rust struct into a Firestore document.
//! - [`firestore_document_from_map`]: Creates a Firestore document from a map of field names to `FirestoreValue`s.
//!
//! Additionally, a generic `From<T> for FirestoreValue where T: serde::Serialize`
//! implementation is provided, allowing easy conversion of any serializable Rust type
//! into a `FirestoreValue`.
/// Provides `#[serde(with = "...")]` serializers and deserializers for Firestore Timestamps
/// (converting between `chrono::DateTime<Utc>` and `google::protobuf::Timestamp`).
pub use *;
/// Provides `#[serde(with = "...")]` serializers and deserializers for Firestore Null values,
/// particularly for handling `Option<T>` where `None` maps to a NullValue.
pub use *;
/// Provides `#[serde(with = "...")]` serializers and deserializers for Firestore GeoPoint values
/// (converting between a suitable Rust type like a struct with `latitude` and `longitude`
/// fields and `google::type::LatLng`).
pub use *;
/// Provides `#[serde(with = "...")]` serializers and deserializers for Firestore DocumentReference values
/// (converting between `String` or a custom `FirestoreReference` type and Firestore's reference format).
pub use *;
/// Provides `#[serde(with = "...")]` serializers and deserializers for Firestore Vector values.
pub use *;
use crateFirestoreValue;
use Value;
pub use firestore_document_to_serializable;
pub use firestore_document_from_map;
pub use firestore_document_from_serializable;
/// Generic conversion from any `serde::Serialize` type into a [`FirestoreValue`].
///
/// This allows for convenient creation of `FirestoreValue` instances from various Rust types
/// using `.into()`. If serialization fails (which is rare for well-behaved `Serialize`
/// implementations), it defaults to a `FirestoreValue` representing a "null" or empty value.
///
/// # Examples
/// ```rust
/// use firestore::FirestoreValue;
///
/// let fv_string: FirestoreValue = "hello".into();
/// let fv_int: FirestoreValue = 42.into();
/// let fv_bool: FirestoreValue = true.into();
///
/// // Assuming MyStruct implements serde::Serialize
/// // struct MyStruct { field: String }
/// // let my_struct = MyStruct { field: "test".to_string() };
/// // let fv_struct: FirestoreValue = my_struct.into();
/// ```