pub trait DeCollectionStream:
Send
+ Sync
+ InputBuffer {
// Required methods
fn insert(
&mut self,
data: &[u8],
metadata: &Option<Variant>,
) -> AnyResult<()>;
fn delete(
&mut self,
data: &[u8],
metadata: &Option<Variant>,
) -> AnyResult<()>;
fn update(
&mut self,
data: &[u8],
metadata: &Option<Variant>,
) -> AnyResult<()>;
fn reserve(&mut self, reservation: usize);
fn truncate(&mut self, len: usize);
fn stage(
&self,
buffers: Vec<Box<dyn InputBuffer>>,
) -> Box<dyn StagedBuffers>;
fn fork(&self) -> Box<dyn DeCollectionStream>;
}Expand description
An input handle that deserializes and buffers records.
A trait for a type that wraps a ZSetHandle or an
MapHandle and collects serialized relational data for
the associated input stream. The client passes a byte array with a
serialized data record (e.g., in JSON or CSV format) to
insert, delete, and
update methods. The record gets deserialized into the
strongly typed representation expected by the input stream.
Instances of this trait are created by calling
DeCollectionHandle::configure_deserializer.
The data format accepted by the handle is determined
by the record_format argument passed to this method.
The input handle internally buffers the deserialized records. Use the
InputBuffer supertrait to push them to the circuit or extract them for
later use.
Required Methods§
Sourcefn insert(&mut self, data: &[u8], metadata: &Option<Variant>) -> AnyResult<()>
fn insert(&mut self, data: &[u8], metadata: &Option<Variant>) -> AnyResult<()>
Buffer a new insert update.
metadata contains optional metadata attached by the transport adapter or parser,
such as Kafka headers, topic name, etc. This metadata is passed as an aux argument to
DeserializeWithContext::deserialize_with_context_aux.
Returns an error if deserialization fails, i.e., the serialized representation is corrupted or does not match the value type of the underlying input stream.
Sourcefn delete(&mut self, data: &[u8], metadata: &Option<Variant>) -> AnyResult<()>
fn delete(&mut self, data: &[u8], metadata: &Option<Variant>) -> AnyResult<()>
Buffer a new delete update.
The data argument contains a serialized record whose
type depends on the underlying input stream: streams created by
RootCircuit::add_input_zset
and RootCircuit::add_input_set
methods support deletion by value, hence the serialized record must
match the value type of the stream. Streams created with
RootCircuit::add_input_map
support deletion by key, so the serialized record must match the key
type of the stream.
The record gets deserialized and pushed to the underlying input stream handle as a delete update.
metadata contains optional metadata attached by the transport adapter or parser,
such as Kafka headers, topic name, etc. This metadata is passed as an aux argument to
DeserializeWithContext::deserialize_with_context_aux.
Returns an error if deserialization fails, i.e., the serialized representation is corrupted or does not match the value or key type of the underlying input stream.
Sourcefn update(&mut self, data: &[u8], metadata: &Option<Variant>) -> AnyResult<()>
fn update(&mut self, data: &[u8], metadata: &Option<Variant>) -> AnyResult<()>
Buffer a new update that will modify an existing record.
metadata contains optional metadata attached by the transport adapter or parser,
such as Kafka headers, topic name, etc. This metadata is passed as an aux argument to
DeserializeWithContext::deserialize_with_context_aux.
This method can only be called on streams created with
RootCircuit::add_input_map
and will fail on other streams. The serialized record must match
the update type of this stream, specified as a type argument to
Catalog::register_input_map.
Sourcefn reserve(&mut self, reservation: usize)
fn reserve(&mut self, reservation: usize)
Reserve space for at least reservation more updates in the
internal input buffer.
Reservations are not required but can be used when the number of inputs is known ahead of time to reduce reallocations.
Sourcefn stage(&self, buffers: Vec<Box<dyn InputBuffer>>) -> Box<dyn StagedBuffers>
fn stage(&self, buffers: Vec<Box<dyn InputBuffer>>) -> Box<dyn StagedBuffers>
Stages all of the buffers, which must have been obtained from a
Parser for this stream, into a StagedBuffers that may later be used
to push the collected data into the circuit. See StagedBuffers for
more information.
Sourcefn fork(&self) -> Box<dyn DeCollectionStream>
fn fork(&self) -> Box<dyn DeCollectionStream>
Create a new deserializer with the same configuration connected to the same input stream. The new deserializer has an independent buffer that is initially empty.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".