Advertisement
Guest User

cargo expand

a guest
May 31st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 106.47 KB | None | 0 0
  1. #![feature(prelude_import)]
  2. #![no_std]
  3. //! Support code for the runtime.
  4. #[prelude_import]
  5. use std::prelude::v1::*;
  6. #[macro_use]
  7. extern crate std as std;
  8. #[macro_use]
  9. extern crate bitmask;
  10. pub use self::storage::hashed::generator::{
  11.     Blake2_128, Blake2_256, HashedStorage, Twox128, Twox256, Twox64Concat,
  12. };
  13. pub use self::storage::unhashed::generator::UnhashedStorage;
  14. #[doc(hidden)]
  15. pub use codec;
  16. #[cfg(feature = "std")]
  17. #[doc(hidden)]
  18. pub use once_cell;
  19. #[doc(hidden)]
  20. pub use paste;
  21. #[cfg(feature = "std")]
  22. pub use serde;
  23. pub use sr_primitives as runtime_primitives;
  24. #[doc(hidden)]
  25. pub use sr_std as rstd;
  26. #[macro_use]
  27. pub mod dispatch {
  28.     //! Dispatch system. Contains a macro for defining runtime modules and
  29.     //! generating values representing lazy module function calls.
  30.     pub use crate::codec::{Codec, Decode, Encode, EncodeAsRef, HasCompact, Input, Output};
  31.     pub use crate::rstd::prelude::{Clone, Eq, PartialEq, Vec};
  32.     pub use crate::rstd::result;
  33.     pub use srml_metadata::{
  34.         DecodeDifferent, DecodeDifferentArray, FunctionArgumentMetadata, FunctionMetadata,
  35.     };
  36.     #[cfg(feature = "std")]
  37.     pub use std::fmt;
  38.     /// A type that cannot be instantiated.
  39.     pub enum Never {}
  40.     /// Result of a module function call; either nothing (functions are only called for "side effects")
  41.     /// or an error message.
  42.     pub type Result = result::Result<(), &'static str>;
  43.    /// A lazy call (module function and argument values) that can be executed via its `dispatch`
  44.    /// method.
  45.    pub trait Dispatchable {
  46.        /// Every function call from your runtime has an origin, which specifies where the extrinsic was
  47.        /// generated from. In the case of a signed extrinsic (transaction), the origin contains an
  48.        /// identifier for the caller. The origin can be empty in the case of an inherent extrinsic.
  49.        type Origin;
  50.        type Trait;
  51.        fn dispatch(self, origin: Self::Origin) -> Result;
  52.    }
  53.    /// Serializable version of Dispatchable.
  54.    /// This value can be used as a "function" in an extrinsic.
  55.    pub trait Callable {
  56.        type Call: Dispatchable + Codec + Clone + PartialEq + Eq;
  57.    }
  58.    pub type CallableCallFor<A> = <A as Callable>::Call;
  59.    #[cfg(feature = "std")]
  60.    pub trait Parameter: Codec + Clone + Eq + fmt::Debug {}
  61.    #[cfg(feature = "std")]
  62.    impl<T> Parameter for T where T: Codec + Clone + Eq + fmt::Debug {}
  63.    pub trait IsSubType<T: Callable> {
  64.        fn is_aux_sub_type(&self) -> Option<&<T as Callable>::Call>;
  65.    }
  66. }
  67. #[macro_use]
  68. pub mod storage {
  69.    //! Stuff to do with the runtime's storage.
  70.     use crate::rstd::borrow::Borrow;
  71.     use crate::rstd::prelude::*;
  72.     use codec::{Codec, Decode, Encode, EncodeAppend, Input, KeyedVec};
  73.     use hashed::generator::{HashedStorage, StorageHasher};
  74.     use unhashed::generator::UnhashedStorage;
  75.     #[macro_use]
  76.     pub mod storage_items {
  77.         //! Strongly typed wrappers around values in storage.
  78.         //!
  79.         //! This crate exports a macro `storage_items!` and traits describing behavior of generated
  80.         //! structs.
  81.         //!
  82.         //! Three kinds of data types are currently supported:
  83.         //!   - values
  84.         //!   - maps
  85.         //!
  86.         //! # Examples:
  87.         //!
  88.         //! ```rust
  89.         //! #[macro_use]
  90.         //! extern crate srml_support;
  91.         //!
  92.         //! type AuthorityId = [u8; 32];
  93.         //! type Balance = u64;
  94.         //! pub type SessionKey = [u8; 32];
  95.         //!
  96.         //! storage_items! {
  97.         //!     // public value
  98.         //!     pub Value: b"putd_key" => SessionKey;
  99.         //!     // private map.
  100.         //!     Balances: b"private_map:" => map [AuthorityId => Balance];
  101.         //! }
  102.         //!
  103.         //!# fn main() { }
  104.         //! ```
  105.         #[doc(hidden)]
  106.         pub use crate::rstd::borrow::Borrow;
  107.         #[doc(hidden)]
  108.         pub use crate::rstd::boxed::Box;
  109.         #[doc(hidden)]
  110.         pub use crate::rstd::marker::PhantomData;
  111.     }
  112.     pub mod unhashed {
  113.         //! Operation on unhashed runtime storage
  114.         use super::{Codec, Decode, Encode, IncrementalInput, KeyedVec, Vec};
  115.         use crate::rstd::borrow::Borrow;
  116.         pub mod generator {
  117.             use crate::codec;
  118.             use crate::rstd::vec::Vec;
  119.             /// Abstraction around storage with unhashed access.
  120.             pub trait UnhashedStorage {
  121.                 /// true if the key exists in storage.
  122.                 fn exists(&self, key: &[u8]) -> bool;
  123.                 /// Load the bytes of a key from storage. Can panic if the type is incorrect.
  124.                 fn get<T: codec::Decode>(&self, key: &[u8]) -> Option<T>;
  125.                 /// Load the bytes of a key from storage. Can panic if the type is incorrect. Will panic if
  126.                 /// it's not there.
  127.                 fn require<T: codec::Decode>(&self, key: &[u8]) -> T {
  128.                     self.get(key).expect("Required values must be in storage")
  129.                 }
  130.                 /// Load the bytes of a key from storage. Can panic if the type is incorrect. The type's
  131.                 /// default is returned if it's not there.
  132.                 fn get_or_default<T: codec::Decode + Default>(&self, key: &[u8]) -> T {
  133.                     self.get(key).unwrap_or_default()
  134.                 }
  135.                 /// Put a value in under a key.
  136.                 fn put<T: codec::Encode>(&mut self, key: &[u8], val: &T);
  137.                 /// Remove the bytes of a key from storage.
  138.                 fn kill(&mut self, key: &[u8]);
  139.                 /// Remove the bytes of a key from storage.
  140.                 fn kill_prefix(&mut self, prefix: &[u8]);
  141.                 /// Take a value from storage, deleting it after reading.
  142.                 fn take<T: codec::Decode>(&mut self, key: &[u8]) -> Option<T> {
  143.                     let value = self.get(key);
  144.                     self.kill(key);
  145.                     value
  146.                 }
  147.                 /// Take a value from storage, deleting it after reading.
  148.                 fn take_or_panic<T: codec::Decode>(&mut self, key: &[u8]) -> T {
  149.                     self.take(key).expect("Required values must be in storage")
  150.                 }
  151.                 /// Take a value from storage, deleting it after reading.
  152.                 fn take_or_default<T: codec::Decode + Default>(&mut self, key: &[u8]) -> T {
  153.                     self.take(key).unwrap_or_default()
  154.                 }
  155.                 /// Get a Vec of bytes from storage.
  156.                 fn get_raw(&self, key: &[u8]) -> Option<Vec<u8>>;
  157.                 /// Put a raw byte slice into storage.
  158.                 fn put_raw(&mut self, key: &[u8], value: &[u8]);
  159.             }
  160.             #[cfg(feature = "std")]
  161.             impl UnhashedStorage for sr_primitives::StorageOverlay {
  162.                 fn exists(&self, key: &[u8]) -> bool {
  163.                     self.contains_key(key)
  164.                 }
  165.                 fn get<T: codec::Decode>(&self, key: &[u8]) -> Option<T> {
  166.                     self.get(key).map(|x| {
  167.                         codec::Decode::decode(&mut x.as_slice())
  168.                             .expect("Unable to decode expected type.")
  169.                     })
  170.                 }
  171.                 fn put<T: codec::Encode>(&mut self, key: &[u8], val: &T) {
  172.                     self.insert(key.to_vec(), codec::Encode::encode(val));
  173.                 }
  174.                 fn kill(&mut self, key: &[u8]) {
  175.                     self.remove(key);
  176.                 }
  177.                 fn kill_prefix(&mut self, prefix: &[u8]) {
  178.                     self.retain(|key, _| !key.starts_with(prefix))
  179.                 }
  180.                 fn get_raw(&self, key: &[u8]) -> Option<Vec<u8>> {
  181.                     self.get(key).cloned()
  182.                 }
  183.                 fn put_raw(&mut self, key: &[u8], value: &[u8]) {
  184.                     self.insert(key.to_vec(), value.to_vec());
  185.                 }
  186.             }
  187.             /// An implementation of a map with a two keys.
  188.             ///
  189.             /// It provides an important ability to efficiently remove all entries
  190.             /// that have a common first key.
  191.             ///
  192.             /// # Mapping of keys to a storage path
  193.             ///
  194.             /// The storage key (i.e. the key under which the `Value` will be stored) is created from two parts.
  195.             /// The first part is a hash of a concatenation of the `PREFIX` and `Key1`. And the second part
  196.             /// is a hash of a `Key2`.
  197.             ///
  198.             /// /!\ be careful while choosing the Hash, indeed malicious could craft second keys to lower the trie.
  199.             pub trait StorageDoubleMap<K1: codec::Codec, K2: codec::Codec, V: codec::Codec> {
  200.                 /// The type that get/take returns.
  201.                 type Query;
  202.                 /// Get the prefix key in storage.
  203.                 fn prefix() -> &'static [u8];
  204.                /// Get the storage key used to fetch a value corresponding to a specific key.
  205.                fn key_for(k1: &K1, k2: &K2) -> Vec<u8>;
  206.                /// Get the storage prefix used to fetch keys corresponding to a specific key1.
  207.                fn prefix_for(k1: &K1) -> Vec<u8>;
  208.                /// true if the value is defined in storage.
  209.                fn exists<S: UnhashedStorage>(k1: &K1, k2: &K2, storage: &S) -> bool {
  210.                    storage.exists(&Self::key_for(k1, k2))
  211.                }
  212.                /// Load the value associated with the given key from the map.
  213.                fn get<S: UnhashedStorage>(k1: &K1, k2: &K2, storage: &S) -> Self::Query;
  214.                /// Take the value under a key.
  215.                fn take<S: UnhashedStorage>(k1: &K1, k2: &K2, storage: &mut S) -> Self::Query;
  216.                /// Store a value to be associated with the given key from the map.
  217.                fn insert<S: UnhashedStorage>(k1: &K1, k2: &K2, val: &V, storage: &mut S) {
  218.                    storage.put(&Self::key_for(k1, k2), val);
  219.                }
  220.                /// Remove the value under a key.
  221.                fn remove<S: UnhashedStorage>(k1: &K1, k2: &K2, storage: &mut S) {
  222.                    storage.kill(&Self::key_for(k1, k2));
  223.                }
  224.                /// Removes all entries that shares the `k1` as the first key.
  225.                fn remove_prefix<S: UnhashedStorage>(k1: &K1, storage: &mut S) {
  226.                    storage.kill_prefix(&Self::prefix_for(k1));
  227.                }
  228.                /// Mutate the value under a key.
  229.                fn mutate<R, F: FnOnce(&mut Self::Query) -> R, S: UnhashedStorage>(
  230.                    k1: &K1,
  231.                    k2: &K2,
  232.                    f: F,
  233.                    storage: &mut S,
  234.                ) -> R;
  235.                /// Append the given items to the value under the key specified.
  236.                fn append<I, S: UnhashedStorage>(
  237.                    k1: &K1,
  238.                    k2: &K2,
  239.                    items: &[I],
  240.                    storage: &mut S,
  241.                ) -> Result<(), &'static str>
  242.                 where
  243.                     I: codec::Encode,
  244.                     V: codec::EncodeAppend<Item = I>,
  245.                 {
  246.                     let key = Self::key_for(k1, k2);
  247.                     let new_val = <V as codec::EncodeAppend>::append(
  248.                         storage.get_raw(&key).unwrap_or_default(),
  249.                         items,
  250.                     )
  251.                     .ok_or_else(|| "Could not append given item")?;
  252.                     storage.put_raw(&key, &new_val);
  253.                     Ok(())
  254.                 }
  255.             }
  256.         }
  257.         /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
  258.         pub fn get<T: Decode + Sized>(key: &[u8]) -> Option<T> {
  259.             runtime_io::read_storage(key, &mut [0; 0][..], 0).map(|_| {
  260.                 let mut input = IncrementalInput { key, pos: 0 };
  261.                 Decode::decode(&mut input)
  262.                     .expect("storage is not null, therefore must be a valid type")
  263.             })
  264.         }
  265.         /// Return the value of the item in storage under `key`, or the type's default if there is no
  266.         /// explicit entry.
  267.         pub fn get_or_default<T: Decode + Sized + Default>(key: &[u8]) -> T {
  268.             get(key).unwrap_or_else(Default::default)
  269.         }
  270.         /// Return the value of the item in storage under `key`, or `default_value` if there is no
  271.         /// explicit entry.
  272.         pub fn get_or<T: Decode + Sized>(key: &[u8], default_value: T) -> T {
  273.             get(key).unwrap_or(default_value)
  274.         }
  275.         /// Return the value of the item in storage under `key`, or `default_value()` if there is no
  276.         /// explicit entry.
  277.         pub fn get_or_else<T: Decode + Sized, F: FnOnce() -> T>(key: &[u8], default_value: F) -> T {
  278.             get(key).unwrap_or_else(default_value)
  279.         }
  280.         /// Put `value` in storage under `key`.
  281.         pub fn put<T: Encode>(key: &[u8], value: &T) {
  282.             value.using_encoded(|slice| runtime_io::set_storage(key, slice));
  283.         }
  284.         /// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise.
  285.         pub fn take<T: Decode + Sized>(key: &[u8]) -> Option<T> {
  286.             let r = get(key);
  287.             if r.is_some() {
  288.                 kill(key);
  289.             }
  290.             r
  291.         }
  292.         /// Remove `key` from storage, returning its value, or, if there was no explicit entry in storage,
  293.         /// the default for its type.
  294.         pub fn take_or_default<T: Decode + Sized + Default>(key: &[u8]) -> T {
  295.             take(key).unwrap_or_else(Default::default)
  296.         }
  297.         /// Return the value of the item in storage under `key`, or `default_value` if there is no
  298.         /// explicit entry. Ensure there is no explicit entry on return.
  299.         pub fn take_or<T: Decode + Sized>(key: &[u8], default_value: T) -> T {
  300.             take(key).unwrap_or(default_value)
  301.         }
  302.         /// Return the value of the item in storage under `key`, or `default_value()` if there is no
  303.         /// explicit entry. Ensure there is no explicit entry on return.
  304.         pub fn take_or_else<T: Decode + Sized, F: FnOnce() -> T>(
  305.             key: &[u8],
  306.             default_value: F,
  307.         ) -> T {
  308.             take(key).unwrap_or_else(default_value)
  309.         }
  310.         /// Check to see if `key` has an explicit entry in storage.
  311.         pub fn exists(key: &[u8]) -> bool {
  312.             runtime_io::read_storage(key, &mut [0; 0][..], 0).is_some()
  313.         }
  314.         /// Ensure `key` has no explicit entry in storage.
  315.         pub fn kill(key: &[u8]) {
  316.             runtime_io::clear_storage(key);
  317.         }
  318.         /// Ensure keys with the given `prefix` have no entries in storage.
  319.         pub fn kill_prefix(prefix: &[u8]) {
  320.             runtime_io::clear_prefix(prefix);
  321.         }
  322.         /// Get a Vec of bytes from storage.
  323.         pub fn get_raw(key: &[u8]) -> Option<Vec<u8>> {
  324.             runtime_io::storage(key)
  325.         }
  326.         /// Put a raw byte slice into storage.
  327.         pub fn put_raw(key: &[u8], value: &[u8]) {
  328.             runtime_io::set_storage(key, value)
  329.         }
  330.         /// A trait to conveniently store a vector of storable data.
  331.         pub trait StorageVec {
  332.             type Item: Default + Sized + Codec;
  333.             const PREFIX: &'static [u8];
  334.            /// Get the current set of items.
  335.            fn items() -> Vec<Self::Item> {
  336.                (0..Self::count()).into_iter().map(Self::item).collect()
  337.            }
  338.            /// Set the current set of items.
  339.            fn set_items<I, T>(items: I)
  340.            where
  341.                I: IntoIterator<Item = T>,
  342.                T: Borrow<Self::Item>,
  343.            {
  344.                let mut count: u32 = 0;
  345.                for i in items.into_iter() {
  346.                    put(&count.to_keyed_vec(Self::PREFIX), i.borrow());
  347.                    count = count
  348.                        .checked_add(1)
  349.                        .expect("exceeded runtime storage capacity");
  350.                }
  351.                Self::set_count(count);
  352.            }
  353.            fn set_item(index: u32, item: &Self::Item) {
  354.                if index < Self::count() {
  355.                    put(&index.to_keyed_vec(Self::PREFIX), item);
  356.                }
  357.            }
  358.            fn clear_item(index: u32) {
  359.                if index < Self::count() {
  360.                    kill(&index.to_keyed_vec(Self::PREFIX));
  361.                }
  362.            }
  363.            fn item(index: u32) -> Self::Item {
  364.                get_or_default(&index.to_keyed_vec(Self::PREFIX))
  365.            }
  366.            fn set_count(count: u32) {
  367.                (count..Self::count()).for_each(Self::clear_item);
  368.                put(&b"len".to_keyed_vec(Self::PREFIX), &count);
  369.            }
  370.            fn count() -> u32 {
  371.                get_or_default(&b"len".to_keyed_vec(Self::PREFIX))
  372.            }
  373.        }
  374.    }
  375.    pub mod hashed {
  376.        //! Operation on runtime storage using hashed keys.
  377.        pub mod generator {
  378.            //! Abstract storage to use on HashedStorage trait
  379.            use crate::codec;
  380.            use crate::rstd::prelude::{Box, Vec};
  381.            #[cfg(feature = "std")]
  382.            use crate::storage::unhashed::generator::UnhashedStorage;
  383.            use runtime_io::{blake2_128, blake2_256, twox_128, twox_256, twox_64};
  384.            pub trait StorageHasher: 'static {
  385.                 type Output: AsRef<[u8]>;
  386.                 fn hash(x: &[u8]) -> Self::Output;
  387.             }
  388.             /// Hash storage keys with `concat(twox128(key), key)`
  389.             pub struct Twox64Concat;
  390.             impl StorageHasher for Twox64Concat {
  391.                 type Output = Vec<u8>;
  392.                 fn hash(x: &[u8]) -> Vec<u8> {
  393.                     twox_64(x)
  394.                         .into_iter()
  395.                         .chain(x.into_iter())
  396.                         .cloned()
  397.                         .collect::<Vec<_>>()
  398.                 }
  399.             }
  400.             /// Hash storage keys with blake2 128
  401.             pub struct Blake2_128;
  402.             impl StorageHasher for Blake2_128 {
  403.                 type Output = [u8; 16];
  404.                 fn hash(x: &[u8]) -> [u8; 16] {
  405.                     blake2_128(x)
  406.                 }
  407.             }
  408.             /// Hash storage keys with blake2 256
  409.             pub struct Blake2_256;
  410.             impl StorageHasher for Blake2_256 {
  411.                 type Output = [u8; 32];
  412.                 fn hash(x: &[u8]) -> [u8; 32] {
  413.                     blake2_256(x)
  414.                 }
  415.             }
  416.             /// Hash storage keys with twox 128
  417.             pub struct Twox128;
  418.             impl StorageHasher for Twox128 {
  419.                 type Output = [u8; 16];
  420.                 fn hash(x: &[u8]) -> [u8; 16] {
  421.                     twox_128(x)
  422.                 }
  423.             }
  424.             /// Hash storage keys with twox 256
  425.             pub struct Twox256;
  426.             impl StorageHasher for Twox256 {
  427.                 type Output = [u8; 32];
  428.                 fn hash(x: &[u8]) -> [u8; 32] {
  429.                     twox_256(x)
  430.                 }
  431.             }
  432.             /// Abstraction around storage.
  433.             pub trait HashedStorage<H: StorageHasher> {
  434.                 /// true if the key exists in storage.
  435.                 fn exists(&self, key: &[u8]) -> bool;
  436.                 /// Load the bytes of a key from storage. Can panic if the type is incorrect.
  437.                 fn get<T: codec::Decode>(&self, key: &[u8]) -> Option<T>;
  438.                 /// Load the bytes of a key from storage. Can panic if the type is incorrect. Will panic if
  439.                 /// it's not there.
  440.                 fn require<T: codec::Decode>(&self, key: &[u8]) -> T {
  441.                     self.get(key).expect("Required values must be in storage")
  442.                 }
  443.                 /// Load the bytes of a key from storage. Can panic if the type is incorrect. The type's
  444.                 /// default is returned if it's not there.
  445.                 fn get_or_default<T: codec::Decode + Default>(&self, key: &[u8]) -> T {
  446.                     self.get(key).unwrap_or_default()
  447.                 }
  448.                 /// Put a value in under a key.
  449.                 fn put<T: codec::Encode>(&mut self, key: &[u8], val: &T);
  450.                 /// Remove the bytes of a key from storage.
  451.                 fn kill(&mut self, key: &[u8]);
  452.                 /// Take a value from storage, deleting it after reading.
  453.                 fn take<T: codec::Decode>(&mut self, key: &[u8]) -> Option<T> {
  454.                     let value = self.get(key);
  455.                     self.kill(key);
  456.                     value
  457.                 }
  458.                 /// Take a value from storage, deleting it after reading.
  459.                 fn take_or_panic<T: codec::Decode>(&mut self, key: &[u8]) -> T {
  460.                     self.take(key).expect("Required values must be in storage")
  461.                 }
  462.                 /// Take a value from storage, deleting it after reading.
  463.                 fn take_or_default<T: codec::Decode + Default>(&mut self, key: &[u8]) -> T {
  464.                     self.take(key).unwrap_or_default()
  465.                 }
  466.                 /// Get a Vec of bytes from storage.
  467.                 fn get_raw(&self, key: &[u8]) -> Option<Vec<u8>>;
  468.                 /// Put a raw byte slice into storage.
  469.                 fn put_raw(&mut self, key: &[u8], value: &[u8]);
  470.             }
  471.             #[cfg(feature = "std")]
  472.             impl<H: StorageHasher> HashedStorage<H> for sr_primitives::StorageOverlay {
  473.                 fn exists(&self, key: &[u8]) -> bool {
  474.                     UnhashedStorage::exists(self, &H::hash(key).as_ref())
  475.                 }
  476.                 fn get<T: codec::Decode>(&self, key: &[u8]) -> Option<T> {
  477.                     UnhashedStorage::get(self, &H::hash(key).as_ref())
  478.                 }
  479.                 fn put<T: codec::Encode>(&mut self, key: &[u8], val: &T) {
  480.                     UnhashedStorage::put(self, &H::hash(key).as_ref(), val)
  481.                 }
  482.                 fn kill(&mut self, key: &[u8]) {
  483.                     UnhashedStorage::kill(self, &H::hash(key).as_ref())
  484.                 }
  485.                 fn get_raw(&self, key: &[u8]) -> Option<Vec<u8>> {
  486.                     UnhashedStorage::get_raw(self, &H::hash(key).as_ref())
  487.                 }
  488.                 fn put_raw(&mut self, key: &[u8], value: &[u8]) {
  489.                     UnhashedStorage::put_raw(self, &H::hash(key).as_ref(), value)
  490.                 }
  491.             }
  492.             /// A strongly-typed value kept in storage.
  493.             pub trait StorageValue<T: codec::Codec> {
  494.                 /// The type that get/take returns.
  495.                 type Query;
  496.                 /// Get the storage key.
  497.                 fn key() -> &'static [u8];
  498.                /// true if the value is defined in storage.
  499.                fn exists<S: HashedStorage<Twox128>>(storage: &S) -> bool {
  500.                    storage.exists(Self::key())
  501.                }
  502.                /// Load the value from the provided storage instance.
  503.                fn get<S: HashedStorage<Twox128>>(storage: &S) -> Self::Query;
  504.                /// Take a value from storage, removing it afterwards.
  505.                fn take<S: HashedStorage<Twox128>>(storage: &mut S) -> Self::Query;
  506.                /// Store a value under this key into the provided storage instance.
  507.                fn put<S: HashedStorage<Twox128>>(val: &T, storage: &mut S) {
  508.                    storage.put(Self::key(), val)
  509.                }
  510.                /// Mutate this value
  511.                fn mutate<R, F: FnOnce(&mut Self::Query) -> R, S: HashedStorage<Twox128>>(
  512.                    f: F,
  513.                    storage: &mut S,
  514.                ) -> R;
  515.                /// Clear the storage value.
  516.                fn kill<S: HashedStorage<Twox128>>(storage: &mut S) {
  517.                    storage.kill(Self::key())
  518.                }
  519.                /// Append the given items to the value in the storage.
  520.                ///
  521.                /// `T` is required to implement `codec::EncodeAppend`.
  522.                fn append<S: HashedStorage<Twox128>, I: codec::Encode>(
  523.                    items: &[I],
  524.                    storage: &mut S,
  525.                ) -> Result<(), &'static str>
  526.                 where
  527.                     T: codec::EncodeAppend<Item = I>,
  528.                 {
  529.                     let new_val = <T as codec::EncodeAppend>::append(
  530.                         storage.get_raw(Self::key()).unwrap_or_default(),
  531.                         items,
  532.                     )
  533.                     .ok_or_else(|| "Could not append given item")?;
  534.                     storage.put_raw(Self::key(), &new_val);
  535.                     Ok(())
  536.                 }
  537.             }
  538.             /// A strongly-typed map in storage.
  539.             pub trait StorageMap<K: codec::Codec, V: codec::Codec> {
  540.                 /// The type that get/take returns.
  541.                 type Query;
  542.                 type Hasher: StorageHasher;
  543.                 /// Get the prefix key in storage.
  544.                 fn prefix() -> &'static [u8];
  545.                /// Get the storage key used to fetch a value corresponding to a specific key.
  546.                fn key_for(x: &K) -> Vec<u8>;
  547.                /// true if the value is defined in storage.
  548.                fn exists<S: HashedStorage<Self::Hasher>>(key: &K, storage: &S) -> bool {
  549.                    storage.exists(&Self::key_for(key)[..])
  550.                }
  551.                /// Load the value associated with the given key from the map.
  552.                fn get<S: HashedStorage<Self::Hasher>>(key: &K, storage: &S) -> Self::Query;
  553.                /// Take the value under a key.
  554.                fn take<S: HashedStorage<Self::Hasher>>(key: &K, storage: &mut S) -> Self::Query;
  555.                /// Store a value to be associated with the given key from the map.
  556.                fn insert<S: HashedStorage<Self::Hasher>>(key: &K, val: &V, storage: &mut S) {
  557.                    storage.put(&Self::key_for(key)[..], val);
  558.                }
  559.                /// Remove the value under a key.
  560.                fn remove<S: HashedStorage<Self::Hasher>>(key: &K, storage: &mut S) {
  561.                    storage.kill(&Self::key_for(key)[..]);
  562.                }
  563.                /// Mutate the value under a key.
  564.                fn mutate<R, F: FnOnce(&mut Self::Query) -> R, S: HashedStorage<Self::Hasher>>(
  565.                    key: &K,
  566.                    f: F,
  567.                    storage: &mut S,
  568.                ) -> R;
  569.            }
  570.            /// A `StorageMap` with enumerable entries.
  571.            pub trait EnumerableStorageMap<K: codec::Codec, V: codec::Codec>:
  572.                StorageMap<K, V>
  573.            {
  574.                /// Return current head element.
  575.                fn head<S: HashedStorage<Self::Hasher>>(storage: &S) -> Option<K>;
  576.                /// Enumerate all elements in the map.
  577.                fn enumerate<'a, S: HashedStorage<Self::Hasher>>(
  578.                     storage: &'a S,
  579.                ) -> Box<dyn Iterator<Item = (K, V)> + 'a>
  580.                 where
  581.                     K: 'a,
  582.                    V: 'a;
  583.             }
  584.             /// A `StorageMap` with appendable entries.
  585.             pub trait AppendableStorageMap<K: codec::Codec, V: codec::Codec>:
  586.                 StorageMap<K, V>
  587.             {
  588.                 /// Append the given items to the value in the storage.
  589.                 ///
  590.                 /// `T` is required to implement `codec::EncodeAppend`.
  591.                 fn append<S: HashedStorage<Self::Hasher>, I: codec::Encode>(
  592.                     key: &K,
  593.                     items: &[I],
  594.                     storage: &mut S,
  595.                 ) -> Result<(), &'static str>
  596.                where
  597.                    V: codec::EncodeAppend<Item = I>,
  598.                {
  599.                    let k = Self::key_for(key);
  600.                    let new_val = <V as codec::EncodeAppend>::append(
  601.                        storage.get_raw(&k[..]).unwrap_or_default(),
  602.                        items,
  603.                    )
  604.                    .ok_or_else(|| "Could not append given item")?;
  605.                    storage.put_raw(&k[..], &new_val);
  606.                    Ok(())
  607.                }
  608.            }
  609.        }
  610.        use super::unhashed;
  611.        use crate::codec::{Codec, Decode, Encode, KeyedVec};
  612.        use crate::rstd::borrow::Borrow;
  613.        use crate::rstd::prelude::*;
  614.        use runtime_io::{self, twox_128};
  615.        /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
  616.        pub fn get<T: Decode + Sized, HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(
  617.            hash: &HashFn,
  618.            key: &[u8],
  619.        ) -> Option<T> {
  620.            unhashed::get(&hash(key).as_ref())
  621.        }
  622.        /// Return the value of the item in storage under `key`, or the type's default if there is no
  623.         /// explicit entry.
  624.         pub fn get_or_default<
  625.             T: Decode + Sized + Default,
  626.             HashFn: Fn(&[u8]) -> R,
  627.             R: AsRef<[u8]>,
  628.         >(
  629.             hash: &HashFn,
  630.             key: &[u8],
  631.         ) -> T {
  632.             unhashed::get_or_default(&hash(key).as_ref())
  633.         }
  634.         /// Return the value of the item in storage under `key`, or `default_value` if there is no
  635.         /// explicit entry.
  636.         pub fn get_or<T: Decode + Sized, HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(
  637.             hash: &HashFn,
  638.             key: &[u8],
  639.             default_value: T,
  640.         ) -> T {
  641.             unhashed::get_or(&hash(key).as_ref(), default_value)
  642.         }
  643.         /// Return the value of the item in storage under `key`, or `default_value()` if there is no
  644.         /// explicit entry.
  645.         pub fn get_or_else<
  646.             T: Decode + Sized,
  647.             F: FnOnce() -> T,
  648.             HashFn: Fn(&[u8]) -> R,
  649.             R: AsRef<[u8]>,
  650.         >(
  651.             hash: &HashFn,
  652.             key: &[u8],
  653.             default_value: F,
  654.         ) -> T {
  655.             unhashed::get_or_else(&hash(key).as_ref(), default_value)
  656.         }
  657.         /// Put `value` in storage under `key`.
  658.         pub fn put<T: Encode, HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(
  659.             hash: &HashFn,
  660.             key: &[u8],
  661.             value: &T,
  662.         ) {
  663.             unhashed::put(&hash(key).as_ref(), value)
  664.         }
  665.         /// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise.
  666.         pub fn take<T: Decode + Sized, HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(
  667.             hash: &HashFn,
  668.             key: &[u8],
  669.         ) -> Option<T> {
  670.             unhashed::take(&hash(key).as_ref())
  671.         }
  672.         /// Remove `key` from storage, returning its value, or, if there was no explicit entry in storage,
  673.         /// the default for its type.
  674.         pub fn take_or_default<
  675.             T: Decode + Sized + Default,
  676.             HashFn: Fn(&[u8]) -> R,
  677.             R: AsRef<[u8]>,
  678.         >(
  679.             hash: &HashFn,
  680.             key: &[u8],
  681.         ) -> T {
  682.             unhashed::take_or_default(&hash(key).as_ref())
  683.         }
  684.         /// Return the value of the item in storage under `key`, or `default_value` if there is no
  685.         /// explicit entry. Ensure there is no explicit entry on return.
  686.         pub fn take_or<T: Decode + Sized, HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(
  687.             hash: &HashFn,
  688.             key: &[u8],
  689.             default_value: T,
  690.         ) -> T {
  691.             unhashed::take_or(&hash(key).as_ref(), default_value)
  692.         }
  693.         /// Return the value of the item in storage under `key`, or `default_value()` if there is no
  694.         /// explicit entry. Ensure there is no explicit entry on return.
  695.         pub fn take_or_else<
  696.             T: Decode + Sized,
  697.             F: FnOnce() -> T,
  698.             HashFn: Fn(&[u8]) -> R,
  699.             R: AsRef<[u8]>,
  700.         >(
  701.             hash: &HashFn,
  702.             key: &[u8],
  703.             default_value: F,
  704.         ) -> T {
  705.             unhashed::take_or_else(&hash(key).as_ref(), default_value)
  706.         }
  707.         /// Check to see if `key` has an explicit entry in storage.
  708.         pub fn exists<HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(hash: &HashFn, key: &[u8]) -> bool {
  709.             unhashed::exists(&hash(key).as_ref())
  710.         }
  711.         /// Ensure `key` has no explicit entry in storage.
  712.         pub fn kill<HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(hash: &HashFn, key: &[u8]) {
  713.             unhashed::kill(&hash(key).as_ref())
  714.         }
  715.         /// Get a Vec of bytes from storage.
  716.         pub fn get_raw<HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(
  717.             hash: &HashFn,
  718.             key: &[u8],
  719.         ) -> Option<Vec<u8>> {
  720.             unhashed::get_raw(&hash(key).as_ref())
  721.         }
  722.         /// Put a raw byte slice into storage.
  723.         pub fn put_raw<HashFn: Fn(&[u8]) -> R, R: AsRef<[u8]>>(
  724.             hash: &HashFn,
  725.             key: &[u8],
  726.             value: &[u8],
  727.         ) {
  728.             unhashed::put_raw(&hash(key).as_ref(), value)
  729.         }
  730.         /// A trait to conveniently store a vector of storable data.
  731.         ///
  732.         /// It uses twox_128 hasher. Final keys in trie are `twox_128(concatenation(PREFIX,count))`
  733.         pub trait StorageVec {
  734.             type Item: Default + Sized + Codec;
  735.             const PREFIX: &'static [u8];
  736.            /// Get the current set of items.
  737.            fn items() -> Vec<Self::Item> {
  738.                (0..Self::count()).into_iter().map(Self::item).collect()
  739.            }
  740.            /// Set the current set of items.
  741.            fn set_items<I, T>(items: I)
  742.            where
  743.                I: IntoIterator<Item = T>,
  744.                T: Borrow<Self::Item>,
  745.            {
  746.                let mut count: u32 = 0;
  747.                for i in items.into_iter() {
  748.                    put(&twox_128, &count.to_keyed_vec(Self::PREFIX), i.borrow());
  749.                    count = count
  750.                        .checked_add(1)
  751.                        .expect("exceeded runtime storage capacity");
  752.                }
  753.                Self::set_count(count);
  754.            }
  755.            /// Push an item.
  756.            fn push(item: &Self::Item) {
  757.                let len = Self::count();
  758.                put(&twox_128, &len.to_keyed_vec(Self::PREFIX), item);
  759.                Self::set_count(len + 1);
  760.            }
  761.            fn set_item(index: u32, item: &Self::Item) {
  762.                if index < Self::count() {
  763.                    put(&twox_128, &index.to_keyed_vec(Self::PREFIX), item);
  764.                }
  765.            }
  766.            fn clear_item(index: u32) {
  767.                if index < Self::count() {
  768.                    kill(&twox_128, &index.to_keyed_vec(Self::PREFIX));
  769.                }
  770.            }
  771.            fn item(index: u32) -> Self::Item {
  772.                get_or_default(&twox_128, &index.to_keyed_vec(Self::PREFIX))
  773.            }
  774.            fn set_count(count: u32) {
  775.                (count..Self::count()).for_each(Self::clear_item);
  776.                put(&twox_128, &b"len".to_keyed_vec(Self::PREFIX), &count);
  777.            }
  778.            fn count() -> u32 {
  779.                get_or_default(&twox_128, &b"len".to_keyed_vec(Self::PREFIX))
  780.            }
  781.        }
  782.    }
  783.    struct IncrementalInput<'a> {
  784.         key: &'a [u8],
  785.        pos: usize,
  786.    }
  787.    impl<'a> Input for IncrementalInput<'a> {
  788.        fn read(&mut self, into: &mut [u8]) -> usize {
  789.            let len = runtime_io::read_storage(self.key, into, self.pos).unwrap_or(0);
  790.            let read = crate::rstd::cmp::min(len, into.len());
  791.            self.pos += read;
  792.            read
  793.        }
  794.    }
  795.    struct IncrementalChildInput<'a> {
  796.         storage_key: &'a [u8],
  797.        key: &'a [u8],
  798.         pos: usize,
  799.     }
  800.     impl<'a> Input for IncrementalChildInput<'a> {
  801.         fn read(&mut self, into: &mut [u8]) -> usize {
  802.             let len = runtime_io::read_child_storage(self.storage_key, self.key, into, self.pos)
  803.                 .unwrap_or(0);
  804.             let read = crate::rstd::cmp::min(len, into.len());
  805.             self.pos += read;
  806.             read
  807.         }
  808.     }
  809.     /// The underlying runtime storage.
  810.     pub struct RuntimeStorage;
  811.     impl<H: StorageHasher> HashedStorage<H> for RuntimeStorage {
  812.         fn exists(&self, key: &[u8]) -> bool {
  813.             hashed::exists(&H::hash, key)
  814.         }
  815.         /// Load the bytes of a key from storage. Can panic if the type is incorrect.
  816.         fn get<T: Decode>(&self, key: &[u8]) -> Option<T> {
  817.             hashed::get(&H::hash, key)
  818.         }
  819.         /// Put a value in under a key.
  820.         fn put<T: Encode>(&mut self, key: &[u8], val: &T) {
  821.             hashed::put(&H::hash, key, val)
  822.         }
  823.         /// Remove the bytes of a key from storage.
  824.         fn kill(&mut self, key: &[u8]) {
  825.             hashed::kill(&H::hash, key)
  826.         }
  827.         /// Take a value from storage, deleting it after reading.
  828.         fn take<T: Decode>(&mut self, key: &[u8]) -> Option<T> {
  829.             hashed::take(&H::hash, key)
  830.         }
  831.         fn get_raw(&self, key: &[u8]) -> Option<Vec<u8>> {
  832.             hashed::get_raw(&H::hash, key)
  833.         }
  834.         fn put_raw(&mut self, key: &[u8], value: &[u8]) {
  835.             hashed::put_raw(&H::hash, key, value)
  836.         }
  837.     }
  838.     impl UnhashedStorage for RuntimeStorage {
  839.         fn exists(&self, key: &[u8]) -> bool {
  840.             unhashed::exists(key)
  841.         }
  842.         /// Load the bytes of a key from storage. Can panic if the type is incorrect.
  843.         fn get<T: Decode>(&self, key: &[u8]) -> Option<T> {
  844.             unhashed::get(key)
  845.         }
  846.         /// Put a value in under a key.
  847.         fn put<T: Encode>(&mut self, key: &[u8], val: &T) {
  848.             unhashed::put(key, val)
  849.         }
  850.         /// Remove the bytes of a key from storage.
  851.         fn kill(&mut self, key: &[u8]) {
  852.             unhashed::kill(key)
  853.         }
  854.         /// Remove the bytes of a key from storage.
  855.         fn kill_prefix(&mut self, prefix: &[u8]) {
  856.             unhashed::kill_prefix(prefix)
  857.         }
  858.         /// Take a value from storage, deleting it after reading.
  859.         fn take<T: Decode>(&mut self, key: &[u8]) -> Option<T> {
  860.             unhashed::take(key)
  861.         }
  862.         fn get_raw(&self, key: &[u8]) -> Option<Vec<u8>> {
  863.             unhashed::get_raw(key)
  864.         }
  865.         fn put_raw(&mut self, key: &[u8], value: &[u8]) {
  866.             unhashed::put_raw(key, value)
  867.         }
  868.     }
  869.     /// A trait for working with macro-generated storage values under the substrate storage API.
  870.     pub trait StorageValue<T: Codec> {
  871.         /// The type that get/take return.
  872.         type Query;
  873.         /// Get the storage key.
  874.         fn key() -> &'static [u8];
  875.        /// Does the value (explicitly) exist in storage?
  876.        fn exists() -> bool;
  877.        /// Load the value from the provided storage instance.
  878.        fn get() -> Self::Query;
  879.        /// Store a value under this key into the provided storage instance.
  880.        fn put<Arg: Borrow<T>>(val: Arg);
  881.        /// Mutate the value
  882.        fn mutate<R, F: FnOnce(&mut Self::Query) -> R>(f: F) -> R;
  883.        /// Clear the storage value.
  884.        fn kill();
  885.        /// Take a value from storage, removing it afterwards.
  886.        fn take() -> Self::Query;
  887.        /// Append the given item to the value in the storage.
  888.        ///
  889.        /// `T` is required to implement `codec::EncodeAppend`.
  890.        fn append<I: Encode>(items: &[I]) -> Result<(), &'static str>
  891.         where
  892.             T: EncodeAppend<Item = I>;
  893.     }
  894.     impl<T: Codec, U> StorageValue<T> for U
  895.     where
  896.         U: hashed::generator::StorageValue<T>,
  897.     {
  898.         type Query = U::Query;
  899.         fn key() -> &'static [u8] {
  900.            <U as hashed::generator::StorageValue<T>>::key()
  901.        }
  902.        fn exists() -> bool {
  903.            U::exists(&RuntimeStorage)
  904.        }
  905.        fn get() -> Self::Query {
  906.            U::get(&RuntimeStorage)
  907.        }
  908.        fn put<Arg: Borrow<T>>(val: Arg) {
  909.            U::put(val.borrow(), &mut RuntimeStorage)
  910.        }
  911.        fn mutate<R, F: FnOnce(&mut Self::Query) -> R>(f: F) -> R {
  912.            U::mutate(f, &mut RuntimeStorage)
  913.        }
  914.        fn kill() {
  915.            U::kill(&mut RuntimeStorage)
  916.        }
  917.        fn take() -> Self::Query {
  918.            U::take(&mut RuntimeStorage)
  919.        }
  920.        fn append<I: Encode>(items: &[I]) -> Result<(), &'static str>
  921.         where
  922.             T: EncodeAppend<Item = I>,
  923.         {
  924.             U::append(items, &mut RuntimeStorage)
  925.         }
  926.     }
  927.     /// A strongly-typed map in storage.
  928.     pub trait StorageMap<K: Codec, V: Codec> {
  929.         /// The type that get/take return.
  930.         type Query;
  931.         /// Get the prefix key in storage.
  932.         fn prefix() -> &'static [u8];
  933.        /// Get the storage key used to fetch a value corresponding to a specific key.
  934.        fn key_for<KeyArg: Borrow<K>>(key: KeyArg) -> Vec<u8>;
  935.        /// Does the value (explicitly) exist in storage?
  936.        fn exists<KeyArg: Borrow<K>>(key: KeyArg) -> bool;
  937.        /// Load the value associated with the given key from the map.
  938.        fn get<KeyArg: Borrow<K>>(key: KeyArg) -> Self::Query;
  939.        /// Store a value to be associated with the given key from the map.
  940.        fn insert<KeyArg: Borrow<K>, ValArg: Borrow<V>>(key: KeyArg, val: ValArg);
  941.        /// Remove the value under a key.
  942.        fn remove<KeyArg: Borrow<K>>(key: KeyArg);
  943.        /// Mutate the value under a key.
  944.        fn mutate<KeyArg: Borrow<K>, R, F: FnOnce(&mut Self::Query) -> R>(key: KeyArg, f: F) -> R;
  945.        /// Take the value under a key.
  946.        fn take<KeyArg: Borrow<K>>(key: KeyArg) -> Self::Query;
  947.    }
  948.    impl<K: Codec, V: Codec, U> StorageMap<K, V> for U
  949.    where
  950.        U: hashed::generator::StorageMap<K, V>,
  951.    {
  952.        type Query = U::Query;
  953.        fn prefix() -> &'static [u8] {
  954.             <U as hashed::generator::StorageMap<K, V>>::prefix()
  955.         }
  956.         fn key_for<KeyArg: Borrow<K>>(key: KeyArg) -> Vec<u8> {
  957.             <U as hashed::generator::StorageMap<K, V>>::key_for(key.borrow())
  958.         }
  959.         fn exists<KeyArg: Borrow<K>>(key: KeyArg) -> bool {
  960.             U::exists(key.borrow(), &RuntimeStorage)
  961.         }
  962.         fn get<KeyArg: Borrow<K>>(key: KeyArg) -> Self::Query {
  963.             U::get(key.borrow(), &RuntimeStorage)
  964.         }
  965.         fn insert<KeyArg: Borrow<K>, ValArg: Borrow<V>>(key: KeyArg, val: ValArg) {
  966.             U::insert(key.borrow(), val.borrow(), &mut RuntimeStorage)
  967.         }
  968.         fn remove<KeyArg: Borrow<K>>(key: KeyArg) {
  969.             U::remove(key.borrow(), &mut RuntimeStorage)
  970.         }
  971.         fn mutate<KeyArg: Borrow<K>, R, F: FnOnce(&mut Self::Query) -> R>(key: KeyArg, f: F) -> R {
  972.             U::mutate(key.borrow(), f, &mut RuntimeStorage)
  973.         }
  974.         fn take<KeyArg: Borrow<K>>(key: KeyArg) -> Self::Query {
  975.             U::take(key.borrow(), &mut RuntimeStorage)
  976.         }
  977.     }
  978.     /// A storage map with values that can be appended to.
  979.     pub trait AppendableStorageMap<K: Codec, V: Codec>: StorageMap<K, V> {
  980.         /// Append the given item to the value in the storage.
  981.         ///
  982.         /// `T` is required to implement `codec::EncodeAppend`.
  983.         fn append<KeyArg: Borrow<K>, I: Encode>(
  984.             key: KeyArg,
  985.             items: &[I],
  986.         ) -> Result<(), &'static str>
  987.        where
  988.            V: EncodeAppend<Item = I>;
  989.    }
  990.    impl<K: Codec, V: Codec, U> AppendableStorageMap<K, V> for U
  991.    where
  992.        U: hashed::generator::AppendableStorageMap<K, V>,
  993.    {
  994.        fn append<KeyArg: Borrow<K>, I: Encode>(
  995.            key: KeyArg,
  996.            items: &[I],
  997.        ) -> Result<(), &'static str>
  998.         where
  999.             V: EncodeAppend<Item = I>,
  1000.         {
  1001.             U::append(key.borrow(), items, &mut RuntimeStorage)
  1002.         }
  1003.     }
  1004.     /// A storage map that can be enumerated.
  1005.     ///
  1006.     /// Primarily useful for off-chain computations.
  1007.     /// Runtime implementors should avoid enumerating storage entries on-chain.
  1008.     pub trait EnumerableStorageMap<K: Codec, V: Codec>: StorageMap<K, V> {
  1009.         /// Return current head element.
  1010.         fn head() -> Option<K>;
  1011.         /// Enumerate all elements in the map.
  1012.         fn enumerate() -> Box<dyn Iterator<Item = (K, V)>>
  1013.         where
  1014.             K: 'static,
  1015.            V: 'static;
  1016.     }
  1017.     impl<K: Codec, V: Codec, U> EnumerableStorageMap<K, V> for U
  1018.     where
  1019.         U: hashed::generator::EnumerableStorageMap<K, V>,
  1020.     {
  1021.         fn head() -> Option<K> {
  1022.             <U as hashed::generator::EnumerableStorageMap<K, V>>::head(&RuntimeStorage)
  1023.         }
  1024.         fn enumerate() -> Box<dyn Iterator<Item = (K, V)>>
  1025.         where
  1026.             K: 'static,
  1027.            V: 'static,
  1028.         {
  1029.             <U as hashed::generator::EnumerableStorageMap<K, V>>::enumerate(&RuntimeStorage)
  1030.         }
  1031.     }
  1032.     /// An implementation of a map with a two keys.
  1033.     ///
  1034.     /// It provides an important ability to efficiently remove all entries
  1035.     /// that have a common first key.
  1036.     ///
  1037.     /// # Mapping of keys to a storage path
  1038.     ///
  1039.     /// The storage key (i.e. the key under which the `Value` will be stored) is created from two parts.
  1040.     /// The first part is a hash of a concatenation of the `PREFIX` and `Key1`. And the second part
  1041.     /// is a hash of a `Key2`.
  1042.     ///
  1043.     /// /!\ be careful while choosing the Hash, indeed malicious could craft second keys to lower the trie.
  1044.     pub trait StorageDoubleMap<K1: Codec, K2: Codec, V: Codec> {
  1045.         /// The type that get/take returns.
  1046.         type Query;
  1047.         /// Get the prefix key in storage.
  1048.         fn prefix() -> &'static [u8];
  1049.        /// Get the storage key used to fetch a value corresponding to a specific key.
  1050.        fn key_for<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> Vec<u8>;
  1051.        /// Get the storage prefix used to fetch keys corresponding to a specific key1.
  1052.        fn prefix_for<KArg1: Borrow<K1>>(k1: KArg1) -> Vec<u8>;
  1053.        /// true if the value is defined in storage.
  1054.        fn exists<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> bool;
  1055.        /// Load the value associated with the given key from the map.
  1056.        fn get<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> Self::Query;
  1057.        /// Take the value under a key.
  1058.        fn take<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> Self::Query;
  1059.        /// Store a value to be associated with the given key from the map.
  1060.        fn insert<KArg1: Borrow<K1>, KArg2: Borrow<K2>, VArg: Borrow<V>>(
  1061.            k1: KArg1,
  1062.            k2: KArg2,
  1063.            val: VArg,
  1064.        );
  1065.        /// Remove the value under a key.
  1066.        fn remove<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2);
  1067.        /// Removes all entries that shares the `k1` as the first key.
  1068.        fn remove_prefix<KArg1: Borrow<K1>>(k1: KArg1);
  1069.        /// Mutate the value under a key.
  1070.        fn mutate<KArg1, KArg2, R, F>(k1: KArg1, k2: KArg2, f: F) -> R
  1071.        where
  1072.            KArg1: Borrow<K1>,
  1073.            KArg2: Borrow<K2>,
  1074.            F: FnOnce(&mut Self::Query) -> R;
  1075.        /// Append the given items to the value under the key specified.
  1076.        ///
  1077.        /// `V` is required to implement `codec::EncodeAppend<Item=I>`.
  1078.        fn append<KArg1, KArg2, I>(k1: KArg1, k2: KArg2, items: &[I]) -> Result<(), &'static str>
  1079.         where
  1080.             KArg1: Borrow<K1>,
  1081.             KArg2: Borrow<K2>,
  1082.             I: codec::Encode,
  1083.             V: EncodeAppend<Item = I>;
  1084.     }
  1085.     impl<K1: Codec, K2: Codec, V: Codec, U> StorageDoubleMap<K1, K2, V> for U
  1086.     where
  1087.         U: unhashed::generator::StorageDoubleMap<K1, K2, V>,
  1088.     {
  1089.         type Query = U::Query;
  1090.         fn prefix() -> &'static [u8] {
  1091.            <U as unhashed::generator::StorageDoubleMap<K1, K2, V>>::prefix()
  1092.        }
  1093.        fn key_for<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> Vec<u8> {
  1094.            <U as unhashed::generator::StorageDoubleMap<K1, K2, V>>::key_for(
  1095.                k1.borrow(),
  1096.                k2.borrow(),
  1097.            )
  1098.        }
  1099.        fn prefix_for<KArg1: Borrow<K1>>(k1: KArg1) -> Vec<u8> {
  1100.            <U as unhashed::generator::StorageDoubleMap<K1, K2, V>>::prefix_for(k1.borrow())
  1101.        }
  1102.        fn exists<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> bool {
  1103.            U::exists(k1.borrow(), k2.borrow(), &RuntimeStorage)
  1104.        }
  1105.        fn get<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> Self::Query {
  1106.            U::get(k1.borrow(), k2.borrow(), &RuntimeStorage)
  1107.        }
  1108.        fn take<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) -> Self::Query {
  1109.            U::take(k1.borrow(), k2.borrow(), &mut RuntimeStorage)
  1110.        }
  1111.        fn insert<KArg1: Borrow<K1>, KArg2: Borrow<K2>, VArg: Borrow<V>>(
  1112.            k1: KArg1,
  1113.            k2: KArg2,
  1114.            val: VArg,
  1115.        ) {
  1116.            U::insert(k1.borrow(), k2.borrow(), val.borrow(), &mut RuntimeStorage)
  1117.        }
  1118.        fn remove<KArg1: Borrow<K1>, KArg2: Borrow<K2>>(k1: KArg1, k2: KArg2) {
  1119.            U::remove(k1.borrow(), k2.borrow(), &mut RuntimeStorage)
  1120.        }
  1121.        fn remove_prefix<KArg1: Borrow<K1>>(k1: KArg1) {
  1122.            U::remove_prefix(k1.borrow(), &mut RuntimeStorage)
  1123.        }
  1124.        fn mutate<KArg1, KArg2, R, F>(k1: KArg1, k2: KArg2, f: F) -> R
  1125.        where
  1126.            KArg1: Borrow<K1>,
  1127.            KArg2: Borrow<K2>,
  1128.            F: FnOnce(&mut Self::Query) -> R,
  1129.        {
  1130.            U::mutate(k1.borrow(), k2.borrow(), f, &mut RuntimeStorage)
  1131.        }
  1132.        fn append<KArg1, KArg2, I>(k1: KArg1, k2: KArg2, items: &[I]) -> Result<(), &'static str>
  1133.         where
  1134.             KArg1: Borrow<K1>,
  1135.             KArg2: Borrow<K2>,
  1136.             I: codec::Encode,
  1137.             V: EncodeAppend<Item = I>,
  1138.         {
  1139.             U::append(k1.borrow(), k2.borrow(), items, &mut RuntimeStorage)
  1140.         }
  1141.     }
  1142.     /// child storage NOTE could replace unhashed by having only one kind of storage (root being null storage
  1143.     /// key (storage_key can become Option<&[u8]>).
  1144.     /// This module is a currently only a variant of unhashed with additional `storage_key`.
  1145.     /// Note that `storage_key` must be unique and strong (strong in the sense of being long enough to
  1146.     /// avoid collision from a resistant hash function (which unique implies)).
  1147.     pub mod child {
  1148.         use super::{Codec, Decode, IncrementalChildInput, Vec};
  1149.         /// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
  1150.         pub fn get<T: Codec + Sized>(storage_key: &[u8], key: &[u8]) -> Option<T> {
  1151.             runtime_io::read_child_storage(storage_key, key, &mut [0; 0][..], 0).map(|_| {
  1152.                 let mut input = IncrementalChildInput {
  1153.                     storage_key,
  1154.                     key,
  1155.                     pos: 0,
  1156.                 };
  1157.                 Decode::decode(&mut input)
  1158.                     .expect("storage is not null, therefore must be a valid type")
  1159.             })
  1160.         }
  1161.         /// Return the value of the item in storage under `key`, or the type's default if there is no
  1162.         /// explicit entry.
  1163.         pub fn get_or_default<T: Codec + Sized + Default>(storage_key: &[u8], key: &[u8]) -> T {
  1164.             get(storage_key, key).unwrap_or_else(Default::default)
  1165.         }
  1166.         /// Return the value of the item in storage under `key`, or `default_value` if there is no
  1167.         /// explicit entry.
  1168.         pub fn get_or<T: Codec + Sized>(storage_key: &[u8], key: &[u8], default_value: T) -> T {
  1169.             get(storage_key, key).unwrap_or(default_value)
  1170.         }
  1171.         /// Return the value of the item in storage under `key`, or `default_value()` if there is no
  1172.         /// explicit entry.
  1173.         pub fn get_or_else<T: Codec + Sized, F: FnOnce() -> T>(
  1174.             storage_key: &[u8],
  1175.             key: &[u8],
  1176.             default_value: F,
  1177.         ) -> T {
  1178.             get(storage_key, key).unwrap_or_else(default_value)
  1179.         }
  1180.         /// Put `value` in storage under `key`.
  1181.         pub fn put<T: Codec>(storage_key: &[u8], key: &[u8], value: &T) {
  1182.             value.using_encoded(|slice| runtime_io::set_child_storage(storage_key, key, slice));
  1183.         }
  1184.         /// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise.
  1185.         pub fn take<T: Codec + Sized>(storage_key: &[u8], key: &[u8]) -> Option<T> {
  1186.             let r = get(storage_key, key);
  1187.             if r.is_some() {
  1188.                 kill(storage_key, key);
  1189.             }
  1190.             r
  1191.         }
  1192.         /// Remove `key` from storage, returning its value, or, if there was no explicit entry in storage,
  1193.         /// the default for its type.
  1194.         pub fn take_or_default<T: Codec + Sized + Default>(storage_key: &[u8], key: &[u8]) -> T {
  1195.             take(storage_key, key).unwrap_or_else(Default::default)
  1196.         }
  1197.         /// Return the value of the item in storage under `key`, or `default_value` if there is no
  1198.         /// explicit entry. Ensure there is no explicit entry on return.
  1199.         pub fn take_or<T: Codec + Sized>(storage_key: &[u8], key: &[u8], default_value: T) -> T {
  1200.             take(storage_key, key).unwrap_or(default_value)
  1201.         }
  1202.         /// Return the value of the item in storage under `key`, or `default_value()` if there is no
  1203.         /// explicit entry. Ensure there is no explicit entry on return.
  1204.         pub fn take_or_else<T: Codec + Sized, F: FnOnce() -> T>(
  1205.             storage_key: &[u8],
  1206.             key: &[u8],
  1207.             default_value: F,
  1208.         ) -> T {
  1209.             take(storage_key, key).unwrap_or_else(default_value)
  1210.         }
  1211.         /// Check to see if `key` has an explicit entry in storage.
  1212.         pub fn exists(storage_key: &[u8], key: &[u8]) -> bool {
  1213.             runtime_io::read_child_storage(storage_key, key, &mut [0; 0][..], 0).is_some()
  1214.         }
  1215.         /// Remove all `storage_key` key/values
  1216.         pub fn kill_storage(storage_key: &[u8]) {
  1217.             runtime_io::kill_child_storage(storage_key)
  1218.         }
  1219.         /// Ensure `key` has no explicit entry in storage.
  1220.         pub fn kill(storage_key: &[u8], key: &[u8]) {
  1221.             runtime_io::clear_child_storage(storage_key, key);
  1222.         }
  1223.         /// Get a Vec of bytes from storage.
  1224.         pub fn get_raw(storage_key: &[u8], key: &[u8]) -> Option<Vec<u8>> {
  1225.             runtime_io::child_storage(storage_key, key)
  1226.         }
  1227.         /// Put a raw byte slice into storage.
  1228.         pub fn put_raw(storage_key: &[u8], key: &[u8], value: &[u8]) {
  1229.             runtime_io::set_child_storage(storage_key, key, value)
  1230.         }
  1231.         pub use super::unhashed::StorageVec;
  1232.     }
  1233. }
  1234. mod hashable {
  1235.     //! Hashable trait.
  1236.     use crate::codec::Codec;
  1237.     use crate::rstd::prelude::Vec;
  1238.     use crate::storage::hashed::generator::StorageHasher;
  1239.     use crate::Twox64Concat;
  1240.     use runtime_io::{blake2_128, blake2_256, twox_128, twox_256};
  1241.     pub trait Hashable: Sized {
  1242.         fn blake2_128(&self) -> [u8; 16];
  1243.         fn blake2_256(&self) -> [u8; 32];
  1244.         fn twox_128(&self) -> [u8; 16];
  1245.         fn twox_256(&self) -> [u8; 32];
  1246.         fn twox_64_concat(&self) -> Vec<u8>;
  1247.     }
  1248.     impl<T: Codec> Hashable for T {
  1249.         fn blake2_128(&self) -> [u8; 16] {
  1250.             self.using_encoded(blake2_128)
  1251.         }
  1252.         fn blake2_256(&self) -> [u8; 32] {
  1253.             self.using_encoded(blake2_256)
  1254.         }
  1255.         fn twox_128(&self) -> [u8; 16] {
  1256.             self.using_encoded(twox_128)
  1257.         }
  1258.         fn twox_256(&self) -> [u8; 32] {
  1259.             self.using_encoded(twox_256)
  1260.         }
  1261.         fn twox_64_concat(&self) -> Vec<u8> {
  1262.             self.using_encoded(Twox64Concat::hash)
  1263.         }
  1264.     }
  1265. }
  1266. #[macro_use]
  1267. pub mod event {
  1268.     //! Macros that define an Event types. Events can be used to easily report changes or conditions
  1269.     //! in your runtime to external entities like users, chain explorers, or dApps.
  1270.     pub use srml_metadata::{DecodeDifferent, EventMetadata, FnEncode, OuterEventMetadata};
  1271. }
  1272. #[macro_use]
  1273. mod origin {
  1274.     //! Macros that define an Origin type. Every function call to your runtime has an origin which
  1275.     //! specifies where the extrinsic was generated from.
  1276. }
  1277. #[macro_use]
  1278. pub mod metadata {
  1279.     pub use srml_metadata::{
  1280.         DecodeDifferent, DefaultByte, DefaultByteGetter, FnEncode, ModuleMetadata, RuntimeMetadata,
  1281.         RuntimeMetadataPrefixed, RuntimeMetadataV4, StorageFunctionMetadata,
  1282.         StorageFunctionModifier, StorageFunctionType, StorageHasher, StorageMetadata,
  1283.     };
  1284. }
  1285. #[macro_use]
  1286. mod runtime {
  1287.     //! Macros to define a runtime. A runtime is basically all your logic running in Substrate,
  1288.     //! consisting of selected SRML modules and maybe some of your own modules.
  1289.     //! A lot of supporting logic is automatically generated for a runtime,
  1290.     //! mostly to combine data types and metadata of the included modules.
  1291. }
  1292. #[macro_use]
  1293. pub mod inherent {
  1294.     #[doc(hidden)]
  1295.     pub use crate::rstd::vec::Vec;
  1296.     #[doc(hidden)]
  1297.     pub use crate::runtime_primitives::traits::{Block as BlockT, Extrinsic};
  1298.     #[doc(hidden)]
  1299.     pub use inherents::{CheckInherentsResult, InherentData, IsFatalError, ProvideInherent};
  1300. }
  1301. #[macro_use]
  1302. pub mod unsigned {
  1303.     #[doc(hidden)]
  1304.     pub use crate::runtime_primitives::traits::ValidateUnsigned;
  1305.     #[doc(hidden)]
  1306.     pub use crate::runtime_primitives::transaction_validity::TransactionValidity;
  1307.     #[doc(hidden)]
  1308.     pub use crate::runtime_primitives::ApplyError;
  1309. }
  1310. mod double_map {
  1311.     //! An implementation of double map backed by storage.
  1312.     use crate::codec::{Codec, Encode};
  1313.     use crate::rstd::prelude::*;
  1314.     use crate::storage::unhashed;
  1315.     use sr_std::borrow::Borrow;
  1316.     /// An implementation of a map with a two keys.
  1317.     ///
  1318.     /// It provides an important ability to efficiently remove all entries
  1319.     /// that have a common first key.
  1320.     ///
  1321.     /// # Mapping of keys to a storage path
  1322.     ///
  1323.     /// The storage key (i.e. the key under which the `Value` will be stored) is created from two parts.
  1324.     /// The first part is a hash of a concatenation of the `PREFIX` and `Key1`. And the second part
  1325.     /// is a hash of a `Key2`.
  1326.     ///
  1327.     /// Hasher are implemented in derive_key* methods.
  1328.     pub trait StorageDoubleMapWithHasher {
  1329.         type Key1: Codec;
  1330.         type Key2: Codec;
  1331.         type Value: Codec + Default;
  1332.         const PREFIX: &'static [u8];
  1333.        /// Insert an entry into this map.
  1334.        fn insert<Q, R>(k1: &Q, k2: &R, val: Self::Value)
  1335.        where
  1336.            Self::Key1: Borrow<Q>,
  1337.            Self::Key2: Borrow<R>,
  1338.            Q: Codec,
  1339.            R: Codec,
  1340.        {
  1341.            unhashed::put(&Self::full_key(k1, k2)[..], &val);
  1342.        }
  1343.        /// Remove an entry from this map.
  1344.        fn remove<Q, R>(k1: &Q, k2: &R)
  1345.        where
  1346.            Self::Key1: Borrow<Q>,
  1347.            Self::Key2: Borrow<R>,
  1348.            Q: Codec,
  1349.            R: Codec,
  1350.        {
  1351.            unhashed::kill(&Self::full_key(k1, k2)[..]);
  1352.        }
  1353.        /// Get an entry from this map.
  1354.        ///
  1355.        /// If there is entry stored under the given keys, returns `None`.
  1356.        fn get<Q, R>(k1: &Q, k2: &R) -> Option<Self::Value>
  1357.        where
  1358.            Self::Key1: Borrow<Q>,
  1359.            Self::Key2: Borrow<R>,
  1360.            Q: Codec,
  1361.            R: Codec,
  1362.        {
  1363.            unhashed::get(&Self::full_key(k1, k2)[..])
  1364.        }
  1365.        /// Returns `true` if value under the specified keys exists.
  1366.        fn exists<Q, R>(k1: &Q, k2: &R) -> bool
  1367.        where
  1368.            Self::Key1: Borrow<Q>,
  1369.            Self::Key2: Borrow<R>,
  1370.            Q: Codec,
  1371.            R: Codec,
  1372.        {
  1373.            unhashed::exists(&Self::full_key(k1, k2)[..])
  1374.        }
  1375.        /// Removes all entries that shares the `k1` as the first key.
  1376.        fn remove_prefix<Q>(k1: &Q)
  1377.        where
  1378.            Self::Key1: Borrow<Q>,
  1379.            Q: Codec,
  1380.        {
  1381.            unhashed::kill_prefix(&Self::derive_key1(Self::encode_key1(k1)))
  1382.        }
  1383.        /// Encode key1 into Vec<u8> and prepend a prefix
  1384.        fn encode_key1<Q>(key: &Q) -> Vec<u8>
  1385.        where
  1386.            Self::Key1: Borrow<Q>,
  1387.            Q: Codec,
  1388.        {
  1389.            let mut raw_prefix = Vec::new();
  1390.            raw_prefix.extend(Self::PREFIX);
  1391.            key.encode_to(&mut raw_prefix);
  1392.            raw_prefix
  1393.        }
  1394.        /// Encode key2 into Vec<u8>
  1395.        fn encode_key2<R>(key: &R) -> Vec<u8>
  1396.        where
  1397.            Self::Key2: Borrow<R>,
  1398.            R: Codec,
  1399.        {
  1400.            Encode::encode(&key)
  1401.        }
  1402.        /// Derive the first part of the key
  1403.        fn derive_key1(key1_data: Vec<u8>) -> Vec<u8>;
  1404.        /// Derive the remaining part of the key
  1405.        fn derive_key2(key2_data: Vec<u8>) -> Vec<u8>;
  1406.        /// Returns a compound key that consist of the two parts: (prefix, `k1`) and `k2`.
  1407.        /// The first part is hashed and then concatenated with a hash of `k2`.
  1408.        fn full_key<Q, R>(k1: &Q, k2: &R) -> Vec<u8>
  1409.        where
  1410.            Self::Key1: Borrow<Q>,
  1411.            Self::Key2: Borrow<R>,
  1412.            Q: Codec,
  1413.            R: Codec,
  1414.        {
  1415.            let key1_data = Self::encode_key1(k1);
  1416.            let key2_data = Self::encode_key2(k2);
  1417.            let mut key = Self::derive_key1(key1_data);
  1418.            key.extend(Self::derive_key2(key2_data));
  1419.            key
  1420.        }
  1421.    }
  1422. }
  1423. pub mod traits {
  1424.    //! Traits for SRML
  1425.    use crate::codec::{Codec, Decode, Encode};
  1426.    use crate::rstd::result;
  1427.    use crate::runtime_primitives::traits::{MaybeSerializeDebug, SimpleArithmetic};
  1428.    /// New trait for querying a single fixed value from a type.
  1429.    pub trait Get<T> {
  1430.        /// Return a constant value.
  1431.        fn get() -> T;
  1432.    }
  1433.    /// The account with the given id was killed.
  1434.    pub trait OnFreeBalanceZero<AccountId> {
  1435.        /// The account was the given id was killed.
  1436.        fn on_free_balance_zero(who: &AccountId);
  1437.    }
  1438.    impl<AccountId> OnFreeBalanceZero<AccountId> for () {
  1439.        fn on_free_balance_zero(_who: &AccountId) {}
  1440.    }
  1441.    impl<AccountId, X: OnFreeBalanceZero<AccountId>, Y: OnFreeBalanceZero<AccountId>>
  1442.        OnFreeBalanceZero<AccountId> for (X, Y)
  1443.    {
  1444.        fn on_free_balance_zero(who: &AccountId) {
  1445.            X::on_free_balance_zero(who);
  1446.            Y::on_free_balance_zero(who);
  1447.        }
  1448.    }
  1449.    /// Trait for a hook to get called when some balance has been minted, causing dilution.
  1450.    pub trait OnDilution<Balance> {
  1451.        /// Some `portion` of the total balance just "grew" by `minted`. `portion` is the pre-growth
  1452.        /// amount (it doesn't take account of the recent growth).
  1453.         fn on_dilution(minted: Balance, portion: Balance);
  1454.     }
  1455.     impl<Balance> OnDilution<Balance> for () {
  1456.         fn on_dilution(_minted: Balance, _portion: Balance) {}
  1457.     }
  1458.     /// Outcome of a balance update.
  1459.     pub enum UpdateBalanceOutcome {
  1460.         /// Account balance was simply updated.
  1461.         Updated,
  1462.         /// The update led to killing the account.
  1463.         AccountKilled,
  1464.     }
  1465.     /// Simple trait designed for hooking into a transaction payment.
  1466.     ///
  1467.     /// It operates over a single generic `AccountId` type.
  1468.     pub trait MakePayment<AccountId> {
  1469.         /// Make transaction payment from `who` for an extrinsic of encoded length
  1470.         /// `encoded_len` bytes. Return `Ok` iff the payment was successful.
  1471.         fn make_payment(who: &AccountId, encoded_len: usize) -> Result<(), &'static str>;
  1472.    }
  1473.    impl<T> MakePayment<T> for () {
  1474.        fn make_payment(_: &T, _: usize) -> Result<(), &'static str> {
  1475.             Ok(())
  1476.         }
  1477.     }
  1478.     /// Handler for when some currency "account" decreased in balance for
  1479.     /// some reason.
  1480.     ///
  1481.     /// The only reason at present for an increase would be for validator rewards, but
  1482.     /// there may be other reasons in the future or for other chains.
  1483.     ///
  1484.     /// Reasons for decreases include:
  1485.     ///
  1486.     /// - Someone got slashed.
  1487.     /// - Someone paid for a transaction to be included.
  1488.     pub trait OnUnbalanced<Imbalance> {
  1489.         /// Handler for some imbalance. Infallible.
  1490.         fn on_unbalanced(amount: Imbalance);
  1491.     }
  1492.     impl<Imbalance: Drop> OnUnbalanced<Imbalance> for () {
  1493.         fn on_unbalanced(amount: Imbalance) {
  1494.             drop(amount);
  1495.         }
  1496.     }
  1497.     /// Simple boolean for whether an account needs to be kept in existence.
  1498.     #[structural_match]
  1499.     #[rustc_copy_clone_marker]
  1500.     pub enum ExistenceRequirement {
  1501.         /// Operation must not result in the account going out of existence.
  1502.         KeepAlive,
  1503.         /// Operation may result in account going out of existence.
  1504.         AllowDeath,
  1505.     }
  1506.     #[automatically_derived]
  1507.     #[allow(unused_qualifications)]
  1508.     impl ::std::marker::Copy for ExistenceRequirement {}
  1509.     #[automatically_derived]
  1510.     #[allow(unused_qualifications)]
  1511.     impl ::std::clone::Clone for ExistenceRequirement {
  1512.         #[inline]
  1513.         fn clone(&self) -> ExistenceRequirement {
  1514.             {
  1515.                 *self
  1516.             }
  1517.         }
  1518.     }
  1519.     #[automatically_derived]
  1520.     #[allow(unused_qualifications)]
  1521.     impl ::std::cmp::Eq for ExistenceRequirement {
  1522.         #[inline]
  1523.         #[doc(hidden)]
  1524.         fn assert_receiver_is_total_eq(&self) -> () {
  1525.             {}
  1526.         }
  1527.     }
  1528.     #[automatically_derived]
  1529.     #[allow(unused_qualifications)]
  1530.     impl ::std::cmp::PartialEq for ExistenceRequirement {
  1531.         #[inline]
  1532.         fn eq(&self, other: &ExistenceRequirement) -> bool {
  1533.             {
  1534.                 let __self_vi = unsafe { ::std::intrinsics::discriminant_value(&*self) } as isize;
  1535.                 let __arg_1_vi = unsafe { ::std::intrinsics::discriminant_value(&*other) } as isize;
  1536.                 if true && __self_vi == __arg_1_vi {
  1537.                     match (&*self, &*other) {
  1538.                         _ => true,
  1539.                     }
  1540.                 } else {
  1541.                     false
  1542.                 }
  1543.             }
  1544.         }
  1545.     }
  1546.     /// A trait for a not-quite Linear Type that tracks an imbalance.
  1547.     ///
  1548.     /// Functions that alter account balances return an object of this trait to
  1549.     /// express how much account balances have been altered in aggregate. If
  1550.     /// dropped, the currency system will take some default steps to deal with
  1551.     /// the imbalance (`balances` module simply reduces or increases its
  1552.     /// total issuance). Your module should generally handle it in some way,
  1553.     /// good practice is to do so in a configurable manner using an
  1554.     /// `OnUnbalanced` type for each situation in which your module needs to
  1555.     /// handle an imbalance.
  1556.     ///
  1557.     /// Imbalances can either be Positive (funds were added somewhere without
  1558.     /// being subtracted elsewhere - e.g. a reward) or Negative (funds deducted
  1559.     /// somewhere without an equal and opposite addition - e.g. a slash or
  1560.     /// system fee payment).
  1561.     ///
  1562.     /// Since they are unsigned, the actual type is always Positive or Negative.
  1563.     /// The trait makes no distinction except to define the `Opposite` type.
  1564.     ///
  1565.     /// New instances of zero value can be created (`zero`) and destroyed
  1566.     /// (`drop_zero`).
  1567.     ///
  1568.     /// Existing instances can be `split` and merged either consuming `self` with
  1569.     /// `merge` or mutating `self` with `subsume`. If the target is an `Option`,
  1570.     /// then `maybe_merge` and `maybe_subsume` might work better. Instances can
  1571.     /// also be `offset` with an `Opposite` that is less than or equal to in value.
  1572.     ///
  1573.     /// You can always retrieve the raw balance value using `peek`.
  1574.     #[must_use]
  1575.     pub trait Imbalance<Balance>: Sized {
  1576.         /// The oppositely imbalanced type. They come in pairs.
  1577.         type Opposite: Imbalance<Balance>;
  1578.         /// The zero imbalance. Can be destroyed with `drop_zero`.
  1579.         fn zero() -> Self;
  1580.         /// Drop an instance cleanly. Only works if its `value()` is zero.
  1581.         fn drop_zero(self) -> Result<(), Self>;
  1582.         /// Consume `self` and return two independent instances; the first
  1583.         /// is guaranteed to be at most `amount` and the second will be the remainder.
  1584.         fn split(self, amount: Balance) -> (Self, Self);
  1585.         /// Consume `self` and an `other` to return a new instance that combines
  1586.         /// both.
  1587.         fn merge(self, other: Self) -> Self;
  1588.         /// Consume `self` and maybe an `other` to return a new instance that combines
  1589.         /// both.
  1590.         fn maybe_merge(self, other: Option<Self>) -> Self {
  1591.             if let Some(o) = other {
  1592.                 self.merge(o)
  1593.             } else {
  1594.                 self
  1595.             }
  1596.         }
  1597.         /// Consume an `other` to mutate `self` into a new instance that combines
  1598.         /// both.
  1599.         fn subsume(&mut self, other: Self);
  1600.         /// Maybe consume an `other` to mutate `self` into a new instance that combines
  1601.         /// both.
  1602.         fn maybe_subsume(&mut self, other: Option<Self>) {
  1603.             if let Some(o) = other {
  1604.                 self.subsume(o)
  1605.             }
  1606.         }
  1607.         /// Consume self and along with an opposite counterpart to return
  1608.         /// a combined result.
  1609.         ///
  1610.         /// Returns `Ok` along with a new instance of `Self` if this instance has a
  1611.         /// greater value than the `other`. Otherwise returns `Err` with an instance of
  1612.         /// the `Opposite`. In both cases the value represents the combination of `self`
  1613.         /// and `other`.
  1614.         fn offset(self, other: Self::Opposite) -> Result<Self, Self::Opposite>;
  1615.         /// The raw value of self.
  1616.         fn peek(&self) -> Balance;
  1617.     }
  1618.     /// Either a positive or a negative imbalance.
  1619.     pub enum SignedImbalance<B, P: Imbalance<B>> {
  1620.         /// A positive imbalance (funds have been created but none destroyed).
  1621.         Positive(P),
  1622.         /// A negative imbalance (funds have been destroyed but none created).
  1623.         Negative(P::Opposite),
  1624.     }
  1625.     impl<
  1626.             P: Imbalance<B, Opposite = N>,
  1627.             N: Imbalance<B, Opposite = P>,
  1628.             B: SimpleArithmetic + Codec + Copy + MaybeSerializeDebug + Default,
  1629.         > SignedImbalance<B, P>
  1630.     {
  1631.         pub fn zero() -> Self {
  1632.             SignedImbalance::Positive(P::zero())
  1633.         }
  1634.         pub fn drop_zero(self) -> Result<(), Self> {
  1635.             match self {
  1636.                 SignedImbalance::Positive(x) => x.drop_zero().map_err(SignedImbalance::Positive),
  1637.                 SignedImbalance::Negative(x) => x.drop_zero().map_err(SignedImbalance::Negative),
  1638.             }
  1639.         }
  1640.         /// Consume `self` and an `other` to return a new instance that combines
  1641.         /// both.
  1642.         pub fn merge(self, other: Self) -> Self {
  1643.             match (self, other) {
  1644.                 (SignedImbalance::Positive(one), SignedImbalance::Positive(other)) => {
  1645.                     SignedImbalance::Positive(one.merge(other))
  1646.                 }
  1647.                 (SignedImbalance::Negative(one), SignedImbalance::Negative(other)) => {
  1648.                     SignedImbalance::Negative(one.merge(other))
  1649.                 }
  1650.                 (SignedImbalance::Positive(one), SignedImbalance::Negative(other)) => {
  1651.                     if one.peek() > other.peek() {
  1652.                         SignedImbalance::Positive(one.offset(other).ok().unwrap_or_else(P::zero))
  1653.                     } else {
  1654.                         SignedImbalance::Negative(other.offset(one).ok().unwrap_or_else(N::zero))
  1655.                     }
  1656.                 }
  1657.                 (one, other) => other.merge(one),
  1658.             }
  1659.         }
  1660.     }
  1661.     /// Abstraction over a fungible assets system.
  1662.     pub trait Currency<AccountId> {
  1663.         /// The balance of an account.
  1664.         type Balance: SimpleArithmetic + Codec + Copy + MaybeSerializeDebug + Default;
  1665.         /// The opaque token type for an imbalance. This is returned by unbalanced operations
  1666.         /// and must be dealt with. It may be dropped but cannot be cloned.
  1667.         type PositiveImbalance: Imbalance<Self::Balance, Opposite = Self::NegativeImbalance>;
  1668.         /// The opaque token type for an imbalance. This is returned by unbalanced operations
  1669.         /// and must be dealt with. It may be dropped but cannot be cloned.
  1670.         type NegativeImbalance: Imbalance<Self::Balance, Opposite = Self::PositiveImbalance>;
  1671.         /// The combined balance of `who`.
  1672.         fn total_balance(who: &AccountId) -> Self::Balance;
  1673.         /// Same result as `slash(who, value)` (but without the side-effects) assuming there are no
  1674.         /// balance changes in the meantime and only the reserved balance is not taken into account.
  1675.         fn can_slash(who: &AccountId, value: Self::Balance) -> bool;
  1676.         /// The total amount of issuance in the system.
  1677.         fn total_issuance() -> Self::Balance;
  1678.         /// The minimum balance any single account may have. This is equivalent to the `Balances` module's
  1679.         /// `ExistentialDeposit`.
  1680.         fn minimum_balance() -> Self::Balance;
  1681.         /// The 'free' balance of a given account.
  1682.         ///
  1683.         /// This is the only balance that matters in terms of most operations on tokens. It alone
  1684.         /// is used to determine the balance when in the contract execution environment. When this
  1685.         /// balance falls below the value of `ExistentialDeposit`, then the 'current account' is
  1686.         /// deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback
  1687.         /// is invoked, giving a chance to external modules to clean up data associated with
  1688.         /// the deleted account.
  1689.         ///
  1690.         /// `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
  1691.         /// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
  1692.         fn free_balance(who: &AccountId) -> Self::Balance;
  1693.         /// Returns `Ok` iff the account is able to make a withdrawal of the given amount
  1694.         /// for the given reason. Basically, it's just a dry-run of `withdraw`.
  1695.         ///
  1696.         /// `Err(...)` with the reason why not otherwise.
  1697.         fn ensure_can_withdraw(
  1698.             who: &AccountId,
  1699.             _amount: Self::Balance,
  1700.             reason: WithdrawReason,
  1701.             new_balance: Self::Balance,
  1702.         ) -> result::Result<(), &'static str>;
  1703.        /// Transfer some liquid free balance to another staker.
  1704.        ///
  1705.        /// This is a very high-level function. It will ensure all appropriate fees are paid
  1706.        /// and no imbalance in the system remains.
  1707.        fn transfer(
  1708.            source: &AccountId,
  1709.            dest: &AccountId,
  1710.            value: Self::Balance,
  1711.        ) -> result::Result<(), &'static str>;
  1712.         /// Deducts up to `value` from the combined balance of `who`, preferring to deduct from the
  1713.         /// free balance. This function cannot fail.
  1714.         ///
  1715.         /// The resulting imbalance is the first item of the tuple returned.
  1716.         ///
  1717.         /// As much funds up to `value` will be deducted as possible. If this is less than `value`,
  1718.         /// then a non-zero second item will be returned.
  1719.         fn slash(who: &AccountId, value: Self::Balance)
  1720.             -> (Self::NegativeImbalance, Self::Balance);
  1721.         /// Mints `value` to the free balance of `who`.
  1722.         ///
  1723.         /// If `who` doesn't exist, nothing is done and an Err returned.
  1724.         fn deposit_into_existing(
  1725.             who: &AccountId,
  1726.             value: Self::Balance,
  1727.         ) -> result::Result<Self::PositiveImbalance, &'static str>;
  1728.        /// Removes some free balance from `who` account for `reason` if possible. If `liveness` is `KeepAlive`,
  1729.        /// then no less than `ExistentialDeposit` must be left remaining.
  1730.        ///
  1731.        /// This checks any locks, vesting, and liquidity requirements. If the removal is not possible, then it
  1732.        /// returns `Err`.
  1733.        fn withdraw(
  1734.            who: &AccountId,
  1735.            value: Self::Balance,
  1736.            reason: WithdrawReason,
  1737.            liveness: ExistenceRequirement,
  1738.        ) -> result::Result<Self::NegativeImbalance, &'static str>;
  1739.         /// Adds up to `value` to the free balance of `who`. If `who` doesn't exist, it is created.
  1740.         ///
  1741.         /// Infallible.
  1742.         fn deposit_creating(who: &AccountId, value: Self::Balance) -> Self::PositiveImbalance;
  1743.         /// Ensure an account's free balance equals some value; this will create the account
  1744.         /// if needed.
  1745.         ///
  1746.         /// Returns a signed imbalance and status to indicate if the account was successfully updated or update
  1747.         /// has led to killing of the account.
  1748.         fn make_free_balance_be(
  1749.             who: &AccountId,
  1750.             balance: Self::Balance,
  1751.         ) -> (
  1752.             SignedImbalance<Self::Balance, Self::PositiveImbalance>,
  1753.             UpdateBalanceOutcome,
  1754.         );
  1755.     }
  1756.     /// A currency where funds can be reserved from the user.
  1757.     pub trait ReservableCurrency<AccountId>: Currency<AccountId> {
  1758.         /// Same result as `reserve(who, value)` (but without the side-effects) assuming there
  1759.         /// are no balance changes in the meantime.
  1760.         fn can_reserve(who: &AccountId, value: Self::Balance) -> bool;
  1761.         /// Deducts up to `value` from reserved balance of `who`. This function cannot fail.
  1762.         ///
  1763.         /// As much funds up to `value` will be deducted as possible. If the reserve balance of `who`
  1764.         /// is less than `value`, then a non-zero second item will be returned.
  1765.         fn slash_reserved(
  1766.             who: &AccountId,
  1767.             value: Self::Balance,
  1768.         ) -> (Self::NegativeImbalance, Self::Balance);
  1769.         /// The amount of the balance of a given account that is externally reserved; this can still get
  1770.         /// slashed, but gets slashed last of all.
  1771.         ///
  1772.         /// This balance is a 'reserve' balance that other subsystems use in order to set aside tokens
  1773.         /// that are still 'owned' by the account holder, but which are suspendable.
  1774.         ///
  1775.         /// When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account'
  1776.         /// is deleted: specifically, `ReservedBalance`.
  1777.         ///
  1778.         /// `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
  1779.         /// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
  1780.         fn reserved_balance(who: &AccountId) -> Self::Balance;
  1781.         /// Moves `value` from balance to reserved balance.
  1782.         ///
  1783.         /// If the free balance is lower than `value`, then no funds will be moved and an `Err` will
  1784.         /// be returned to notify of this. This is different behavior than `unreserve`.
  1785.         fn reserve(who: &AccountId, value: Self::Balance) -> result::Result<(), &'static str>;
  1786.        /// Moves up to `value` from reserved balance to free balance. This function cannot fail.
  1787.        ///
  1788.        /// As much funds up to `value` will be moved as possible. If the reserve balance of `who`
  1789.        /// is less than `value`, then the remaining amount will be returned.
  1790.        ///
  1791.        /// # NOTES
  1792.        ///
  1793.        /// - This is different from `reserve`.
  1794.        /// - If the remaining reserved balance is less than `ExistentialDeposit`, it will
  1795.        /// invoke `on_reserved_too_low` and could reap the account.
  1796.        fn unreserve(who: &AccountId, value: Self::Balance) -> Self::Balance;
  1797.        /// Moves up to `value` from reserved balance of account `slashed` to free balance of account
  1798.        /// `beneficiary`. `beneficiary` must exist for this to succeed. If it does not, `Err` will be
  1799.        /// returned.
  1800.        ///
  1801.        /// As much funds up to `value` will be deducted as possible. If this is less than `value`,
  1802.        /// then `Ok(non_zero)` will be returned.
  1803.        fn repatriate_reserved(
  1804.            slashed: &AccountId,
  1805.            beneficiary: &AccountId,
  1806.            value: Self::Balance,
  1807.        ) -> result::Result<Self::Balance, &'static str>;
  1808.     }
  1809.     /// An identifier for a lock. Used for disambiguating different locks so that
  1810.     /// they can be individually replaced or removed.
  1811.     pub type LockIdentifier = [u8; 8];
  1812.     /// A currency whose accounts can have liquidity restrictions.
  1813.     pub trait LockableCurrency<AccountId>: Currency<AccountId> {
  1814.         /// The quantity used to denote time; usually just a `BlockNumber`.
  1815.         type Moment;
  1816.         /// Create a new balance lock on account `who`.
  1817.         ///
  1818.         /// If the new lock is valid (i.e. not already expired), it will push the struct to
  1819.         /// the `Locks` vec in storage. Note that you can lock more funds than a user has.
  1820.         ///
  1821.         /// If the lock `id` already exists, this will update it.
  1822.         fn set_lock(
  1823.             id: LockIdentifier,
  1824.             who: &AccountId,
  1825.             amount: Self::Balance,
  1826.             until: Self::Moment,
  1827.             reasons: WithdrawReasons,
  1828.         );
  1829.         /// Changes a balance lock (selected by `id`) so that it becomes less liquid in all
  1830.         /// parameters or creates a new one if it does not exist.
  1831.         ///
  1832.         /// Calling `extend_lock` on an existing lock `id` differs from `set_lock` in that it
  1833.         /// applies the most severe constraints of the two, while `set_lock` replaces the lock
  1834.         /// with the new parameters. As in, `extend_lock` will set:
  1835.         /// - maximum `amount`
  1836.         /// - farthest duration (`until`)
  1837.         /// - bitwise mask of all `reasons`
  1838.         fn extend_lock(
  1839.             id: LockIdentifier,
  1840.             who: &AccountId,
  1841.             amount: Self::Balance,
  1842.             until: Self::Moment,
  1843.             reasons: WithdrawReasons,
  1844.         );
  1845.         /// Remove an existing lock.
  1846.         fn remove_lock(id: LockIdentifier, who: &AccountId);
  1847.     }
  1848.     #[repr(i8)]
  1849.     #[allow(dead_code)]
  1850.     /// Reason for moving funds out of an account.
  1851.     #[structural_match]
  1852.     #[rustc_copy_clone_marker]
  1853.     pub enum WithdrawReason {
  1854.         /// In order to pay for (system) transaction costs.
  1855.         TransactionPayment = 1,
  1856.         /// In order to transfer ownership.
  1857.         Transfer = 2,
  1858.         /// In order to reserve some funds for a later return or repatriation
  1859.         Reserve = 4,
  1860.         /// In order to pay some other (higher-level) fees.
  1861.         Fee = 8,
  1862.     }
  1863.     #[automatically_derived]
  1864.     #[allow(unused_qualifications)]
  1865.     #[allow(dead_code)]
  1866.     impl ::std::marker::Copy for WithdrawReason {}
  1867.     #[automatically_derived]
  1868.     #[allow(unused_qualifications)]
  1869.     #[allow(dead_code)]
  1870.     impl ::std::clone::Clone for WithdrawReason {
  1871.         #[inline]
  1872.         fn clone(&self) -> WithdrawReason {
  1873.             {
  1874.                 *self
  1875.             }
  1876.         }
  1877.     }
  1878.     #[automatically_derived]
  1879.     #[allow(unused_qualifications)]
  1880.     #[allow(dead_code)]
  1881.     impl ::std::cmp::Eq for WithdrawReason {
  1882.         #[inline]
  1883.         #[doc(hidden)]
  1884.         fn assert_receiver_is_total_eq(&self) -> () {
  1885.             {}
  1886.         }
  1887.     }
  1888.     #[automatically_derived]
  1889.     #[allow(unused_qualifications)]
  1890.     #[allow(dead_code)]
  1891.     impl ::std::cmp::PartialEq for WithdrawReason {
  1892.         #[inline]
  1893.         fn eq(&self, other: &WithdrawReason) -> bool {
  1894.             {
  1895.                 let __self_vi = unsafe { ::std::intrinsics::discriminant_value(&*self) } as i8;
  1896.                 let __arg_1_vi = unsafe { ::std::intrinsics::discriminant_value(&*other) } as i8;
  1897.                 if true && __self_vi == __arg_1_vi {
  1898.                     match (&*self, &*other) {
  1899.                         _ => true,
  1900.                     }
  1901.                 } else {
  1902.                     false
  1903.                 }
  1904.             }
  1905.         }
  1906.     }
  1907.     #[automatically_derived]
  1908.     #[allow(unused_qualifications)]
  1909.     #[allow(dead_code)]
  1910.     impl ::std::cmp::Ord for WithdrawReason {
  1911.         #[inline]
  1912.         fn cmp(&self, other: &WithdrawReason) -> ::std::cmp::Ordering {
  1913.             {
  1914.                 let __self_vi = unsafe { ::std::intrinsics::discriminant_value(&*self) } as i8;
  1915.                 let __arg_1_vi = unsafe { ::std::intrinsics::discriminant_value(&*other) } as i8;
  1916.                 if true && __self_vi == __arg_1_vi {
  1917.                     match (&*self, &*other) {
  1918.                         _ => ::std::cmp::Ordering::Equal,
  1919.                     }
  1920.                 } else {
  1921.                     __self_vi.cmp(&__arg_1_vi)
  1922.                 }
  1923.             }
  1924.         }
  1925.     }
  1926.     #[automatically_derived]
  1927.     #[allow(unused_qualifications)]
  1928.     #[allow(dead_code)]
  1929.     impl ::std::cmp::PartialOrd for WithdrawReason {
  1930.         #[inline]
  1931.         fn partial_cmp(
  1932.             &self,
  1933.             other: &WithdrawReason,
  1934.         ) -> ::std::option::Option<::std::cmp::Ordering> {
  1935.             {
  1936.                 let __self_vi = unsafe { ::std::intrinsics::discriminant_value(&*self) } as i8;
  1937.                 let __arg_1_vi = unsafe { ::std::intrinsics::discriminant_value(&*other) } as i8;
  1938.                 if true && __self_vi == __arg_1_vi {
  1939.                     match (&*self, &*other) {
  1940.                         _ => ::std::option::Option::Some(::std::cmp::Ordering::Equal),
  1941.                     }
  1942.                 } else {
  1943.                     __self_vi.partial_cmp(&__arg_1_vi)
  1944.                 }
  1945.             }
  1946.         }
  1947.     }
  1948.     #[automatically_derived]
  1949.     #[allow(unused_qualifications)]
  1950.     #[allow(dead_code)]
  1951.     impl ::std::fmt::Debug for WithdrawReason {
  1952.         fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
  1953.             match (&*self,) {
  1954.                 (&WithdrawReason::TransactionPayment,) => {
  1955.                     let mut debug_trait_builder = f.debug_tuple("TransactionPayment");
  1956.                     debug_trait_builder.finish()
  1957.                 }
  1958.                 (&WithdrawReason::Transfer,) => {
  1959.                     let mut debug_trait_builder = f.debug_tuple("Transfer");
  1960.                     debug_trait_builder.finish()
  1961.                 }
  1962.                 (&WithdrawReason::Reserve,) => {
  1963.                     let mut debug_trait_builder = f.debug_tuple("Reserve");
  1964.                     debug_trait_builder.finish()
  1965.                 }
  1966.                 (&WithdrawReason::Fee,) => {
  1967.                     let mut debug_trait_builder = f.debug_tuple("Fee");
  1968.                     debug_trait_builder.finish()
  1969.                 }
  1970.             }
  1971.         }
  1972.     }
  1973.     #[automatically_derived]
  1974.     #[allow(unused_qualifications)]
  1975.     #[allow(dead_code)]
  1976.     impl ::std::hash::Hash for WithdrawReason {
  1977.         fn hash<__H: ::std::hash::Hasher>(&self, state: &mut __H) -> () {
  1978.             match (&*self,) {
  1979.                 _ => ::std::hash::Hash::hash(
  1980.                     &unsafe { ::std::intrinsics::discriminant_value(self) },
  1981.                     state,
  1982.                 ),
  1983.             }
  1984.         }
  1985.     }
  1986.     #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
  1987.     const _IMPL_ENCODE_FOR_WithdrawReason: () = {
  1988.         #[allow(unknown_lints)]
  1989.         #[allow(rust_2018_idioms)]
  1990.         extern crate codec as _parity_codec;
  1991.         impl _parity_codec::Encode for WithdrawReason {
  1992.             fn encode_to<EncOut: _parity_codec::Output>(&self, dest: &mut EncOut) {
  1993.                 match *self {
  1994.                     WithdrawReason::TransactionPayment => {
  1995.                         dest.push_byte(1 as u8);
  1996.                     }
  1997.                     WithdrawReason::Transfer => {
  1998.                         dest.push_byte(2 as u8);
  1999.                     }
  2000.                     WithdrawReason::Reserve => {
  2001.                         dest.push_byte(4 as u8);
  2002.                     }
  2003.                     WithdrawReason::Fee => {
  2004.                         dest.push_byte(8 as u8);
  2005.                     }
  2006.                     _ => (),
  2007.                 }
  2008.             }
  2009.         }
  2010.     };
  2011.     #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
  2012.     const _IMPL_DECODE_FOR_WithdrawReason: () = {
  2013.         #[allow(unknown_lints)]
  2014.         #[allow(rust_2018_idioms)]
  2015.         extern crate codec as _parity_codec;
  2016.         impl _parity_codec::Decode for WithdrawReason {
  2017.             fn decode<DecIn: _parity_codec::Input>(input: &mut DecIn) -> Option<Self> {
  2018.                 match input.read_byte()? {
  2019.                     x if x == 1 as u8 => Some(WithdrawReason::TransactionPayment),
  2020.                     x if x == 2 as u8 => Some(WithdrawReason::Transfer),
  2021.                     x if x == 4 as u8 => Some(WithdrawReason::Reserve),
  2022.                     x if x == 8 as u8 => Some(WithdrawReason::Fee),
  2023.                     _ => None,
  2024.                 }
  2025.             }
  2026.         }
  2027.     };
  2028.     #[allow(dead_code)]
  2029.     /// Reasons for moving funds out of an account.
  2030.     #[structural_match]
  2031.     #[rustc_copy_clone_marker]
  2032.     pub struct WithdrawReasons {
  2033.         mask: i8,
  2034.     }
  2035.     #[automatically_derived]
  2036.     #[allow(unused_qualifications)]
  2037.     #[allow(dead_code)]
  2038.     impl ::std::marker::Copy for WithdrawReasons {}
  2039.     #[automatically_derived]
  2040.     #[allow(unused_qualifications)]
  2041.     #[allow(dead_code)]
  2042.     impl ::std::clone::Clone for WithdrawReasons {
  2043.         #[inline]
  2044.         fn clone(&self) -> WithdrawReasons {
  2045.             {
  2046.                 let _: ::std::clone::AssertParamIsClone<i8>;
  2047.                 *self
  2048.             }
  2049.         }
  2050.     }
  2051.     #[automatically_derived]
  2052.     #[allow(unused_qualifications)]
  2053.     #[allow(dead_code)]
  2054.     impl ::std::cmp::Eq for WithdrawReasons {
  2055.         #[inline]
  2056.         #[doc(hidden)]
  2057.         fn assert_receiver_is_total_eq(&self) -> () {
  2058.             {
  2059.                 let _: ::std::cmp::AssertParamIsEq<i8>;
  2060.             }
  2061.         }
  2062.     }
  2063.     #[automatically_derived]
  2064.     #[allow(unused_qualifications)]
  2065.     #[allow(dead_code)]
  2066.     impl ::std::cmp::PartialEq for WithdrawReasons {
  2067.         #[inline]
  2068.         fn eq(&self, other: &WithdrawReasons) -> bool {
  2069.             match *other {
  2070.                 WithdrawReasons {
  2071.                     mask: ref __self_1_0,
  2072.                 } => match *self {
  2073.                     WithdrawReasons {
  2074.                         mask: ref __self_0_0,
  2075.                     } => (*__self_0_0) == (*__self_1_0),
  2076.                 },
  2077.             }
  2078.         }
  2079.         #[inline]
  2080.         fn ne(&self, other: &WithdrawReasons) -> bool {
  2081.             match *other {
  2082.                 WithdrawReasons {
  2083.                     mask: ref __self_1_0,
  2084.                 } => match *self {
  2085.                     WithdrawReasons {
  2086.                         mask: ref __self_0_0,
  2087.                     } => (*__self_0_0) != (*__self_1_0),
  2088.                 },
  2089.             }
  2090.         }
  2091.     }
  2092.     #[automatically_derived]
  2093.     #[allow(unused_qualifications)]
  2094.     #[allow(dead_code)]
  2095.     impl ::std::cmp::Ord for WithdrawReasons {
  2096.         #[inline]
  2097.         fn cmp(&self, other: &WithdrawReasons) -> ::std::cmp::Ordering {
  2098.             match *other {
  2099.                 WithdrawReasons {
  2100.                     mask: ref __self_1_0,
  2101.                 } => match *self {
  2102.                     WithdrawReasons {
  2103.                         mask: ref __self_0_0,
  2104.                     } => match ::std::cmp::Ord::cmp(&(*__self_0_0), &(*__self_1_0)) {
  2105.                         ::std::cmp::Ordering::Equal => ::std::cmp::Ordering::Equal,
  2106.                         cmp => cmp,
  2107.                     },
  2108.                 },
  2109.             }
  2110.         }
  2111.     }
  2112.     #[automatically_derived]
  2113.     #[allow(unused_qualifications)]
  2114.     #[allow(dead_code)]
  2115.     impl ::std::cmp::PartialOrd for WithdrawReasons {
  2116.         #[inline]
  2117.         fn partial_cmp(
  2118.             &self,
  2119.             other: &WithdrawReasons,
  2120.         ) -> ::std::option::Option<::std::cmp::Ordering> {
  2121.             match *other {
  2122.                 WithdrawReasons {
  2123.                     mask: ref __self_1_0,
  2124.                 } => match *self {
  2125.                     WithdrawReasons {
  2126.                         mask: ref __self_0_0,
  2127.                     } => {
  2128.                         match ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)) {
  2129.                             ::std::option::Option::Some(::std::cmp::Ordering::Equal) => {
  2130.                                 ::std::option::Option::Some(::std::cmp::Ordering::Equal)
  2131.                             }
  2132.                             cmp => cmp,
  2133.                         }
  2134.                     }
  2135.                 },
  2136.             }
  2137.         }
  2138.         #[inline]
  2139.         fn lt(&self, other: &WithdrawReasons) -> bool {
  2140.             match *other {
  2141.                 WithdrawReasons {
  2142.                     mask: ref __self_1_0,
  2143.                 } => match *self {
  2144.                     WithdrawReasons {
  2145.                         mask: ref __self_0_0,
  2146.                     } => {
  2147.                         ::std::option::Option::unwrap_or(
  2148.                             ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)),
  2149.                             ::std::cmp::Ordering::Greater,
  2150.                         ) == ::std::cmp::Ordering::Less
  2151.                     }
  2152.                 },
  2153.             }
  2154.         }
  2155.         #[inline]
  2156.         fn le(&self, other: &WithdrawReasons) -> bool {
  2157.             match *other {
  2158.                 WithdrawReasons {
  2159.                     mask: ref __self_1_0,
  2160.                 } => match *self {
  2161.                     WithdrawReasons {
  2162.                         mask: ref __self_0_0,
  2163.                     } => {
  2164.                         ::std::option::Option::unwrap_or(
  2165.                             ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)),
  2166.                             ::std::cmp::Ordering::Greater,
  2167.                         ) != ::std::cmp::Ordering::Greater
  2168.                     }
  2169.                 },
  2170.             }
  2171.         }
  2172.         #[inline]
  2173.         fn gt(&self, other: &WithdrawReasons) -> bool {
  2174.             match *other {
  2175.                 WithdrawReasons {
  2176.                     mask: ref __self_1_0,
  2177.                 } => match *self {
  2178.                     WithdrawReasons {
  2179.                         mask: ref __self_0_0,
  2180.                     } => {
  2181.                         ::std::option::Option::unwrap_or(
  2182.                             ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)),
  2183.                             ::std::cmp::Ordering::Less,
  2184.                         ) == ::std::cmp::Ordering::Greater
  2185.                     }
  2186.                 },
  2187.             }
  2188.         }
  2189.         #[inline]
  2190.         fn ge(&self, other: &WithdrawReasons) -> bool {
  2191.             match *other {
  2192.                 WithdrawReasons {
  2193.                     mask: ref __self_1_0,
  2194.                 } => match *self {
  2195.                     WithdrawReasons {
  2196.                         mask: ref __self_0_0,
  2197.                     } => {
  2198.                         ::std::option::Option::unwrap_or(
  2199.                             ::std::cmp::PartialOrd::partial_cmp(&(*__self_0_0), &(*__self_1_0)),
  2200.                             ::std::cmp::Ordering::Less,
  2201.                         ) != ::std::cmp::Ordering::Less
  2202.                     }
  2203.                 },
  2204.             }
  2205.         }
  2206.     }
  2207.     #[automatically_derived]
  2208.     #[allow(unused_qualifications)]
  2209.     #[allow(dead_code)]
  2210.     impl ::std::fmt::Debug for WithdrawReasons {
  2211.         fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
  2212.             match *self {
  2213.                 WithdrawReasons {
  2214.                     mask: ref __self_0_0,
  2215.                 } => {
  2216.                     let mut debug_trait_builder = f.debug_struct("WithdrawReasons");
  2217.                     let _ = debug_trait_builder.field("mask", &&(*__self_0_0));
  2218.                     debug_trait_builder.finish()
  2219.                 }
  2220.             }
  2221.         }
  2222.     }
  2223.     #[automatically_derived]
  2224.     #[allow(unused_qualifications)]
  2225.     #[allow(dead_code)]
  2226.     impl ::std::hash::Hash for WithdrawReasons {
  2227.         fn hash<__H: ::std::hash::Hasher>(&self, state: &mut __H) -> () {
  2228.             match *self {
  2229.                 WithdrawReasons {
  2230.                     mask: ref __self_0_0,
  2231.                 } => ::std::hash::Hash::hash(&(*__self_0_0), state),
  2232.             }
  2233.         }
  2234.     }
  2235.     #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
  2236.     const _IMPL_ENCODE_FOR_WithdrawReasons: () = {
  2237.         #[allow(unknown_lints)]
  2238.         #[allow(rust_2018_idioms)]
  2239.         extern crate codec as _parity_codec;
  2240.         impl _parity_codec::Encode for WithdrawReasons {
  2241.             fn encode_to<EncOut: _parity_codec::Output>(&self, dest: &mut EncOut) {
  2242.                 dest.push(&self.mask);
  2243.             }
  2244.         }
  2245.     };
  2246.     #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
  2247.     const _IMPL_DECODE_FOR_WithdrawReasons: () = {
  2248.         #[allow(unknown_lints)]
  2249.         #[allow(rust_2018_idioms)]
  2250.         extern crate codec as _parity_codec;
  2251.         impl _parity_codec::Decode for WithdrawReasons {
  2252.             fn decode<DecIn: _parity_codec::Input>(input: &mut DecIn) -> Option<Self> {
  2253.                 Some(WithdrawReasons {
  2254.                     mask: _parity_codec::Decode::decode(input)?,
  2255.                 })
  2256.             }
  2257.         }
  2258.     };
  2259.     #[allow(dead_code)]
  2260.     impl WithdrawReasons {
  2261.         /// Create a new mask with all flags unset.
  2262.         #[inline]
  2263.         pub fn none() -> Self {
  2264.             WithdrawReasons { mask: 0 }
  2265.         }
  2266.         /// Create a new mask with all flags set.
  2267.         #[inline]
  2268.         pub fn all() -> Self {
  2269.             WithdrawReasons {
  2270.                 mask: 1 | 2 | 4 | 8,
  2271.             }
  2272.         }
  2273.         /// Set all `other` flags.
  2274.         ///
  2275.         /// `other` can be either a single flag or another mask.
  2276.         #[inline]
  2277.         pub fn set<T>(&mut self, other: T)
  2278.         where
  2279.             T: Into<WithdrawReasons> + ::bitmask::__core::ops::Deref<Target = i8>,
  2280.         {
  2281.             self.mask |= *other;
  2282.         }
  2283.         /// Unset all `other` flags.
  2284.         ///
  2285.         /// `other` can be either a single flag or another mask.
  2286.         #[inline]
  2287.         pub fn unset<T>(&mut self, other: T)
  2288.         where
  2289.             T: Into<WithdrawReasons> + ::bitmask::__core::ops::Deref<Target = i8>,
  2290.         {
  2291.             self.mask &= Self::all().mask ^ *other;
  2292.         }
  2293.         /// Toggle all `other` flags.
  2294.         ///
  2295.         /// `other` can be either a single flag or another mask.
  2296.         #[inline]
  2297.         pub fn toggle<T>(&mut self, other: T)
  2298.         where
  2299.             T: Into<WithdrawReasons> + ::bitmask::__core::ops::Deref<Target = i8>,
  2300.         {
  2301.             self.mask ^= *other;
  2302.         }
  2303.         /// Check if the mask contains all of `other`'s flags.
  2304.         ///
  2305.         /// `other` can be either a single flag or another mask.
  2306.         #[inline]
  2307.         pub fn contains<T>(&self, other: T) -> bool
  2308.         where
  2309.             T: Into<WithdrawReasons> + ::bitmask::__core::ops::Deref<Target = i8>,
  2310.         {
  2311.             self.mask & *other == *other
  2312.         }
  2313.         /// Check if the mask has common flags with `other`.
  2314.         ///
  2315.         /// `other` can be either a single flag or another mask.
  2316.         #[inline]
  2317.         pub fn intersects<T>(&self, other: T) -> bool
  2318.         where
  2319.             T: Into<WithdrawReasons> + ::bitmask::__core::ops::Deref<Target = i8>,
  2320.         {
  2321.             self.mask & *other != 0
  2322.         }
  2323.         /// Check if all flags are set.
  2324.         pub fn is_all(&self) -> bool {
  2325.             self.mask == Self::all().mask
  2326.         }
  2327.         /// Check if all flags are unset.
  2328.         pub fn is_none(&self) -> bool {
  2329.             self.mask == 0
  2330.         }
  2331.     }
  2332.     impl ::bitmask::__core::convert::From<WithdrawReason> for WithdrawReasons {
  2333.         /// Create a mask from a single flag.
  2334.         ///
  2335.         /// When creating a mask from multiple flags or another mask just use the `clone` method
  2336.         /// or the `copy` semantics.
  2337.         #[inline]
  2338.         fn from(flag: WithdrawReason) -> Self {
  2339.             WithdrawReasons { mask: flag as i8 }
  2340.         }
  2341.     }
  2342.     impl ::bitmask::__core::ops::Deref for WithdrawReasons {
  2343.         type Target = i8;
  2344.         /// Deref to the internal type.
  2345.         ///
  2346.         /// Useful for FFI.
  2347.         #[inline]
  2348.         fn deref(&self) -> &i8 {
  2349.             &self.mask as &i8
  2350.         }
  2351.     }
  2352.     impl ::bitmask::__core::ops::Deref for WithdrawReason {
  2353.         type Target = i8;
  2354.         /// Deref to the internal type.
  2355.         ///
  2356.         /// Useful for FFI.
  2357.         #[inline]
  2358.         fn deref(&self) -> &i8 {
  2359.             unsafe { ::bitmask::__core::mem::transmute(self) }
  2360.         }
  2361.     }
  2362.     impl ::bitmask::__core::ops::BitOr<WithdrawReasons> for WithdrawReasons {
  2363.         type Output = WithdrawReasons;
  2364.         #[inline]
  2365.         fn bitor(self, other: WithdrawReasons) -> Self::Output {
  2366.             WithdrawReasons {
  2367.                 mask: *self | *other,
  2368.             }
  2369.         }
  2370.     }
  2371.     impl ::bitmask::__core::ops::BitOr<WithdrawReason> for WithdrawReasons {
  2372.         type Output = WithdrawReasons;
  2373.         #[inline]
  2374.         fn bitor(self, other: WithdrawReason) -> Self::Output {
  2375.             WithdrawReasons {
  2376.                 mask: *self | *other,
  2377.             }
  2378.         }
  2379.     }
  2380.     impl ::bitmask::__core::ops::BitOr<WithdrawReasons> for WithdrawReason {
  2381.         type Output = WithdrawReasons;
  2382.         #[inline]
  2383.         fn bitor(self, other: WithdrawReasons) -> Self::Output {
  2384.             WithdrawReasons {
  2385.                 mask: *self | *other,
  2386.             }
  2387.         }
  2388.     }
  2389.     impl ::bitmask::__core::ops::BitOr<WithdrawReason> for WithdrawReason {
  2390.         type Output = WithdrawReasons;
  2391.         #[inline]
  2392.         fn bitor(self, other: WithdrawReason) -> Self::Output {
  2393.             WithdrawReasons {
  2394.                 mask: *self | *other,
  2395.             }
  2396.         }
  2397.     }
  2398.     impl ::bitmask::__core::ops::BitAnd<WithdrawReasons> for WithdrawReasons {
  2399.         type Output = WithdrawReasons;
  2400.         #[inline]
  2401.         fn bitand(self, other: WithdrawReasons) -> Self::Output {
  2402.             WithdrawReasons {
  2403.                 mask: *self & *other,
  2404.             }
  2405.         }
  2406.     }
  2407.     impl ::bitmask::__core::ops::BitAnd<WithdrawReason> for WithdrawReasons {
  2408.         type Output = WithdrawReasons;
  2409.         #[inline]
  2410.         fn bitand(self, other: WithdrawReason) -> Self::Output {
  2411.             WithdrawReasons {
  2412.                 mask: *self & *other,
  2413.             }
  2414.         }
  2415.     }
  2416.     impl ::bitmask::__core::ops::BitAnd<WithdrawReasons> for WithdrawReason {
  2417.         type Output = WithdrawReasons;
  2418.         #[inline]
  2419.         fn bitand(self, other: WithdrawReasons) -> Self::Output {
  2420.             WithdrawReasons {
  2421.                 mask: *self & *other,
  2422.             }
  2423.         }
  2424.     }
  2425.     impl ::bitmask::__core::ops::BitAnd<WithdrawReason> for WithdrawReason {
  2426.         type Output = WithdrawReasons;
  2427.         #[inline]
  2428.         fn bitand(self, other: WithdrawReason) -> Self::Output {
  2429.             WithdrawReasons {
  2430.                 mask: *self & *other,
  2431.             }
  2432.         }
  2433.     }
  2434.     impl ::bitmask::__core::ops::BitXor<WithdrawReasons> for WithdrawReasons {
  2435.         type Output = WithdrawReasons;
  2436.         #[inline]
  2437.         fn bitxor(self, other: WithdrawReasons) -> Self::Output {
  2438.             WithdrawReasons {
  2439.                 mask: *self ^ *other,
  2440.             }
  2441.         }
  2442.     }
  2443.     impl ::bitmask::__core::ops::BitXor<WithdrawReason> for WithdrawReasons {
  2444.         type Output = WithdrawReasons;
  2445.         #[inline]
  2446.         fn bitxor(self, other: WithdrawReason) -> Self::Output {
  2447.             WithdrawReasons {
  2448.                 mask: *self ^ *other,
  2449.             }
  2450.         }
  2451.     }
  2452.     impl ::bitmask::__core::ops::BitXor<WithdrawReasons> for WithdrawReason {
  2453.         type Output = WithdrawReasons;
  2454.         #[inline]
  2455.         fn bitxor(self, other: WithdrawReasons) -> Self::Output {
  2456.             WithdrawReasons {
  2457.                 mask: *self ^ *other,
  2458.             }
  2459.         }
  2460.     }
  2461.     impl ::bitmask::__core::ops::BitXor<WithdrawReason> for WithdrawReason {
  2462.         type Output = WithdrawReasons;
  2463.         #[inline]
  2464.         fn bitxor(self, other: WithdrawReason) -> Self::Output {
  2465.             WithdrawReasons {
  2466.                 mask: *self ^ *other,
  2467.             }
  2468.         }
  2469.     }
  2470.     impl ::bitmask::__core::ops::BitOrAssign<WithdrawReasons> for WithdrawReasons {
  2471.         #[inline]
  2472.         fn bitor_assign(&mut self, other: WithdrawReasons) {
  2473.             self.mask |= *other
  2474.         }
  2475.     }
  2476.     impl ::bitmask::__core::ops::BitOrAssign<WithdrawReason> for WithdrawReasons {
  2477.         #[inline]
  2478.         fn bitor_assign(&mut self, other: WithdrawReason) {
  2479.             self.mask |= *other
  2480.         }
  2481.     }
  2482.     impl ::bitmask::__core::ops::BitAndAssign<WithdrawReasons> for WithdrawReasons {
  2483.         #[inline]
  2484.         fn bitand_assign(&mut self, other: WithdrawReasons) {
  2485.             self.mask &= *other
  2486.         }
  2487.     }
  2488.     impl ::bitmask::__core::ops::BitAndAssign<WithdrawReason> for WithdrawReasons {
  2489.         #[inline]
  2490.         fn bitand_assign(&mut self, other: WithdrawReason) {
  2491.             self.mask &= *other
  2492.         }
  2493.     }
  2494.     impl ::bitmask::__core::ops::BitXorAssign<WithdrawReasons> for WithdrawReasons {
  2495.         #[inline]
  2496.         fn bitxor_assign(&mut self, other: WithdrawReasons) {
  2497.             self.mask ^= *other
  2498.         }
  2499.     }
  2500.     impl ::bitmask::__core::ops::BitXorAssign<WithdrawReason> for WithdrawReasons {
  2501.         #[inline]
  2502.         fn bitxor_assign(&mut self, other: WithdrawReason) {
  2503.             self.mask ^= *other
  2504.         }
  2505.     }
  2506.     impl ::bitmask::__core::ops::Not for WithdrawReasons {
  2507.         type Output = WithdrawReasons;
  2508.         #[inline]
  2509.         fn not(self) -> Self::Output {
  2510.             let all_flags = WithdrawReasons::all();
  2511.             WithdrawReasons {
  2512.                 mask: *all_flags ^ *self,
  2513.             }
  2514.         }
  2515.     }
  2516.     impl ::bitmask::__core::ops::Not for WithdrawReason {
  2517.         type Output = WithdrawReasons;
  2518.         #[inline]
  2519.         fn not(self) -> Self::Output {
  2520.             let all_flags = WithdrawReasons::all();
  2521.             WithdrawReasons {
  2522.                 mask: *all_flags ^ *self,
  2523.             }
  2524.         }
  2525.     }
  2526. }
  2527. pub use self::dispatch::{Callable, Dispatchable, IsSubType, Parameter};
  2528. pub use self::double_map::StorageDoubleMapWithHasher;
  2529. pub use self::hashable::Hashable;
  2530. pub use self::storage::{
  2531.     AppendableStorageMap, EnumerableStorageMap, StorageDoubleMap, StorageMap, StorageValue,
  2532. };
  2533. pub use runtime_io::{print, storage_root};
  2534. #[doc(inline)]
  2535. pub use srml_support_procedural::decl_storage;
  2536. /// The void type - it cannot exist.
  2537. #[structural_match]
  2538. pub enum Void {}
  2539. #[automatically_derived]
  2540. #[allow(unused_qualifications)]
  2541. impl ::std::clone::Clone for Void {
  2542.     #[inline]
  2543.     fn clone(&self) -> Void {
  2544.         unsafe { ::std::intrinsics::unreachable() }
  2545.     }
  2546. }
  2547. #[automatically_derived]
  2548. #[allow(unused_qualifications)]
  2549. impl ::std::cmp::Eq for Void {
  2550.     #[inline]
  2551.     #[doc(hidden)]
  2552.     fn assert_receiver_is_total_eq(&self) -> () {
  2553.         {}
  2554.     }
  2555. }
  2556. #[automatically_derived]
  2557. #[allow(unused_qualifications)]
  2558. impl ::std::cmp::PartialEq for Void {
  2559.     #[inline]
  2560.     fn eq(&self, other: &Void) -> bool {
  2561.         unsafe { ::std::intrinsics::unreachable() }
  2562.     }
  2563. }
  2564. #[automatically_derived]
  2565. #[allow(unused_qualifications)]
  2566. impl ::std::fmt::Debug for Void {
  2567.     fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
  2568.         unsafe { ::std::intrinsics::unreachable() }
  2569.     }
  2570. }
  2571. #[cfg(feature = "std")]
  2572. #[doc(hidden)]
  2573. pub use serde::{Deserialize, Serialize};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement