diff --git a/Cargo.lock b/Cargo.lock index 09099a1f9e6..da3eb41a8c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1623,6 +1623,12 @@ dependencies = [ "syn", ] +[[package]] +name = "impls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbc2ceeb474920e0d451e95df08409ac01a207851b564ba9dafcdb07a34fa6de" + [[package]] name = "indenter" version = "0.3.3" @@ -1986,7 +1992,9 @@ name = "iroha_schema" version = "2.0.0-pre-rc.4" dependencies = [ "fixnum", + "impls", "iroha_schema_derive", + "iroha_schema_gen", "parity-scale-codec", "serde", ] diff --git a/schema/Cargo.toml b/schema/Cargo.toml index ed6abc8df5d..5014aaa1a76 100644 --- a/schema/Cargo.toml +++ b/schema/Cargo.toml @@ -12,3 +12,6 @@ fixnum = { version = "0.6.1", default-features = false, features = ["i64"] } [dev-dependencies] parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive", "full"] } +impls = { version = "=1.0.0" } + +iroha_schema_gen = { version = "=2.0.0-pre-rc.4", path = "gen" } \ No newline at end of file diff --git a/schema/tests/architecture-dependent.rs b/schema/tests/architecture-dependent.rs new file mode 100644 index 00000000000..c3d70ce9110 --- /dev/null +++ b/schema/tests/architecture-dependent.rs @@ -0,0 +1,24 @@ +use impls::impls; +use iroha_schema::IntoSchema; +use parity_scale_codec::{Decode, Encode}; + +#[test] +fn usize_isize_not_into_schema() { + // The architecture-dependent + assert!(!impls!(usize: IntoSchema)); + assert!(!impls!(isize: IntoSchema)); + + // use serde::Serialize; + // + // assert!(!impls!(usize: Serialize)); + // `usize` should be `Serialize`. + + // But not `Encode`/`Decode`. + assert!(!impls!(usize: Encode | Decode)); + assert!(!impls!(isize: Encode | Decode)); + + // There are no other primitive architecture-dependent types, so + // as long as `IntoSchema` requires all variants and all fields to + // also be `IntoSchema`, we are guaranteed that all schema types + // are safe to exchange. +}