[][src]Crate exonum_proto

Protobuf generated structs and traits for conversion.

The central part of this module is ProtobufConvert. The main purpose of this trait is to allow users to create a map between their types and the types generated from .proto descriptions, while providing a mechanism for additional validation of protobuf data.

Most of the time you do not have to implement this trait because most of the use cases are covered by #[derive(ProtobufConvert)] from exonum_derive crate.

A typical example of such mapping with validation is manual implementation of this trait for crypto::Hash. crypto::Hash is a fixed sized array of bytes but protobuf does not allow us to express this constraint since only dynamically sized arrays are supported. If you would like to use Hash as a part of your protobuf struct, you would have to write a conversion function from protobuf proto::Hash(which is dynamically sized array of bytes) tocrypto::Hash and call it every time when you want to use crypto::Hash in your application.

The provided ProtobufConvert implementation for Hash allows you to embed this field into your struct and generate ProtobufConvert for it using #[derive(ProtobufConvert)], which will validate your struct based on the validation function for Hash.



Module of the rust-protobuf generated files.



Implement BinaryValue trait for type that implements Protobuf::Message.



Used for establishing correspondence between rust struct and protobuf rust struct

Derive Macros


ProtobufConvert derive macro.