mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 17:21:08 +00:00
Implement sessions.
This commit is contained in:
@@ -3,14 +3,14 @@ use endiansensitive::EndianSensitive;
|
||||
use runtime_support;
|
||||
|
||||
pub trait Storage {
|
||||
fn into(_key: &[u8]) -> Self where Self: Sized { unimplemented!() }
|
||||
fn into(key: &[u8]) -> Self where Self: Sized + Default { Self::try_into(key).unwrap_or_else(Default::default) }
|
||||
fn try_into(_key: &[u8]) -> Option<Self> where Self: Sized { unimplemented!() }
|
||||
fn store(&self, key: &[u8]);
|
||||
}
|
||||
|
||||
impl<T: Default + Sized + EndianSensitive> Storage for T {
|
||||
fn into(key: &[u8]) -> Self {
|
||||
fn try_into(key: &[u8]) -> Option<Self> {
|
||||
Slicable::set_as_slice(|out| runtime_support::read_storage(key, out) == out.len())
|
||||
.unwrap_or_else(Default::default)
|
||||
}
|
||||
fn store(&self, key: &[u8]) {
|
||||
self.as_slice_then(|slice| runtime_support::set_storage(key, slice));
|
||||
|
||||
Reference in New Issue
Block a user