pub trait AsyncSerializer: Send + Sync {
type Error: Error + Send + Sync + 'static;
// Required methods
fn serialize<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn deserialize<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn extension(&self) -> &'static str;
// Provided methods
fn serialize_bytes<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn deserialize_bytes<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn serialize_batch<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 [T],
) -> Pin<Box<dyn Future<Output = Result<Vec<String>>> + Send + 'async_trait>>
where T: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Async serialization abstraction for non-blocking serialization operations
§Async Version
This trait provides async operations for serialization with better I/O handling.
Required Associated Types§
Required Methods§
Sourcefn serialize<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
fn serialize<'life0, 'life1, 'async_trait, T>( &'life0 self, data: &'life1 T, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
Serialize data to string
Sourcefn deserialize<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn deserialize<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deserialize data from string
Provided Methods§
Sourcefn serialize_bytes<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
fn serialize_bytes<'life0, 'life1, 'async_trait, T>( &'life0 self, data: &'life1 T, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
Serialize data to bytes
Sourcefn deserialize_bytes<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn deserialize_bytes<'life0, 'life1, 'async_trait, T>(
&'life0 self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned + Send + Sync,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deserialize data from bytes
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.