Skip to content

Commit b900d0a

Browse files
authored
Merge pull request #1230 from GPTechinno/std_logic
enforce `no_std` for all? protocol/v2 crates
2 parents dee3cae + 8cd634b commit b900d0a

25 files changed

Lines changed: 70 additions & 36 deletions

File tree

protocols/v2/binary-sv2/binary-sv2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ serde_sv2 = {version = "^1.0.0", path = "../serde-sv2", optional = true}
1818
serde = { version = "1.0.89", features = ["derive", "alloc"], default-features = false, optional = true }
1919
binary_codec_sv2 = {version = "^1.0.0", path = "../no-serde-sv2/codec", optional = true}
2020
derive_codec_sv2 = {version = "^1.0.0", path = "../no-serde-sv2/derive_codec", optional = true}
21-
tracing = {version = "0.1"}
21+
tracing = { version = "0.1", default-features = false }
2222

2323
[features]
2424
default = ["core"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# binary_sv2
2+
3+
`binary_sv2` is a Rust `no_std` crate

protocols/v2/binary-sv2/binary-sv2/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// TODO unify errors from serde_sv2 and no-serde-sv2
2-
//
2+
3+
#![no_std]
4+
5+
#[macro_use]
6+
extern crate alloc;
7+
38
use core::convert::TryInto;
49

510
#[cfg(feature = "with_serde")]
@@ -34,6 +39,7 @@ pub fn u256_from_int<V: Into<u64>>(value: V) -> U256<'static> {
3439
#[cfg(test)]
3540
mod test {
3641
use super::*;
42+
use alloc::vec::Vec;
3743

3844
mod test_struct {
3945
use super::*;
@@ -748,7 +754,6 @@ mod test {
748754
}
749755
mod test_sv2_option_none {
750756
use super::*;
751-
use core::convert::TryInto;
752757

753758
#[derive(Deserialize, Serialize, PartialEq, Debug, Clone)]
754759
struct Test<'decoder> {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# binary_codec_sv2
2+
3+
`binary_codec_sv2` is a Rust `no_std` crate

protocols/v2/binary-sv2/no-serde-sv2/codec/src/codec/decodable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
Error,
77
};
88
use alloc::vec::Vec;
9-
use std::convert::TryFrom;
9+
use core::convert::TryFrom;
1010
#[cfg(not(feature = "no_std"))]
1111
use std::io::{Cursor, Read};
1212

protocols/v2/binary-sv2/no-serde-sv2/codec/src/codec/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ mod impls;
1111
#[cfg(feature = "with_buffer_pool")]
1212
use buffer_sv2::Slice;
1313

14+
use alloc::vec::Vec;
15+
1416
/// Return the encoded byte size or a `Decodable`
1517
pub trait SizeHint {
1618
fn size_hint(data: &[u8], offset: usize) -> Result<usize, Error>;

protocols/v2/binary-sv2/no-serde-sv2/codec/src/datatypes/copy_data_types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Copy data types
22
use crate::{codec::Fixed, datatypes::Sv2DataType, Error};
3+
4+
use alloc::vec::Vec;
35
use core::convert::{TryFrom, TryInto};
46

57
#[cfg(not(feature = "no_std"))]

protocols/v2/binary-sv2/no-serde-sv2/codec/src/datatypes/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ pub use non_copy_data_types::{
1212
B0255, B032, B064K, U256,
1313
};
1414

15+
use alloc::vec::Vec;
16+
use core::convert::TryInto;
1517
#[cfg(not(feature = "no_std"))]
1618
use std::io::{Error as E, Read, Write};
1719

18-
use std::convert::TryInto;
19-
2020
pub trait Sv2DataType<'a>: Sized + SizeHint + GetSize + TryInto<FieldMarker> {
2121
fn from_bytes_(data: &'a mut [u8]) -> Result<Self, Error> {
2222
Self::size_hint(data, 0)?;

protocols/v2/binary-sv2/no-serde-sv2/codec/src/datatypes/non_copy_data_types/inner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use crate::{
44
datatypes::Sv2DataType,
55
Error,
66
};
7-
use core::convert::TryFrom;
8-
use std::convert::TryInto;
97

8+
use alloc::vec::Vec;
9+
use core::convert::{TryFrom, TryInto};
1010
#[cfg(not(feature = "no_std"))]
1111
use std::io::{Error as E, Read, Write};
1212

protocols/v2/binary-sv2/no-serde-sv2/codec/src/datatypes/non_copy_data_types/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#[cfg(feature = "prop_test")]
22
use quickcheck::{Arbitrary, Gen};
33

4+
use alloc::string::String;
5+
#[cfg(feature = "prop_test")]
6+
use alloc::vec::Vec;
7+
48
mod inner;
59
mod seq_inner;
610

@@ -28,7 +32,6 @@ impl<'decoder> From<[u8; 32]> for U256<'decoder> {
2832
}
2933
}
3034

31-
#[cfg(not(feature = "with_serde"))]
3235
#[cfg(feature = "prop_test")]
3336
impl<'a> U256<'a> {
3437
pub fn from_gen(g: &mut Gen) -> Self {
@@ -40,7 +43,6 @@ impl<'a> U256<'a> {
4043
}
4144
}
4245

43-
#[cfg(not(feature = "with_serde"))]
4446
#[cfg(feature = "prop_test")]
4547
impl<'a> B016M<'a> {
4648
pub fn from_gen(g: &mut Gen) -> Self {

0 commit comments

Comments
 (0)