Skip to main content

AsyncSerializer

Trait AsyncSerializer 

Source
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§

Source

type Error: Error + Send + Sync + 'static

The error type returned by serialization operations

Required Methods§

Source

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,

Serialize data to string

Source

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

Source

fn extension(&self) -> &'static str

Get file extension for this format

Provided Methods§

Source

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,

Serialize data to bytes

Source

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

Source

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,

Serialize multiple objects in batch

Source

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,

Health check for serializer

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§