Expand description
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 precisiongoogle::protobuf::Duration— Signed duration with nanosecond precisiongoogle::protobuf::Any— Any value with an attached type URLgoogle::protobuf::Struct/google::protobuf::Value/google::protobuf::ListValue— JSON-like dynamic valuesgoogle::protobuf::FieldMask— Specifies a subset of fields referenced in a messagegoogle::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
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(requiresstdfeature)Duration↔std::time::Duration(requiresstdfeature)Timestamp↔chrono::DateTime(requireschronofeature; any time zone in,Utcout)Duration↔chrono::TimeDelta(requireschronofeature)Any::pack/Any::unpackhelpersValueconstructors:Value::null,From<f64>,From<String>,From<bool>, etc.- Wrapper type
From/Intoimpls
§Cargo features
std(default) — standard-library integration (SystemTime/Durationconversions,std::error::Error). Without it the crate isno_std+alloc.json— proto3 canonical JSON serde for the WKTs.arbitrary—arbitrary::Arbitraryderives for fuzzing.chrono—Timestamp↔chrono::DateTimeandDuration↔chrono::TimeDeltaconversions.no_std-compatible (chronois pulled withdefault-features = false).reflect— runtime reflection: the WKT view types implementbuffa_descriptor::reflect::ReflectMessage, so a message that has a WKT field can reflect over it. This pulls abuffa-descriptordependency and requiresstd(the embedded descriptor pool usesstd::sync::OnceLock). If you reach for&view as &dyn ReflectMessageon a WKT view and the compiler saysReflectMessageis not implemented, enable this feature.
Re-exports§
pub use google::protobuf::Any;pub use google::protobuf::Duration;pub use google::protobuf::Empty;pub use google::protobuf::FieldMask;pub use google::protobuf::ListValue;pub use google::protobuf::NullValue;pub use google::protobuf::Struct;pub use google::protobuf::Timestamp;pub use google::protobuf::Value;
Modules§
Enums§
- Duration
Chrono Error chrono - Errors that can occur when converting a protobuf
Durationto achrono::TimeDelta. - Duration
Error - Errors that can occur when converting a protobuf
Durationto a Rust type. - Timestamp
Error - Errors that can occur when converting a
Timestampto a Rust time type.
Functions§
- register_
wkt_ types - Registers all well-known types with the given
TypeRegistry.