mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-15 00:18:06 -05:00
Move the StorageEntity method types into the StorageEntity trait itself so that you don't need to implement for all types
This commit is contained in:
@@ -45,11 +45,8 @@ impl DecoderMaker for Rc<Bytecode> {
|
||||
}
|
||||
}
|
||||
|
||||
impl StorageEntity for Bytecode {
|
||||
fn to_storage_entry<'a, E, Tx: StorageBackendHandle<'a, E>>(
|
||||
&self,
|
||||
_tx: &mut Tx,
|
||||
) -> Result<storage::StorageEntry, E> {
|
||||
impl<'a, E, Tx: StorageBackendHandle<'a, E>> StorageEntity<'a, E, Tx> for Bytecode {
|
||||
fn to_storage_entry(&self, _tx: &mut Tx) -> Result<storage::StorageEntry, E> {
|
||||
Ok(storage::StorageEntry {
|
||||
ref_count: 1,
|
||||
refs: vec![],
|
||||
@@ -57,10 +54,7 @@ impl StorageEntity for Bytecode {
|
||||
})
|
||||
}
|
||||
|
||||
fn from_storage_entry<'a, E, Tx: StorageBackendHandle<'a, E>>(
|
||||
_tx: &mut Tx,
|
||||
entry: storage::StorageEntry,
|
||||
) -> Result<Self, E> {
|
||||
fn from_storage_entry(_tx: &mut Tx, entry: storage::StorageEntry) -> Result<Self, E> {
|
||||
Ok(Bytecode::new(entry.data))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,8 @@ impl Tag {
|
||||
}
|
||||
}
|
||||
|
||||
impl StorageEntity for Val {
|
||||
fn from_storage_entry<'a, E, Tx: StorageBackendHandle<'a, E>>(
|
||||
tx: &mut Tx,
|
||||
entry: StorageEntry,
|
||||
) -> Result<Self, E> {
|
||||
impl<'a, E, Tx: StorageBackendHandle<'a, E>> StorageEntity<'a, E, Tx> for Val {
|
||||
fn from_storage_entry(tx: &mut Tx, entry: StorageEntry) -> Result<Self, E> {
|
||||
let mut reader = StorageEntryReader::new(&entry);
|
||||
let res = read_from_entry(tx, &mut reader);
|
||||
assert!(reader.done());
|
||||
@@ -59,10 +56,7 @@ impl StorageEntity for Val {
|
||||
res
|
||||
}
|
||||
|
||||
fn to_storage_entry<'a, E, Tx: StorageBackendHandle<'a, E>>(
|
||||
&self,
|
||||
tx: &mut Tx,
|
||||
) -> Result<StorageEntry, E> {
|
||||
fn to_storage_entry(&self, tx: &mut Tx) -> Result<StorageEntry, E> {
|
||||
let mut entry = StorageEntry {
|
||||
ref_count: 1,
|
||||
refs: vec![],
|
||||
|
||||
Reference in New Issue
Block a user