Skip to main content

Crate proto_types

Crate proto_types 

Source
Expand description

Proto-types   Rust Crates.io Version License Sponsor

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 following features can also enable a variety of automatically derived implementations:

  • cel (TryInto cel::Value)
  • serde (Serialize, Deserialize)
  • diesel (FromSql, ToSql, FromSqlRow, QueryId, AsExpression)
    • The diesel backend must be specified in the feature (i.e. diesel-postgres, diesel-sqlite, diesel-mysql)

In addition, the types from the google packages come with the 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

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

Β§πŸ’» google.rpc

Available by default:

Enabled with the rpc flag:

Β§πŸ“œ License

This repository is licensed under the MPL-2.0 license, unless otherwise indicated. The file CREDITS.md contains the details of the external code (and relevant licenses) used in this project.

Β§Feature flags

  • chrono-wasm β€” Enables the now() methods for chrono in a wasm environment
  • std (enabled by default) β€” Enables the standard library features
  • cel β€” Enables conversions into cel::Value.
  • serde β€” Enables serde implementations.
  • protovalidate β€” Enables implementations for the buf.validate messages and enums.
  • 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.

Re-exportsΒ§

pub use rpc::*;
pub use common::*;

ModulesΒ§

celcel
Implementations to allow conversion from well known types to cel::Value
common
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.
generated_code_info
Nested message and enum types in GeneratedCodeInfo.
method_options
Nested message and enum types in MethodOptions.
num_wrappers
Struct wrappers for protobuf-specific numeric types such as sint32 or fixed64.
protovalidateprotovalidate
Generated rust code from buf.validate protobuf package, with some added methods and structs.
rpc
source_code_info
Nested message and enum types in SourceCodeInfo.
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.
BoolValue
Wrapper message for bool.
BytesValue
Wrapper message for bytes.
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.
Empty
A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs.
Enum
Enum type definition.
EnumDescriptorProto
Describes an enum type.
EnumOptions
EnumValue
Enum value definition.
EnumValueDescriptorProto
Describes a value within an enum.
EnumValueOptions
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.
FloatValue
Wrapper message for float.
GeneratedCodeInfo
Describes the relationship between generated code and its original source file.
Int32Value
Wrapper message for int32.
Int64Value
Wrapper message for int64.
ListValue
ListValue is a wrapper around a repeated field of values.
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:
OneofDescriptorProto
Describes a oneof.
OneofOptions
Option
A protocol buffer option, which can be attached to a message, field, enumeration, etc.
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.
StringValue
Wrapper message for string.
Struct
Struct represents a structured data value, consisting of fields which map to dynamically typed values.
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.
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.
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.

EnumsΒ§

FieldType
This is an enhanced enum for protobuf types, which allows precise identification for well known types such as Any, Timestamp or Duration. It is non-exhaustive because other well known types can be added in the future, but it is safe to assume that any non matching variant will be of the generic Message type.
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.