roboplc_rpc/dataformat/
mod.rs1use core::fmt;
2
3use serde::{Deserialize, Serialize};
4
5mod json;
6pub use json::Packer as Json;
7#[cfg(feature = "msgpack")]
8mod msgpack;
9#[cfg(feature = "msgpack")]
10pub use msgpack::Packer as Msgpack;
11
12pub trait DataFormat {
14 type PackError: fmt::Display;
16 type UnpackError: fmt::Display;
18
19 fn pack<D: Serialize>(data: &D) -> Result<Vec<u8>, Self::PackError>;
21 fn unpack<'de, T: Deserialize<'de>>(payload: &'de [u8]) -> Result<T, Self::UnpackError>;
23}