>;
/// Extract the state backend type for a type that implements `ProvideRuntimeApi`.
#[cfg(feature = "std")]
pub type StateBackendFor =
<
>::Api as ApiExt>::StateBackend;
/// Extract the state backend transaction type for a type that implements `ProvideRuntimeApi`.
#[cfg(feature = "std")]
pub type TransactionFor =
as StateBackend>>::Transaction;
/// Something that can be constructed to a runtime api.
#[cfg(feature = "std")]
pub trait ConstructRuntimeApi> {
/// The actual runtime api that will be constructed.
type RuntimeApi: ApiExt;
/// Construct an instance of the runtime api.
fn construct_runtime_api<'a>(call: &'a C) -> ApiRef<'a, Self::RuntimeApi>;
}
/// Extends the runtime api traits with an associated error type. This trait is given as super
/// trait to every runtime api trait.
#[cfg(feature = "std")]
pub trait ApiErrorExt {
/// Error type used by the runtime apis.
type Error: std::fmt::Debug + From;
}
/// Extends the runtime api implementation with some common functionality.
#[cfg(feature = "std")]
pub trait ApiExt: ApiErrorExt {
/// The state backend that is used to store the block states.
type StateBackend: StateBackend>;
/// The given closure will be called with api instance. Inside the closure any api call is
/// allowed. After doing the api call, the closure is allowed to map the `Result` to a
/// different `Result` type. This can be important, as the internal data structure that keeps
/// track of modifications to the storage, discards changes when the `Result` is an `Err`.
/// On `Ok`, the structure commits the changes to an internal buffer.
fn map_api_result result::Result, R, E>(
&self,
map_call: F,
) -> result::Result where Self: Sized;
/// Checks if the given api is implemented and versions match.
fn has_api(
&self,
at: &BlockId,
) -> Result where Self: Sized;
/// Check if the given api is implemented and the version passes a predicate.
fn has_api_with bool>(
&self,
at: &BlockId,
pred: P,
) -> Result where Self: Sized;
/// Start recording all accessed trie nodes for generating proofs.
fn record_proof(&mut self);
/// Extract the recorded proof.
///
/// This stops the proof recording.
///
/// If `record_proof` was not called before, this will return `None`.
fn extract_proof(&mut self) -> Option;
/// Convert the api object into the storage changes that were done while executing runtime
/// api functions.
///
/// After executing this function, all collected changes are reset.
fn into_storage_changes(
&self,
backend: &Self::StateBackend,
changes_trie_state: Option<&ChangesTrieState, NumberFor>>,
parent_hash: Block::Hash,
) -> Result, String> where Self: Sized;
}
/// Before calling any runtime api function, the runtime need to be initialized
/// at the requested block. However, some functions like `execute_block` or
/// `initialize_block` itself don't require to have the runtime initialized
/// at the requested block.
///
/// `call_api_at` is instructed by this enum to do the initialization or to skip
/// it.
#[cfg(feature = "std")]
#[derive(Clone, Copy)]
pub enum InitializeBlock<'a, Block: BlockT> {
/// Skip initializing the runtime for a given block.
///
/// This is used by functions who do the initialization by themselves or don't require it.
Skip,
/// Initialize the runtime for a given block.
///
/// If the stored `BlockId` is `Some(_)`, the runtime is currently initialized at this block.
Do(&'a RefCell