forked from wasmerio/wasmer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes made after review with Christoph plus added compression of jo…
…urnals
- Loading branch information
1 parent
69bcc61
commit d494348
Showing
69 changed files
with
1,530 additions
and
1,466 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
use std::borrow::Cow; | ||
|
||
use lz4_flex::block::{compress_prepend_size, decompress_size_prepended}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use serde::{Deserializer, Serializer}; | ||
|
||
pub fn serialize<S: Serializer>(v: &[u8], s: S) -> Result<S::Ok, S::Error> { | ||
#[allow(deprecated)] | ||
let base64 = base64::encode(v); | ||
let base64 = base64::encode(compress_prepend_size(v)); | ||
String::serialize(&base64, s) | ||
} | ||
|
||
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Cow<'static, [u8]>, D::Error> { | ||
let base64 = String::deserialize(d)?; | ||
#[allow(deprecated)] | ||
base64::decode(base64.as_bytes()) | ||
.map_err(serde::de::Error::custom) | ||
.map(|d| d.into()) | ||
base64::decode( | ||
decompress_size_prepended(base64.as_bytes()) | ||
.map_err(|err| serde::de::Error::custom(err))?, | ||
) | ||
.map_err(serde::de::Error::custom) | ||
.map(|d| d.into()) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.