mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-01-07 15:43:07 +00:00
16 lines
417 B
Rust
16 lines
417 B
Rust
use crate::common::EncodingBenchmark;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
pub struct BincodeFormat;
|
|
impl<T: Serialize + for<'de> Deserialize<'de>> EncodingBenchmark<T> for BincodeFormat {
|
|
fn name() -> &'static str {
|
|
"Bincode"
|
|
}
|
|
fn encode(data: &T) -> Vec<u8> {
|
|
bincode::serialize(data).unwrap()
|
|
}
|
|
fn decode(data: &[u8]) -> T {
|
|
bincode::deserialize(data).unwrap()
|
|
}
|
|
}
|