pub trait ProtobufConvert: Sized {
type ProtoStruct;
// Required methods
fn to_pb(&self) -> Self::ProtoStruct;
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>;
}
Expand description
Used for establishing correspondence between a Rust struct and a type generated from Protobuf.
Required Associated Types§
Sourcetype ProtoStruct
type ProtoStruct
Type generated from the Protobuf definition.
Required Methods§
Sourcefn to_pb(&self) -> Self::ProtoStruct
fn to_pb(&self) -> Self::ProtoStruct
Performs conversion to the type generated from Protobuf.
Sourcefn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Performs conversion from the type generated from Protobuf.
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.
Implementations on Foreign Types§
Source§impl ProtobufConvert for bool
impl ProtobufConvert for bool
type ProtoStruct = bool
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for f32
impl ProtobufConvert for f32
type ProtoStruct = f32
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for f64
impl ProtobufConvert for f64
type ProtoStruct = f64
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for i16
impl ProtobufConvert for i16
type ProtoStruct = i32
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for i32
impl ProtobufConvert for i32
type ProtoStruct = i32
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for i64
impl ProtobufConvert for i64
type ProtoStruct = i64
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for u16
impl ProtobufConvert for u16
type ProtoStruct = u32
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for u32
impl ProtobufConvert for u32
type ProtoStruct = u32
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for u64
impl ProtobufConvert for u64
type ProtoStruct = u64
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for ()
impl ProtobufConvert for ()
type ProtoStruct = Empty
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(_pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for String
impl ProtobufConvert for String
type ProtoStruct = String
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for Vec<u8>
impl ProtobufConvert for Vec<u8>
Special case for protobuf bytes.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for BitVec
impl ProtobufConvert for BitVec
type ProtoStruct = BitVec
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for DateTime<Utc>
impl ProtobufConvert for DateTime<Utc>
type ProtoStruct = Timestamp
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 8]
impl ProtobufConvert for [u8; 8]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 16]
impl ProtobufConvert for [u8; 16]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 24]
impl ProtobufConvert for [u8; 24]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 32]
impl ProtobufConvert for [u8; 32]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 40]
impl ProtobufConvert for [u8; 40]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 48]
impl ProtobufConvert for [u8; 48]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 56]
impl ProtobufConvert for [u8; 56]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 64]
impl ProtobufConvert for [u8; 64]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 72]
impl ProtobufConvert for [u8; 72]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 80]
impl ProtobufConvert for [u8; 80]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 88]
impl ProtobufConvert for [u8; 88]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 96]
impl ProtobufConvert for [u8; 96]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 104]
impl ProtobufConvert for [u8; 104]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 112]
impl ProtobufConvert for [u8; 112]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 120]
impl ProtobufConvert for [u8; 120]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 128]
impl ProtobufConvert for [u8; 128]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 160]
impl ProtobufConvert for [u8; 160]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 256]
impl ProtobufConvert for [u8; 256]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 512]
impl ProtobufConvert for [u8; 512]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 1024]
impl ProtobufConvert for [u8; 1024]
Special case for fixed sized arrays.
type ProtoStruct = Vec<u8>
fn to_pb(&self) -> Self::ProtoStruct
fn from_pb(pb: Self::ProtoStruct) -> Result<Self, Error>
Source§impl ProtobufConvert for [u8; 2048]
impl ProtobufConvert for [u8; 2048]
Special case for fixed sized arrays.