pub trait RustType<Proto>: Sized {
    // Required methods
    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§

source

fn into_proto(&self) -> Proto

Convert a Self into a Proto value.

source

fn from_proto(proto: Proto) -> Result<Self, TryFromProtoError>

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§

source§

impl RustType<ProtoDuration> for Duration

source§

impl<R, P> RustType<Vec<P, Global>> for BTreeSet<R, Global>where R: RustType<P> + Ord,

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

source§

impl RustType<f32> for f32

Identity type for $t.

source§

impl RustType<f64> for f64

Identity type for $t.

source§

impl RustType<String> for String

Identity type for $t.

source§

impl RustType<u64> for u64

Identity type for $t.

source§

impl<K, V, T> RustType<Vec<T, Global>> for BTreeMap<K, V, Global>where K: Eq + Ord, T: ProtoMapEntry<K, V>,

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

source§

impl RustType<i32> for i8

source§

impl RustType<i32> for i32

Identity type for $t.

source§

impl<R, P> RustType<Box<P, Global>> for Box<R, Global>where R: RustType<P>,

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

source§

impl RustType<u32> for u16

source§

impl RustType<ProtoU128> for Uuid

source§

impl<R1, R2, P1, P2> RustType<(P1, P2)> for (R1, R2)where R1: RustType<P1>, R2: RustType<P2>,

source§

impl RustType<ProtoSslMode> for SslMode

source§

impl RustType<u32> for char

source§

impl RustType<u64> for Option<NonZeroU64>

source§

impl RustType<Vec<u8, Global>> for Vec<u8, Global>

Identity type for $t.

source§

impl RustType<i32> for i16

source§

impl RustType<ProtoU128> for u128

source§

impl<R, P> RustType<Vec<P, Global>> for Vec<R, Global>where R: RustType<P>,

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

source§

impl RustType<u32> for u8

source§

impl RustType<u64> for NonZeroUsize

source§

impl RustType<u32> for u32

Identity type for $t.

source§

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

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

source§

impl RustType<i64> for i64

Identity type for $t.

source§

impl RustType<()> for ()

source§

impl RustType<u64> for usize

source§

impl RustType<bool> for bool

Identity type for $t.

source§

impl RustType<ProtoU64Antichain> for Antichain<Timestamp>

source§

impl RustType<ProtoCharLength> for CharLength

source§

impl RustType<ProtoNaiveDateTime> for DateTime<Utc>

source§

impl RustType<ProtoVarCharMaxLength> for VarCharMaxLength

source§

impl RustType<ProtoTimestampPrecision> for TimestampPrecision

source§

impl RustType<ProtoOptionalNumericMaxScale> for Option<NumericMaxScale>

source§

impl RustType<ProtoGlobalId> for GlobalId

source§

impl RustType<ProtoColumnType> for ColumnType

source§

impl RustType<ProtoRegex> for Regex

source§

impl RustType<ProtoAclMode> for AclMode

source§

impl RustType<ProtoNaiveTime> for NaiveTime

source§

impl RustType<ProtoInvalidRangeError> for InvalidRangeError

source§

impl RustType<ProtoAclItem> for AclItem

source§

impl RustType<ProtoRoleId> for RoleId

source§

impl RustType<ProtoRow> for Row

source§

impl RustType<ProtoTz> for Tz

Encode a Tz as string representation. This is not the most space efficient solution, but it is immune to changes in the chrono_tz (and is fully compatible with its public API).

source§

impl RustType<ProtoInterval> for Interval

source§

impl RustType<ProtoRecordField> for (ColumnName, ColumnType)

source§

impl RustType<ProtoNaiveDate> for NaiveDate

source§

impl RustType<ProtoNaiveDateTime> for CheckedTimestamp<NaiveDateTime>

source§

impl RustType<ProtoRelationDesc> for RelationDesc

source§

impl RustType<ProtoMzAclItem> for MzAclItem

source§

impl RustType<ProtoScalarType> for ScalarType

source§

impl RustType<ProtoNumericMaxScale> for NumericMaxScale

source§

impl RustType<ProtoNaiveDateTime> for CheckedTimestamp<DateTime<Utc>>

source§

impl RustType<ProtoUrl> for Url

source§

impl RustType<ProtoInvalidArrayError> for InvalidArrayError

source§

impl RustType<ProtoColumnName> for ColumnName

source§

impl RustType<ProtoTimezone> for Timezone

source§

impl RustType<ProtoDate> for Date

source§

impl RustType<ProtoParseHexError> for ParseHexError

source§

impl RustType<ProtoFixedOffset> for FixedOffset

source§

impl RustType<ProtoDateTimeUnits> for DateTimeUnits

source§

impl RustType<ProtoNaiveDateTime> for NaiveDateTime

source§

impl RustType<ProtoParseError> for ParseError

source§

impl RustType<ProtoOptionalTimestampPrecision> for Option<TimestampPrecision>

source§

impl RustType<ProtoRelationType> for RelationType

source§

impl RustType<ProtoKey> for Vec<usize, Global>

source§

impl RustType<ProtoPrimitiveBytesStats> for PrimitiveStats<Vec<u8, Global>>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<f32>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<u32>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<bool>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<u16>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<u8>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<i32>

source§

impl RustType<ProtoAtomicBytesStats> for AtomicBytesStats

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<i8>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<i64>

source§

impl RustType<ProtoBytesStats> for BytesStats

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<f64>

source§

impl RustType<ProtoStructStats> for StructStats

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<i16>

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<u64>

source§

impl RustType<ProtoDynStats> for Box<dyn DynStats, Global>

source§

impl RustType<ProtoJsonStats> for JsonStats

source§

impl RustType<ProtoPrimitiveStats> for PrimitiveStats<String>

source§

impl RustType<MzAclItem> for MzAclItem

source§

impl RustType<AclMode> for AclMode

source§

impl RustType<Timestamp> for Timestamp

source§

impl RustType<Duration> for Duration

source§

impl RustType<RoleId> for RoleId

source§

impl RustType<GlobalId> for GlobalId

source§

impl<T> RustType<TimestampAntichain> for Antichain<T>where T: RustType<Timestamp> + Clone + PartialOrder,

source§

impl RustType<EpochMillis> for u64

Implementors§