[][src]Trait gf::support::protobuf::Protobuf

pub trait Protobuf<M: Default + Message>: Sized {
    fn from_protobuf(src: M) -> Result<Self, ProtobufError>;
fn to_protobuf(&self) -> M; fn from_protobuf_opt(src: Option<M>) -> Result<Option<Self>, ProtobufError> { ... }
fn from_protobuf_opt_req(src: Option<M>) -> Result<Self, ProtobufError> { ... }
fn from_protobuf_vec(src: Vec<M>) -> Result<Vec<Self>, ProtobufError> { ... }
fn from_protobuf_bytes(bytes: &[u8]) -> Result<Self, ProtobufError> { ... }
fn to_protobuf_bytes(&self) -> Vec<u8> { ... } }

An object that can be serialized and deserialized as a Protocol buffers message.

An object can implement this trait multiple times, for different major message versions.

Required methods

fn from_protobuf(src: M) -> Result<Self, ProtobufError>

Convert from the message type.

fn to_protobuf(&self) -> M

Convert to the message type.

Loading content...

Provided methods

fn from_protobuf_opt(src: Option<M>) -> Result<Option<Self>, ProtobufError>

Convert from an optional source.

fn from_protobuf_opt_req(src: Option<M>) -> Result<Self, ProtobufError>

Convert from a required source that is expressed as an Option.

fn from_protobuf_vec(src: Vec<M>) -> Result<Vec<Self>, ProtobufError>

Convert from a vector.

fn from_protobuf_bytes(bytes: &[u8]) -> Result<Self, ProtobufError>

Deserialize from a slice of bytes using the message type.

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

Serialize to a vector of bytes using the message type.

Loading content...

Implementors

Loading content...