mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Rewrap all comments to 100 line width (#9490)
* reformat everything again * manual formatting * last manual fix * Fix build
This commit is contained in:
@@ -26,11 +26,12 @@
|
||||
//! # Using a type in a runtime interface
|
||||
//!
|
||||
//! Any type that should be used in a runtime interface as argument or return value needs to
|
||||
//! implement [`RIType`]. The associated type [`FFIType`](./trait.RIType.html#associatedtype.FFIType)
|
||||
//! is the type that is used in the FFI function to represent the actual type. For example `[T]` is
|
||||
//! represented by an `u64`. The slice pointer and the length will be mapped to an `u64` value.
|
||||
//! For more information see this [table](#ffi-type-and-conversion).
|
||||
//! The FFI function definition is used when calling from the wasm runtime into the node.
|
||||
//! implement [`RIType`]. The associated type
|
||||
//! [`FFIType`](./trait.RIType.html#associatedtype.FFIType) is the type that is used in the FFI
|
||||
//! function to represent the actual type. For example `[T]` is represented by an `u64`. The slice
|
||||
//! pointer and the length will be mapped to an `u64` value. For more information see this
|
||||
//! [table](#ffi-type-and-conversion). The FFI function definition is used when calling from the
|
||||
//! wasm runtime into the node.
|
||||
//!
|
||||
//! Traits are used to convert from a type to the corresponding
|
||||
//! [`RIType::FFIType`](./trait.RIType.html#associatedtype.FFIType).
|
||||
@@ -93,13 +94,14 @@
|
||||
//! | `&str` | `u64` | <code>v.len() 32bit << 32 | v.as_ptr() 32bit</code> |
|
||||
//! | `&[u8]` | `u64` | <code>v.len() 32bit << 32 | v.as_ptr() 32bit</code> |
|
||||
//! | `Vec<u8>` | `u64` | <code>v.len() 32bit << 32 | v.as_ptr() 32bit</code> |
|
||||
//! | `Vec<T> where T: Encode` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32 | e.as_ptr() 32bit</code> |
|
||||
//! | `&[T] where T: Encode` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32 | e.as_ptr() 32bit</code> |
|
||||
//! | `[u8; N]` | `u32` | `v.as_ptr()` |
|
||||
//! | `*const T` | `u32` | `Identity` |
|
||||
//! | `Option<T>` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32 | e.as_ptr() 32bit</code> |
|
||||
//! | [`T where T: PassBy<PassBy=Inner>`](./pass_by#Inner) | Depends on inner | Depends on inner |
|
||||
//! | [`T where T: PassBy<PassBy=Codec>`](./pass_by#Codec)|`u64`|<code>v.len() 32bit << 32 |v.as_ptr() 32bit</code>|
|
||||
//! | `Vec<T> where T: Encode` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32
|
||||
//! | e.as_ptr() 32bit</code> | | `&[T] where T: Encode` | `u64` | `let e =
|
||||
//! v.encode();`<br><br><code>e.len() 32bit << 32 | e.as_ptr() 32bit</code> | | `[u8; N]` |
|
||||
//! `u32` | `v.as_ptr()` | | `*const T` | `u32` | `Identity` |
|
||||
//! | `Option<T>` | `u64` | `let e = v.encode();`<br><br><code>e.len() 32bit << 32 | e.as_ptr()
|
||||
//! 32bit</code> | | [`T where T: PassBy<PassBy=Inner>`](./pass_by#Inner) | Depends on inner |
|
||||
//! Depends on inner | | [`T where T: PassBy<PassBy=Codec>`](./pass_by#Codec)|`u64`|<code>v.len()
|
||||
//! 32bit << 32 |v.as_ptr() 32bit</code>|
|
||||
//!
|
||||
//! `Identity` means that the value is converted directly into the corresponding FFI type.
|
||||
|
||||
@@ -119,10 +121,10 @@ pub use sp_std;
|
||||
|
||||
/// Attribute macro for transforming a trait declaration into a runtime interface.
|
||||
///
|
||||
/// A runtime interface is a fixed interface between a Substrate compatible runtime and the native
|
||||
/// node. This interface is callable from a native and a wasm runtime. The macro will generate the
|
||||
/// corresponding code for the native implementation and the code for calling from the wasm
|
||||
/// side to the native implementation.
|
||||
/// A runtime interface is a fixed interface between a Substrate compatible runtime and the
|
||||
/// native node. This interface is callable from a native and a wasm runtime. The macro will
|
||||
/// generate the corresponding code for the native implementation and the code for calling from
|
||||
/// the wasm side to the native implementation.
|
||||
///
|
||||
/// The macro expects the runtime interface declaration as trait declaration:
|
||||
///
|
||||
@@ -273,25 +275,25 @@ pub use sp_std;
|
||||
/// The macro supports any kind of argument type, as long as it implements [`RIType`] and the
|
||||
/// required `FromFFIValue`/`IntoFFIValue`. The macro will convert each
|
||||
/// argument to the corresponding FFI representation and will call into the host using this FFI
|
||||
/// representation. On the host each argument is converted back to the native representation and
|
||||
/// the native implementation is called. Any return value is handled in the same way.
|
||||
/// representation. On the host each argument is converted back to the native representation
|
||||
/// and the native implementation is called. Any return value is handled in the same way.
|
||||
///
|
||||
/// # Wasm only interfaces
|
||||
///
|
||||
/// Some interfaces are only required from within the wasm runtime e.g. the allocator interface.
|
||||
/// To support this, the macro can be called like `#[runtime_interface(wasm_only)]`. This instructs
|
||||
/// the macro to make two significant changes to the generated code:
|
||||
/// Some interfaces are only required from within the wasm runtime e.g. the allocator
|
||||
/// interface. To support this, the macro can be called like `#[runtime_interface(wasm_only)]`.
|
||||
/// This instructs the macro to make two significant changes to the generated code:
|
||||
///
|
||||
/// 1. The generated functions are not callable from the native side.
|
||||
/// 2. The trait as shown above is not implemented for `Externalities` and is instead implemented
|
||||
/// for `FunctionExecutor` (from `sp-wasm-interface`).
|
||||
/// 2. The trait as shown above is not implemented for `Externalities` and is instead
|
||||
/// implemented for `FunctionExecutor` (from `sp-wasm-interface`).
|
||||
///
|
||||
/// # Disable tracing
|
||||
/// By addding `no_tracing` to the list of options you can prevent the wasm-side interface from
|
||||
/// generating the default `sp-tracing`-calls. Note that this is rarely needed but only meant for
|
||||
/// the case when that would create a circular dependency. You usually _do not_ want to add this
|
||||
/// flag, as tracing doesn't cost you anything by default anyways (it is added as a no-op) but is
|
||||
/// super useful for debugging later.
|
||||
/// generating the default `sp-tracing`-calls. Note that this is rarely needed but only meant
|
||||
/// for the case when that would create a circular dependency. You usually _do not_ want to add
|
||||
/// this flag, as tracing doesn't cost you anything by default anyways (it is added as a no-op)
|
||||
/// but is super useful for debugging later.
|
||||
pub use sp_runtime_interface_proc_macro::runtime_interface;
|
||||
|
||||
#[doc(hidden)]
|
||||
|
||||
@@ -40,8 +40,8 @@ use sp_std::vec::Vec;
|
||||
|
||||
/// Derive macro for implementing [`PassBy`] with the [`Codec`] strategy.
|
||||
///
|
||||
/// This requires that the type implements [`Encode`](codec::Encode) and [`Decode`](codec::Decode)
|
||||
/// from `parity-scale-codec`.
|
||||
/// This requires that the type implements [`Encode`](codec::Encode) and
|
||||
/// [`Decode`](codec::Decode) from `parity-scale-codec`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@@ -58,11 +58,12 @@ pub use sp_runtime_interface_proc_macro::PassByCodec;
|
||||
|
||||
/// Derive macro for implementing [`PassBy`] with the [`Inner`] strategy.
|
||||
///
|
||||
/// Besides implementing [`PassBy`], this derive also implements the helper trait [`PassByInner`].
|
||||
/// Besides implementing [`PassBy`], this derive also implements the helper trait
|
||||
/// [`PassByInner`].
|
||||
///
|
||||
/// The type is required to be a struct with just one field. The field type needs to implement
|
||||
/// the required traits to pass it between the wasm and the native side. (See the runtime interface
|
||||
/// crate for more information about these traits.)
|
||||
/// the required traits to pass it between the wasm and the native side. (See the runtime
|
||||
/// interface crate for more information about these traits.)
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@@ -86,8 +87,8 @@ pub use sp_runtime_interface_proc_macro::PassByInner;
|
||||
/// Besides implementing [`PassBy`], this derive also implements `TryFrom<u8>` and
|
||||
/// `From<Self> for u8` for the type.
|
||||
///
|
||||
/// The type is required to be an enum with only unit variants and at maximum `256` variants. Also
|
||||
/// it is required that the type implements `Copy`.
|
||||
/// The type is required to be an enum with only unit variants and at maximum `256` variants.
|
||||
/// Also it is required that the type implements `Copy`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
||||
@@ -29,8 +29,8 @@ pub fn pack_ptr_and_len(ptr: u32, len: u32) -> u64 {
|
||||
/// Unpacks an `u64` into the pointer and length.
|
||||
///
|
||||
/// Runtime API functions return a 64-bit value which encodes a pointer in the least-significant
|
||||
/// 32-bits and a length in the most-significant 32 bits. This interprets the returned value as a pointer,
|
||||
/// length tuple.
|
||||
/// 32-bits and a length in the most-significant 32 bits. This interprets the returned value as a
|
||||
/// pointer, length tuple.
|
||||
pub fn unpack_ptr_and_len(val: u64) -> (u32, u32) {
|
||||
// The static assertions from above are changed into a runtime check.
|
||||
#[cfg(all(not(feature = "std"), feature = "disable_target_static_assertions"))]
|
||||
|
||||
Reference in New Issue
Block a user