proto-types 0.1.11

⚙️ Implementations for various common protobuf types.
Documentation

🧩 Implementations for common protobuf types

This crate provides implementations for several well known protobuf types, such as those from google.protobuf, google.rpc and google.type, plus some implementations for buf.validate which are used by protocheck.

You can use feature flags to selectively include the implementations that you're interested in.

🗒️ List of implementations

Each struct/enum includes the default impls from prost such as Clone, Debug and so on.

The types coming from the google packages all have [serde::Serialize] and [serde::Deserialize] implementations when the serde feature flag is activated, and they also have From/TryFrom implementations for cel::Value when the cel feature is enabled.

Each type comes with implementations listed below, plus a variety of utility methods and helpers that can be found in the documentation.

All of the structs that have fallible methods also come with their own custom error enum.

📑 google.protobuf

  • [Duration]
    • Ord, PartialOrd
    • Display
    • Add, Sub (between durations)
    • Mul, Div (with integers)
    • Conversions from [Interval] and to/from [chrono::TimeDelta]
    • Helpers for the extraction of units (seconds, minutes, etc) and formatting
    • ToTokens (optional)
  • [Timestamp]
    • Ord, PartialOrd
    • Display
    • Add, Sub (with Duration)
    • Custom formatting with chrono syntax (requires the chrono feature)
    • Conversions to/from [std::time::SystemTime] and [chrono::DateTime]
    • ToTokens (optional)
  • [FieldMask]
    • Display
  • [Empty]
  • [Any]

📚 google.type

All of these can be included with the all_common flag, or selected individually with their respective flag.

  • [TimeOfDay]
    • Constructor with validation check
    • Display
    • Ord, PartialOrd
    • Conversions to/from [chrono::NaiveTime]
  • [Date]
    • Constructor with validation check
    • Display
    • PartialOrd
    • Conversions to/from [chrono::NaiveDate]
  • [DateTime]
    • Constructor with validation check
    • Display
    • PartialOrd
    • Conversions to/from [chrono::NaiveDateTime], [chrono::DateTime] with [chrono::FixedOffset] or [chrono::Utc] (and [chrono::DateTime] with [chrono_tz::Tz] with the chrono-tz feature)
  • [TimeZone]
    • Display
  • [Interval]
    • Constructor with validation check
    • PartialOrd
    • Conversions to/from [Duration]
  • [Money]
    • Constructor with validation check
    • PartialOrd
    • Formatting helper
    • Checked operations
    • (Lossy) conversions to/from f64
  • [Color]
    • Constructor with validation check
    • Conversions to/from [palette::Srgba] (with the palette feature)
  • [Fraction]
    • Constructor with validation check (for 0 denominator case)
    • Display
    • PartialOrd
    • Checked operations
    • Conversion to f64
  • [Decimal]
    • Conversion to [rust_decimal::Decimal]
  • [LatLng]
    • Constructor with validation check
    • Display
  • [PostalAddress]
    • Validator (checks presence of region_code)
  • [PhoneNumber]
    • Constructor with validation check (prevents the kind field from being None)
    • Validator (checks presence of required kind field)
  • [Quaternion]
  • [LocalizedText]
  • [Expr]
  • [CalendarPeriod]
  • [Month]
  • [DayOfWeek]

💻 google.rpc

  • [Status] (available by default, even without the flag)

These can be enabled with the rpc flag.

  • [ErrorInfo]
  • [DebugInfo]
  • [RetryInfo]
  • [QuotaFailure]
  • [quota_failure::Violation]
  • [PreconditionFailure]
  • [precondition_failure::Violation]
  • [BadRequest]
  • [bad_request::FieldViolation]
  • [RequestInfo]
  • [ResourceInfo]
  • [Help]
  • [help::Link]
  • [LocalizedMessage]
  • [HttpRequest]
  • [HttpResponse]
  • [HttpHeader]
  • [Code]