-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aea39b4
commit 25a579c
Showing
4 changed files
with
72 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use bincode::Options; | ||
use revision::Revisioned; | ||
use std::io::{Read, Write}; | ||
|
||
use crate::SmolStr; | ||
|
||
impl Revisioned for SmolStr { | ||
#[inline] | ||
fn revision() -> u16 { | ||
1 | ||
} | ||
|
||
fn serialize_revisioned<W: Write>(&self, w: &mut W) -> Result<(), revision::Error> { | ||
bincode::options() | ||
.with_no_limit() | ||
.with_little_endian() | ||
.with_varint_encoding() | ||
.reject_trailing_bytes() | ||
.serialize_into(w, self) | ||
.map_err(|ref err| revision::Error::Serialize(format!("{:?}", err))) | ||
} | ||
|
||
fn deserialize_revisioned<R: Read>(r: &mut R) -> Result<Self, revision::Error> | ||
where | ||
Self: Sized, | ||
{ | ||
bincode::options() | ||
.with_no_limit() | ||
.with_little_endian() | ||
.with_varint_encoding() | ||
.reject_trailing_bytes() | ||
.deserialize_from(r) | ||
.map_err(|ref err| revision::Error::Deserialize(format!("{:?}", err))) | ||
} | ||
} |
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