-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(starknet_patricia,starknet_committer): abstract storage prefix t…
…rait
- Loading branch information
1 parent
eece190
commit 61e7128
Showing
9 changed files
with
91 additions
and
73 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
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,25 +1,20 @@ | ||
use crate::storage::errors::DeserializationError; | ||
use crate::storage::storage_trait::{StorageKey, StorageValue}; | ||
use crate::storage::storage_trait::{create_db_key, StorageKey, StoragePrefix, StorageValue}; | ||
|
||
pub trait DBObject { | ||
/// Serializes the given value. | ||
fn serialize(&self) -> StorageValue; | ||
|
||
// TODO(Aviv, 17/07/2024): Define a trait `T` for storage prefix and return `impl T` here. | ||
/// Returns the storage key prefix of the DB object. | ||
fn get_prefix(&self) -> Vec<u8>; | ||
fn get_prefix(&self) -> impl StoragePrefix; | ||
|
||
/// Returns a `StorageKey` from a prefix and a suffix. | ||
fn get_db_key(&self, suffix: &[u8]) -> StorageKey { | ||
StorageKey([self.get_prefix(), b":".to_vec(), suffix.to_vec()].concat()) | ||
create_db_key(self.get_prefix(), suffix) | ||
} | ||
} | ||
|
||
pub trait Deserializable: Sized { | ||
/// Deserializes the given value. | ||
fn deserialize(value: &StorageValue) -> Result<Self, DeserializationError>; | ||
|
||
// TODO(Aviv, 17/07/2024): Define a trait `T` for storage prefix and return `impl T` here. | ||
/// The prefix used to store in DB. | ||
fn prefix() -> Vec<u8>; | ||
} |
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