This repository was archived by the owner on Nov 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed
primitives/runtime-interface
proc-macro/src/runtime_interface Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 2121//! functions will prepare the parameters for the FFI boundary, call the external host function
2222//! exported into wasm and convert back the result.
2323//!
24- //! [`generate`](bare_function_interface::generate) is the entry point for generating for each
24+ //! [`generate`] is the entry point for generating for each
2525//! trait method one bare function.
2626//!
27- //! [`function_for_method`](bare_function_interface::function_for_method) generates the bare
27+ //! [`function_for_method`] generates the bare
2828//! function per trait method. Each bare function contains both implementations. The implementations
2929//! are feature-gated, so that one is compiled for the native and the other for the wasm side.
3030
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ pub trait IntoPreallocatedFFIValue: RIType {
4949}
5050
5151/// Something that can be created from a ffi value.
52+ /// Implementations are safe to assume that the `arg` given to `from_ffi_value`
53+ /// is only generated by the corresponding [`wasm::IntoFFIValue`](crate::wasm::IntoFFIValue)
54+ /// implementation.
5255pub trait FromFFIValue : RIType {
5356 /// As `Self` can be an unsized type, it needs to be represented by a sized type at the host.
5457 /// This `SelfInstance` is the sized type.
Original file line number Diff line number Diff line change 2525//! # Using a type in a runtime interface
2626//!
2727//! Any type that should be used in a runtime interface as argument or return value needs to
28- //! implement [`RIType`]. The associated type `FFIType` is the type that is used in the FFI
29- //! function to represent the actual type. For example `[T]` is represented by an `u64`. The slice
30- //! pointer and the length will be mapped to an `u64` value. For more information, see the
31- //! implementation of [`RIType`] for `T` . The FFI function definition is used when calling from
28+ //! implement [`RIType`]. The associated type [ `FFIType`](RIType::FFIType) is the type that is used
29+ //! in the FFI function to represent the actual type. For example `[T]` is represented by an `u64`.
30+ //! The slice pointer and the length will be mapped to an `u64` value. For more information see
31+ //! this [table](#ffi-type-and-conversion) . The FFI function definition is used when calling from
3232//! the wasm runtime into the node.
3333//!
3434//! Traits are used to convert from a type to the corresponding [`RIType::FFIType`].
@@ -265,7 +265,7 @@ pub use codec;
265265pub ( crate ) mod impls;
266266#[ cfg( feature = "std" ) ]
267267pub mod host;
268- #[ cfg( not( feature = "std" ) ) ]
268+ #[ cfg( any ( not( feature = "std" ) , doc ) ) ]
269269pub mod wasm;
270270pub mod pass_by;
271271
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ use sp_std::cell::Cell;
2626///
2727/// It is unsafe behavior to call `Something::into_ffi_value().get()` and take this as input for
2828/// `from_ffi_value`. Implementations are safe to assume that the `arg` given to `from_ffi_value`
29- /// is only generated by the corresponding `host::IntoFFIValue` implementation.
29+ /// is only generated by the corresponding [`host::IntoFFIValue`](crate::host::IntoFFIValue)
30+ /// implementation.
3031pub trait FromFFIValue : Sized + RIType {
3132 /// Create `Self` from the given ffi value.
3233 fn from_ffi_value ( arg : Self :: FFIType ) -> Self ;
You can’t perform that action at this time.
0 commit comments