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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//! Protobuf well-known types for buffa.
//!
//! This crate provides Rust types for Google's well-known `.proto` types:
//!
//! - [`google::protobuf::Timestamp`] — Unix timestamp with nanosecond precision
//! - [`google::protobuf::Duration`] — Signed duration with nanosecond precision
//! - [`google::protobuf::Any`] — Any value with an attached type URL
//! - [`google::protobuf::Struct`] / [`google::protobuf::Value`] / [`google::protobuf::ListValue`]
//! — JSON-like dynamic values
//! - [`google::protobuf::FieldMask`] — Specifies a subset of fields referenced in a message
//! - [`google::protobuf::Empty`] — A generic empty message
//! - Wrapper types: [`google::protobuf::BoolValue`], [`google::protobuf::Int32Value`],
//! [`google::protobuf::Int64Value`], [`google::protobuf::UInt32Value`],
//! [`google::protobuf::UInt64Value`], [`google::protobuf::FloatValue`],
//! [`google::protobuf::DoubleValue`], [`google::protobuf::StringValue`],
//! [`google::protobuf::BytesValue`]
//!
//! # Usage
//!
//! ```rust,no_run
//! use buffa_types::google::protobuf::Timestamp;
//! use buffa::Message;
//!
//! let ts = Timestamp { seconds: 1_000_000_000, nanos: 0, ..Default::default() };
//! let bytes = ts.encode_to_vec();
//! let decoded = Timestamp::decode_from_slice(&bytes).unwrap();
//! assert_eq!(ts, decoded);
//! ```
//!
//! # Ergonomic helpers
//!
//! Common Rust type conversions are provided as trait impls:
//!
//! - `Timestamp` ↔ [`std::time::SystemTime`] (requires `std` feature)
//! - `Duration` ↔ [`std::time::Duration`] (requires `std` feature)
//! - `Timestamp` ↔ [`chrono::DateTime`] (requires `chrono` feature; any time
//! zone in, `Utc` out)
//! - `Duration` ↔ [`chrono::TimeDelta`] (requires `chrono` feature)
//! - `Timestamp` ↔ [`jiff::Timestamp`] (requires `jiff` feature)
//! - `Duration` ↔ [`jiff::SignedDuration`] (requires `jiff` feature)
//! - `Any::pack` / `Any::unpack` helpers
//! - `Value` constructors: [`Value::null`](google::protobuf::Value::null), `From<f64>`, `From<String>`, `From<bool>`, etc.
//! - Wrapper type `From`/`Into` impls
//!
//! # Cargo features
//!
//! - **`std`** (default) — standard-library integration (`SystemTime`/`Duration`
//! conversions, `std::error::Error`). Without it the crate is `no_std` + `alloc`.
//! - **`json`** — proto3 canonical JSON serde for the WKTs.
//! - **`arbitrary`** — `arbitrary::Arbitrary` derives for fuzzing.
//! - **`chrono`** — `Timestamp` ↔ `chrono::DateTime` and `Duration` ↔
//! `chrono::TimeDelta` conversions. `no_std`-compatible (`chrono` is pulled
//! with `default-features = false`).
//! - **`jiff`** — `Timestamp` ↔ `jiff::Timestamp` and `Duration` ↔
//! `jiff::SignedDuration` conversions. `no_std`-compatible (`jiff` is pulled
//! with `default-features = false` + `alloc`).
//! - **`reflect`** — runtime reflection: the WKT view types implement
//! `buffa_descriptor::reflect::ReflectMessage`, so a message that has a WKT
//! field can reflect over it. This pulls a `buffa-descriptor` dependency and
//! requires `std` (the embedded descriptor pool uses `std::sync::OnceLock`).
//! If you reach for `&view as &dyn ReflectMessage` on a WKT view and the
//! compiler says `ReflectMessage` is not implemented, enable this feature.
extern crate alloc;
// Extension modules (ergonomic helpers — hand-written, not generated).
// Well-known type Rust structs — generated once by `gen_wkt_types`, checked
// into src/generated/. These protos are Google-owned and frozen; regeneration
// is only needed when buffa-codegen's output format changes. See the
// `task gen-wkt-types` target and the `check-generated-code` CI job.
//
// The checked-in approach means consumers of buffa-types need only the
// `buffa` runtime — NOT protoc, NOT buffa-build, NOT buffa-codegen.
//
// The allow attributes suppress lints that fire on generated code:
// derivable_impls — enum Default impls are explicit rather than derived
// match_single_binding — empty messages generate a single-arm wildcard merge
// Convenience re-exports of the most commonly-used well-known types.
// Full paths (`google::protobuf::*`) remain available for disambiguation.
// Wrapper types (Int32Value, etc.) are NOT re-exported to avoid name
// collisions with similarly-named types in user code.
pub use ;
// Re-export error types from extension modules (these are hand-written types
// in private modules, so re-exporting is the only way to make them accessible).
pub use DurationError;
pub use TimestampError;
pub use DurationChronoError;
pub use DurationJiffError;
// Re-export the WKT registry function for `Any` JSON + text support.
pub use register_wkt_types;