mirror of https://github.com/Trivernis/bromine.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
436 B
Rust
18 lines
436 B
Rust
use crate::payload::SerializationResult;
|
|
use serde::de::DeserializeOwned;
|
|
use serde::Serialize;
|
|
use std::io::Read;
|
|
|
|
#[inline]
|
|
pub fn serialize<T: Serialize>(data: T) -> SerializationResult<Vec<u8>> {
|
|
let bytes = bincode::serialize(&data)?;
|
|
|
|
Ok(bytes)
|
|
}
|
|
|
|
#[inline]
|
|
pub fn deserialize<R: Read, T: DeserializeOwned>(reader: R) -> SerializationResult<T> {
|
|
let type_data = bincode::deserialize_from(reader)?;
|
|
Ok(type_data)
|
|
}
|