mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
add doc-only substrate entry point crate (#14581)
* add doc-only substrate entry point crate * document a few more things * add more * fix width * Update primitives/io/src/lib.rs Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> * add link * update cargo toml file * fix sp-io docs * improve * small update * add license * satisfy license job * add a line about FRAME * CI happy now * make CI more happy * Let the check run for the whole workspace * Forward the substrate node again as default run * update binary names * upate verison test * Fix fix fix * Fix * rename to substrate-node in more places * Revert "rename to substrate-node in more places" This reverts commit 66960f84a1b6f1f7c638b4040e28e9fbabb8adf5. * fix * Fix build pipeline * Fix properly plus add some docs --------- Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
@@ -15,19 +15,67 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! I/O host interface for substrate runtime.
|
||||
//! # Substrate Primitives: IO
|
||||
//!
|
||||
//! This crate contains interfaces for the runtime to communicate with the outside world, ergo `io`.
|
||||
//! In other context, such interfaces are referred to as "**host functions**".
|
||||
//!
|
||||
//! Each set of host functions are defined with an instance of the
|
||||
//! [`sp_runtime_interface::runtime_interface`] macro.
|
||||
//!
|
||||
//! Most notably, this crate contains host functions for:
|
||||
//!
|
||||
//! - [`hashing`]
|
||||
//! - [`crypto`]
|
||||
//! - [`trie`]
|
||||
//! - [`offchain`]
|
||||
//! - [`storage`]
|
||||
//! - [`allocator`]
|
||||
//! - [`logging`]
|
||||
//!
|
||||
//! All of the default host functions provided by this crate, and by default contained in all
|
||||
//! substrate-based clients are amalgamated in [`SubstrateHostFunctions`].
|
||||
//!
|
||||
//! ## Externalities
|
||||
//!
|
||||
//! Host functions go hand in hand with the concept of externalities. Externalities are an
|
||||
//! environment in which host functions are provided, and thus can be accessed. Some host functions
|
||||
//! are only accessible in an externality environment that provides it.
|
||||
//!
|
||||
//! A typical error for substrate developers is the following:
|
||||
//!
|
||||
//! ```should_panic
|
||||
//! use sp_io::storage::get;
|
||||
//! # fn main() {
|
||||
//! let data = get(b"hello world");
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! This code will panic with the following error:
|
||||
//!
|
||||
//! ```no_compile
|
||||
//! thread 'main' panicked at '`get_version_1` called outside of an Externalities-provided environment.'
|
||||
//! ```
|
||||
//!
|
||||
//! Such error messages should always be interpreted as "code accessing host functions accessed
|
||||
//! outside of externalities".
|
||||
//!
|
||||
//! An externality is any type that implements [`sp_externalities::Externalities`]. A simple example
|
||||
//! of which is [`TestExternalities`], which is commonly used in tests and is exported from this
|
||||
//! crate.
|
||||
//!
|
||||
//! ```
|
||||
//! use sp_io::{storage::get, TestExternalities};
|
||||
//! # fn main() {
|
||||
//! TestExternalities::default().execute_with(|| {
|
||||
//! let data = get(b"hello world");
|
||||
//! });
|
||||
//! # }
|
||||
//! ```
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![cfg_attr(enable_alloc_error_handler, feature(alloc_error_handler))]
|
||||
#![cfg_attr(
|
||||
feature = "std",
|
||||
doc = "Substrate runtime standard library as compiled when linked with Rust's standard library."
|
||||
)]
|
||||
#![cfg_attr(
|
||||
not(feature = "std"),
|
||||
doc = "Substrate's runtime standard library as compiled without Rust's standard library."
|
||||
)]
|
||||
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user