Skip to main content

Crate buffa_types

Crate buffa_types 

Source
Expand description

Protobuf well-known types for buffa.

This crate provides Rust types for Google’s well-known .proto types:

§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:

§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 JSON-mappable WKTs (Timestamp, Duration, Any, Struct/Value/ListValue, FieldMask, Empty, wrappers). Api/Type/Enum/SourceContext and the messages they contain have no serde impls; a json = true message embedding one of them does not compile.
  • arbitraryarbitrary::Arbitrary derives for fuzzing.
  • chronoTimestampchrono::DateTime and Durationchrono::TimeDelta conversions. no_std-compatible (chrono is pulled with default-features = false).
  • jiffTimestampjiff::Timestamp and Durationjiff::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.

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§

google

Enums§

DurationChronoErrorchrono
Errors that can occur when converting a protobuf Duration to a chrono::TimeDelta.
DurationError
Errors that can occur when converting a protobuf Duration to a Rust type.
DurationJiffErrorjiff
Errors that can occur when converting a protobuf Duration to a jiff::SignedDuration.
TimestampError
Errors that can occur when converting a Timestamp to a Rust time type.

Functions§

register_wkt_types
Registers all well-known types with the given TypeRegistry.