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§
fn serialize(&self, topic: &str, value: &T) -> Bytes
Sourcefn deserialize(&self, topic: &str, bytes: &[u8]) -> Result<T, SerdeError>
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§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".