pub trait FormattedSink {
type K;
type V;
// Required method
async fn write_one(
&mut self,
k: Option<Self::K>,
v: Option<Self::V>,
) -> Result<()>;
// Provided method
async fn write_chunk<F: SinkFormatter>(
&mut self,
chunk: StreamChunk,
formatter: &F,
) -> Result<()>
where F::K: SerTo<Self::K>,
F::V: SerTo<Self::V> { ... }
}Expand description
A free-form sink that may output in multiple formats and encodings. Examples include kafka, kinesis, nats and redis.
The implementor specifies required key & value type (likely string or bytes), as well as how to
write a single pair. The provided write_chunk method would handle the interaction with a
SinkFormatter.
Currently kafka takes &mut self while kinesis takes &self. So we use &mut self in trait
but implement it for &Kinesis. This allows us to hold &mut &Kinesis and &Kinesis
simultaneously, preventing the schema clone issue propagating from kafka to kinesis.
Required Associated Types§
Required Methods§
Provided Methods§
async fn write_chunk<F: SinkFormatter>( &mut self, chunk: StreamChunk, formatter: &F, ) -> Result<()>
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.