-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supply the format from the session level
- Loading branch information
Showing
17 changed files
with
301 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use manul::{ | ||
protocol::{DeserializationError, LocalError}, | ||
session::Format, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub struct Bincode; | ||
|
||
impl Format for Bincode { | ||
fn serialize<T: Serialize>(value: T) -> Result<Box<[u8]>, LocalError> { | ||
bincode::serde::encode_to_vec(value, bincode::config::standard()) | ||
.map(|vec| vec.into()) | ||
.map_err(|err| LocalError::new(err.to_string())) | ||
} | ||
|
||
fn deserialize<'de, T: Deserialize<'de>>(bytes: &'de [u8]) -> Result<T, DeserializationError> { | ||
bincode::serde::decode_borrowed_from_slice(bytes, bincode::config::standard()) | ||
.map_err(|err| DeserializationError::new(err.to_string())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
extern crate alloc; | ||
|
||
mod format; | ||
pub mod simple; | ||
|
||
#[cfg(test)] | ||
mod simple_malicious; | ||
|
||
pub use format::Bincode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.