pub trait RustType<Proto>: Sized {
    fn into_proto(&self) -> Proto;
    fn from_proto(proto: Proto) -> Result<Self, TryFromProtoError>;
}
Expand description

A trait for representing a Rust type Self as a value of type Proto for the purpose of serializing this value as (part of) a Protobuf message.

To encode a value, use RustType::into_proto() (which should always be an infallible conversion).

To decode a value, use the fallible RustType::from_proto(). Since the representation type can be “bigger” than the original, decoding may fail, indicated by returning a TryFromProtoError wrapped in a Result::Err.

Convenience syntax for the above methods is available from the matching ProtoType.

Required Methods

Convert a Self into a Proto value.

Consume and convert a Proto back into a Self value.

Since Proto can be “bigger” than the original, this may fail, indicated by returning a TryFromProtoError wrapped in a Result::Err.

Implementations on Foreign Types

Blanket implementation for HashMap<K, V> where there exists T such that T implements ProtoMapEntry<K, V>.

Identity type for $t.

Identity type for $t.

Identity type for $t.

Identity type for $t.

Identity type for $t.

Identity type for $t.

Identity type for $t.

Identity type for $t.

Identity type for $t.

Blanket implementation for BTreeMap<K, V> where there exists T such that T implements ProtoMapEntry<K, V>.

Blanket implementation for BTreeSet<R> where R is a RustType.

Blanket implementation for Vec<R> where R is a RustType.

Blanket implementation for Option<R> where R is a RustType.

Blanket implementation for Box<R> where R is a RustType.

Implementors