Fix cycle dependency in sp-runtime-interface (#4353)

* Fix cycle dependency in `sp-runtime-interface`

* Fixes tests
This commit is contained in:
Bastian Köcher
2019-12-11 09:32:11 +01:00
committed by GitHub
parent 1ff41742bd
commit 6500b33df3
19 changed files with 218 additions and 224 deletions
@@ -35,7 +35,70 @@ use sp_std::{marker::PhantomData, convert::TryFrom};
#[cfg(not(feature = "std"))]
use sp_std::{slice, vec::Vec};
pub use sp_runtime_interface_proc_macro::{PassByCodec, PassByInner, PassByEnum};
/// 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`.
///
/// # Example
///
/// ```
/// # use sp_runtime_interface::pass_by::PassByCodec;
/// # use codec::{Encode, Decode};
/// #[derive(PassByCodec, Encode, Decode)]
/// struct EncodableType {
/// name: Vec<u8>,
/// param: u32,
/// }
/// ```
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`].
///
/// 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.)
///
/// # Example
///
/// ```
/// # use sp_runtime_interface::pass_by::PassByInner;
/// #[derive(PassByInner)]
/// struct Data([u8; 32]);
/// ```
///
/// ```
/// # use sp_runtime_interface::pass_by::PassByInner;
/// #[derive(PassByInner)]
/// struct Data {
/// data: [u8; 32],
/// }
/// ```
pub use sp_runtime_interface_proc_macro::PassByInner;
/// Derive macro for implementing [`PassBy`] with the [`Enum`] strategy.
///
/// 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`.
///
/// # Example
///
/// ```
/// # use sp_runtime_interface::pass_by::PassByEnum;
/// #[derive(PassByEnum, Copy, Clone)]
/// enum Data {
/// Okay,
/// NotOkay,
/// // This will not work with the derive.
/// //Why(u32),
/// }
/// ```
pub use sp_runtime_interface_proc_macro::PassByEnum;
/// Something that should be passed between wasm and the host using the given strategy.
///