DomainType

Trait DomainType 

Source
pub trait DomainType
where Self: Clone + Sized + TryFrom<Self::Proto>, Self::Proto: Message + Name + Default + From<Self> + Send + Sync + 'static, <Self as TryFrom<Self::Proto>>::Error: Into<Error> + Send + Sync + 'static,
{ type Proto; // Provided methods fn encode_to_vec(&self) -> Vec<u8> { ... } fn to_proto(&self) -> Self::Proto { ... } fn decode<B: Buf>(buf: B) -> Result<Self, Error> { ... } }
Expand description

A marker type that captures the relationships between a domain type (Self) and a protobuf type (Self::Proto).

Required Associated Types§

Provided Methods§

Source

fn encode_to_vec(&self) -> Vec<u8>

Encode this domain type to a byte vector, via proto type P.

Source

fn to_proto(&self) -> Self::Proto

Convert this domain type to the associated proto type.

This uses the From impl internally, so it works exactly like .into(), but does not require type inference.

Source

fn decode<B: Buf>(buf: B) -> Result<Self, Error>

Decode this domain type from a byte buffer, via proto type P.

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§