trait MaybeData: Debug {
type Out;
// Required methods
fn on_base(
self,
f: impl FnOnce(ScalarRefImpl<'_>) -> Result<Value, FieldEncodeError>,
) -> Result<Self::Out, FieldEncodeError>;
fn on_struct(
self,
st: &StructType,
pb: &MessageDescriptor,
) -> Result<Self::Out, FieldEncodeError>;
fn on_list(
self,
elem: &DataType,
pb: &FieldDescriptor,
) -> Result<Self::Out, FieldEncodeError>;
fn on_map(
self,
m: &MapType,
pb: &MessageDescriptor,
) -> Result<Self::Out, FieldEncodeError>;
}
Expand description
A trait that assists code reuse between validate
and encode
.
- For
validate
, the inputs are (RisingWave type, ProtoBuf type). - For
encode
, the inputs are (RisingWave type, RisingWave data, ProtoBuf type).
Thus we impl MaybeData
for both [()
] and ScalarRefImpl
.
Required Associated Types§
Required Methods§
fn on_base( self, f: impl FnOnce(ScalarRefImpl<'_>) -> Result<Value, FieldEncodeError>, ) -> Result<Self::Out, FieldEncodeError>
fn on_struct( self, st: &StructType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>
fn on_list( self, elem: &DataType, pb: &FieldDescriptor, ) -> Result<Self::Out, FieldEncodeError>
fn on_map( self, m: &MapType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl MaybeData for ScalarRefImpl<'_>
impl MaybeData for ScalarRefImpl<'_>
Nullability is not part of type system in proto.
- Top level is always a message.
- All message fields can be omitted in proto3.
- All repeated elements must have a value.
So we handle ScalarRefImpl
rather than DatumRef
here.