mz_proto

Trait ProtoType

Source
pub trait ProtoType<Rust>: Sized {
    // Required methods
    fn into_rust(self) -> Result<Rust, TryFromProtoError>;
    fn from_rust(rust: &Rust) -> Self;
}
Expand description

The symmetric counterpart of RustType, similar to what Into is to From.

The Rust parameter is generic, as opposed to the Proto associated type in RustType because the same Protobuf type can be used to encode many different Rust types.

Clients should only implement RustType.

Required Methods§

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<P, R> ProtoType<R> for P
where R: RustType<P>,

Blanket implementation for ProtoType, so clients only need to implement RustType.