-
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.
refactor: splitting serializable trait
- Loading branch information
1 parent
758a47a
commit 9a57bbd
Showing
10 changed files
with
26 additions
and
34 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
pub mod cast; | ||
pub mod errors; | ||
pub mod read; | ||
pub mod types; |
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 was deleted.
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
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
use crate::storage::errors::SerializationError; | ||
use crate::storage::errors::{DeserializationError, SerializationError}; | ||
use crate::storage::storage_trait::{StorageKey, StorageValue}; | ||
|
||
pub(crate) trait Serializable { | ||
/// Serializes the given value. | ||
fn serialize(&self) -> Result<StorageValue, SerializationError>; | ||
/// Returns the key used to store self in storage. | ||
fn db_key(&self) -> StorageKey; | ||
} | ||
|
||
pub(crate) trait Deserializable: Sized { | ||
/// Deserializes the given value. | ||
fn deserialize(key: &StorageKey, value: &StorageValue) -> Result<Self, SerializationError> | ||
fn deserialize(key: &StorageKey, value: &StorageValue) -> Result<Self, DeserializationError> | ||
where | ||
Self: Sized; | ||
/// Returns the key used to store self in storage. | ||
fn db_key(&self) -> StorageKey; | ||
} |