artisan 0.11.0

Api RequesT Framework U Like - 你喜欢的 Rust API 请求框架
Documentation
//! 序列化器 trait 定义
//!
//! 定义数据序列化/反序列化的抽象接口。
//!
//! # 内置实现
//!
//! - [`JsonPacker`] - JSON 序列化器(默认)

use serde_json::Value;
use std::collections::HashMap;

use crate::Result;

pub trait Packer: Send + Sync + std::fmt::Debug {
    /// 序列化数据
    ///
    /// # Errors
    ///
    /// 返回错误当序列化失败。
    fn pack(&self, data: &HashMap<String, Value>) -> Result<String>;

    /// 反序列化数据
    ///
    /// # Errors
    ///
    /// 返回错误当反序列化失败。
    fn unpack(&self, data: &str) -> Result<Value>;
}