Trait MaybeData

Source
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§

Source

fn on_base( self, f: impl FnOnce(ScalarRefImpl<'_>) -> Result<Value, FieldEncodeError>, ) -> Result<Self::Out, FieldEncodeError>

Source

fn on_struct( self, st: &StructType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Source

fn on_list( self, elem: &DataType, pb: &FieldDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Source

fn on_map( self, m: &MapType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>

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 MaybeData for ()

Source§

type Out = ()

Source§

fn on_base( self, _: impl FnOnce(ScalarRefImpl<'_>) -> Result<Value, FieldEncodeError>, ) -> Result<Self::Out, FieldEncodeError>

Source§

fn on_struct( self, st: &StructType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Source§

fn on_list( self, elem: &DataType, pb: &FieldDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Source§

fn on_map( self, elem: &MapType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Source§

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.

Source§

type Out = Value

Source§

fn on_base( self, f: impl FnOnce(ScalarRefImpl<'_>) -> Result<Value, FieldEncodeError>, ) -> Result<Self::Out, FieldEncodeError>

Source§

fn on_struct( self, st: &StructType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Source§

fn on_list( self, elem: &DataType, pb: &FieldDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Source§

fn on_map( self, m: &MapType, pb: &MessageDescriptor, ) -> Result<Self::Out, FieldEncodeError>

Implementors§