-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #686 from pod2co/borsh
Add `borsh` support
- Loading branch information
Showing
5 changed files
with
41 additions
and
2 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
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,24 @@ | ||
#[cfg(test)] | ||
mod borsh_tests { | ||
use crate::Uuid; | ||
use std::string::ToString; | ||
use borsh::{BorshDeserialize, BorshSerialize}; | ||
|
||
#[test] | ||
fn test_serialize() { | ||
let uuid_str = "f9168c5e-ceb2-4faa-b6bf-329bf39fa1e4"; | ||
let uuid = Uuid::parse_str(uuid_str).unwrap(); | ||
let uuid_bytes = uuid.as_bytes().to_vec(); | ||
let borsh_bytes = uuid.try_to_vec().unwrap(); | ||
assert_eq!(uuid_bytes, borsh_bytes); | ||
} | ||
|
||
#[test] | ||
fn test_deserialize() { | ||
let uuid_str = "f9168c5e-ceb2-4faa-b6bf-329bf39fa1e4"; | ||
let uuid = Uuid::parse_str(uuid_str).unwrap(); | ||
let uuid_bytes = uuid.as_bytes().to_vec(); | ||
let deserialized = Uuid::try_from_slice(&uuid_bytes).unwrap().to_string(); | ||
assert_eq!(uuid_str, deserialized); | ||
} | ||
} |
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