Skip to main content

Serde

Trait Serde 

Source
pub trait Serde<T>:
    Send
    + Sync
    + 'static {
    // Required methods
    fn serialize(&self, topic: &str, value: &T) -> Bytes;
    fn deserialize(&self, topic: &str, bytes: &[u8]) -> Result<T, SerdeError>;

    // Provided method
    fn prepare(&self, _topic: &str, _role: SerdeRole) { ... }
}
Expand description

Serialize a T to bytes and back. Source nodes deserialize with it, and sink and repartition nodes serialize with it.

Required Methods§

Source

fn serialize(&self, topic: &str, value: &T) -> Bytes

Source

fn deserialize(&self, topic: &str, bytes: &[u8]) -> Result<T, SerdeError>

§Errors

Returns an error when configuration is invalid, protocol encoding fails, the broker rejects the request, or transport I/O fails.

Provided Methods§

Source

fn prepare(&self, _topic: &str, _role: SerdeRole)

Pre-register any per-topic state, such as a schema-registry subject, before processing starts. The topology calls this method once per (topic, role) at wiring time. The default is a no-op, because a stateless serde needs nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Serde<Bytes> for BytesSerde

Source§

impl Serde<String> for StringSerde

Source§

impl Serde<i64> for I64Serde

Source§

impl<K, KS> Serde<Windowed<K>> for SessionWindowedSerde<KS>
where K: Send + Sync + 'static, KS: Serde<K>,

Source§

impl<K, KS> Serde<Windowed<K>> for TimeWindowedSerde<KS>
where K: Send + Sync + 'static, KS: Serde<K>,

Source§

impl<T, S> Serde<T> for SchemaSerde<T, S>
where T: Send + Sync + 'static, S: SchemaSerializer<T> + SchemaDeserializer<T> + SchemaSubject,