mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 08:31:14 +00:00
Introduce storage types, to builds abstraction on storage (to be used in pallet attribute macro) (#7278)
* introduce storage types * fix line width * improve doc * typo * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * remove redundant function * some more doc improvment * disallow: some value on empty with option query tests are update to still test default value is used when it is supposed to be used. Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7fcf0ff610
commit
ff6b603d69
@@ -1724,6 +1724,24 @@ pub trait Instance: 'static {
|
||||
const PREFIX: &'static str;
|
||||
}
|
||||
|
||||
/// An instance of a storage.
|
||||
///
|
||||
/// It is required the the couple `(PalletInfo::name<Pallet>(), STORAGE_PREFIX)` is unique.
|
||||
/// Any storage with same couple will collide.
|
||||
pub trait StorageInstance {
|
||||
type Pallet: 'static;
|
||||
type PalletInfo: PalletInfo;
|
||||
const STORAGE_PREFIX: &'static str;
|
||||
}
|
||||
|
||||
/// Implement Get by returning Default for any type that implements Default.
|
||||
pub struct GetDefault;
|
||||
impl<T: Default> crate::traits::Get<T> for GetDefault {
|
||||
fn get() -> T {
|
||||
T::default()
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait similar to `Convert` to convert values from `B` an abstract balance type
|
||||
/// into u64 and back from u128. (This conversion is used in election and other places where complex
|
||||
/// calculation over balance type is needed)
|
||||
|
||||
Reference in New Issue
Block a user