Crate proto_types

Crate proto_types 

Source
Expand description

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

Β§πŸ“š google.type

Β§πŸ’» google.rpc

Β§Feature flags

  • cel β€” Enables conversions into cel::Value.
  • serde β€” Enables serde implementations.
  • protovalidate β€” Enables implementations for the buf.validate messages and enums.
  • protocheck β€” Used internally by protocheck.
  • totokens β€” Enables ToTokens implementations.
  • chrono (enabled by default) β€” Enables conversion to and from chrono types for the time-related structs.
  • chrono-tz β€” Enables timezone support for DateTime.
  • all_common β€” Enables all message types from the google.type package.
  • rpc β€” Enables all message types from the google.rpc package.
  • decimal β€” Enables support for the google.type.Decimal, with conversions to/from rust_decimal::Decimal.
  • color β€” Enables google.type.Color.
  • palette β€” Enables conversions to and from types from the palette crate for Color.
  • date β€” Enables google.type.Date.
  • datetime β€” Enables google.type.DateTime.
  • timeofday β€” Enables google.type.TimeOfDay.
  • fraction β€” Enables google.type.Fraction.
  • money β€” Enables google.type.Money.
  • interval β€” Enables google.type.Interval.
  • localized_text β€” Enables google.type.LocalizedText.
  • postal_address β€” Enables google.type.PostalAddress.
  • quaternion β€” Enables google.type.Quaternion.
  • latlng β€” Enables google.type.LatLng.
  • expr β€” Enables google.type.Expr.
  • phone_number β€” Enables google.type.PhoneNumber.

ModulesΒ§

bad_requestrpc
Nested message and enum types in BadRequest.
celcel
Implementations to allow conversion from well known types to cel::Value
colorcolor
Implementations for the google.type.Color message.
datedate
Implementations for the google.type.Date message.
date_timedatetime
Nested message and enum types in DateTime.
datetimedatetime
Implementations for the google.type.DateTime message.
decimaldecimal
Implementations for the google.type.Decimal message.
descriptor_proto
Nested message and enum types in DescriptorProto.
duration
Implementations and units for Duration structs.
enum_descriptor_proto
Nested message and enum types in EnumDescriptorProto.
field
Nested message and enum types in Field.
field_descriptor_proto
Nested message and enum types in FieldDescriptorProto.
field_options
Nested message and enum types in FieldOptions.
file_options
Nested message and enum types in FileOptions.
fractionfraction
Implementations for the google.type.Fraction message.
generated_code_info
Nested message and enum types in GeneratedCodeInfo.
helprpc
Nested message and enum types in Help.
intervalinterval
Implementations for the google.type.Interval message.
latlnglatlng
Implementations for the google.type.LatLng message.
method_options
Nested message and enum types in MethodOptions.
moneymoney
Implementations for the google.type.Money message. DISCLAIMER: all of the methods implemented for Money are just implemented for convenience, and they are provided as is, without warranties of any kind. By using this module, the user is relieving the authors of this library from any responsibility for any damage that may be caused by its usage.
phone_numberphone_number
Nested message and enum types in PhoneNumber.
precondition_failurerpc
Nested message and enum types in PreconditionFailure.
protovalidateprotovalidate
Generated rust code from buf.validate protobuf package, with some added methods and structs.
quota_failurerpc
Nested message and enum types in QuotaFailure.
source_code_info
Nested message and enum types in SourceCodeInfo.
time_of_daytimeofday
Implementations for the google.type.TimeOfDay message.
timestamp
uninterpreted_option
Nested message and enum types in UninterpretedOption.
value
Nested message and enum types in Value.

StructsΒ§

Any
Any contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message.
Api
Api is a light-weight descriptor for an API Interface.
BadRequestrpc
Describes violations in a client request. This error type focuses on the syntactic aspects of the request.
BoolValue
Wrapper message for bool.
BytesValue
Wrapper message for bytes.
Colorcolor
Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness. For example, the fields of this representation can be trivially provided to the constructor of java.awt.Color in Java; it can also be trivially provided to UIColor’s +colorWithRed:green:blue:alpha method in iOS; and, with just a little work, it can be easily formatted into a CSS rgba() string in JavaScript.
Datedate
Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following:
DateTimedatetime
Represents civil time (or occasionally physical time).
DebugInforpc
Describes additional debugging info.
Decimaldecimal
A representation of a decimal value, such as 2.5. Clients may convert values into language-native decimal formats, such as Java’s [BigDecimal][] or Python’s [decimal.Decimal][].
DescriptorProto
Describes a message type.
DoubleValue
Wrapper message for double.
Duration
A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like β€œday” or β€œmonth”. It is related to Timestamp in that the difference between two Timestamp values is a Duration and it can be added or subtracted from a Timestamp. Range is approximately +-10,000 years.
Empty
A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance:
Enum
Enum type definition.
EnumDescriptorProto
Describes an enum type.
EnumOptions
EnumValue
Enum value definition.
EnumValueDescriptorProto
Describes a value within an enum.
EnumValueOptions
ErrorInforpc
Describes the cause of the error with structured details.
Exprexpr
Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec.
ExtensionRangeOptions
Field
A single field of a message type.
FieldDescriptorProto
Describes a field within a message.
FieldMask
FieldMask represents a set of symbolic field paths, for example:
FieldOptions
FileDescriptorProto
Describes a complete .proto file.
FileDescriptorSet
The protocol compiler can output a FileDescriptorSet containing the .proto files it parses.
FileOptions
Each of the definitions above may have β€œoptions” attached. These are just annotations which may cause code to be generated slightly differently or may contain hints for code that manipulates protocol messages.
FloatValue
Wrapper message for float.
Fractionfraction
Represents a fraction in terms of a numerator divided by a denominator.
GeneratedCodeInfo
Describes the relationship between generated code and its original source file. A GeneratedCodeInfo message is associated with only one generated source file, but may contain references to different source .proto files.
Helprpc
Provides links to documentation or for performing an out of band action.
HttpHeaderrpc
Represents an HTTP header.
HttpRequestrpc
Represents an HTTP request.
HttpResponserpc
Represents an HTTP response.
Int32Value
Wrapper message for int32.
Int64Value
Wrapper message for int64.
Intervalinterval
Represents a time interval, encoded as a Timestamp start (inclusive) and a Timestamp end (exclusive).
LatLnglatlng
An object that represents a latitude/longitude pair. This is expressed as a pair of doubles to represent degrees latitude and degrees longitude. Unless specified otherwise, this must conform to the WGS84> standard. Values must be within normalized ranges.
ListValue
ListValue is a wrapper around a repeated field of values.
LocalizedMessagerpc
Provides a localized error message that is safe to return to the user which can be attached to an RPC error.
LocalizedTextlocalized_text
Localized variant of a text in a particular language.
MessageOptions
Method
Method represents a method of an API interface.
MethodDescriptorProto
Describes a method of a service.
MethodOptions
Mixin
Declares an API Interface to be included in this interface. The including interface must redeclare all the methods from the included interface, but documentation and options are inherited as follows:
Moneymoney
Represents an amount of money with its currency type.
OneofDescriptorProto
Describes a oneof.
OneofOptions
Option
A protocol buffer option, which can be attached to a message, field, enumeration, etc.
PhoneNumberphone_number
An object representing a phone number, suitable as an API wire format.
PostalAddresspostal_address
Represents a postal address, e.g. for postal delivery or payments addresses. Given a postal address, a postal service can deliver items to a premise, P.O. Box or similar. It is not intended to model geographical locations (roads, towns, mountains).
PreconditionFailurerpc
Describes what preconditions have failed.
Quaternionquaternion
A quaternion is defined as the quotient of two directed lines in a three-dimensional space or equivalently as the quotient of two Euclidean vectors (https://en.wikipedia.org/wiki/Quaternion).
QuotaFailurerpc
Describes how a quota check failed.
RequestInforpc
Contains metadata about the request that clients can attach when filing a bug or providing other forms of feedback.
ResourceInforpc
Describes the resource that is being accessed.
RetryInforpc
Describes when the clients can retry a failed request. Clients could ignore the recommendation here or retry when this information is missing from error responses.
ServiceDescriptorProto
Describes a service.
ServiceOptions
SourceCodeInfo
Encapsulates information about the original source file from which a FileDescriptorProto was generated.
SourceContext
SourceContext represents information about the source of a protobuf element, like the file in which it is defined.
Statusrpc
The Status type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by gRPC. Each Status message contains three pieces of data: error code, error message, and error details.
StringValue
Wrapper message for string.
Struct
Struct represents a structured data value, consisting of fields which map to dynamically typed values. In some languages, Struct might be supported by a native representation. For example, in scripting languages like JS a struct is represented as an object. The details of that representation are described together with the proto support for the language.
TimeOfDaytimeofday
Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are [google.type.Date][google.type.Date] and google.protobuf.Timestamp.
TimeZonedatetime
Represents a time zone from the IANA Time Zone Database.
Timestamp
A Timestamp represents a point in time independent of any time zone or local calendar, encoded as a count of seconds and fractions of seconds at nanosecond resolution. The count is relative to an epoch at UTC midnight on January 1, 1970, in the proleptic Gregorian calendar which extends the Gregorian calendar backwards to year one.
Type
A protocol buffer message type.
UInt32Value
Wrapper message for uint32.
UInt64Value
Wrapper message for uint64.
UninterpretedOption
A message representing a option the parser does not recognize. This only appears in options protos created by the compiler::Parser class. DescriptorPool resolves these when building Descriptor objects. Therefore, options protos in descriptor objects (e.g. returned by Descriptor::options(), or produced by Descriptor::CopyTo()) will never have UninterpretedOptions in them.
Value
Value represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. A producer of value is expected to set one of these variants. Absence of any variant indicates an error.

EnumsΒ§

CalendarPeriod
A CalendarPeriod represents the abstract concept of a time period that has a canonical start. Grammatically, β€œthe start of the current CalendarPeriod.” All calendar times begin at midnight UTC.
Coderpc
The canonical error codes for gRPC APIs.
DayOfWeek
Represents a day of the week.
FieldType
An enhanced enum for protobuf types, allowing you to identify well known types such as Any, Timestamp or Duration
Month
Represents a month in the Gregorian calendar.
NullValue
NullValue is a singleton enumeration to represent the null value for the Value type union.
Syntax
The syntax in which a protocol buffer element is defined.