mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Full native build with new structure.
No tests yet. Wasm build still pulls in std.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Trait
|
||||
|
||||
use std::iter::Extend;
|
||||
use rstd::iter::Extend;
|
||||
use super::slicable::Slicable;
|
||||
|
||||
/// Trait to allow itself to be serialised into a value which can be extended
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
//! Serialiser and prepender.
|
||||
|
||||
use slicable::Slicable;
|
||||
use std::iter::Extend;
|
||||
use std::vec::Vec;
|
||||
use rstd::iter::Extend;
|
||||
use rstd::vec::Vec;
|
||||
|
||||
/// Trait to allow itselg to be serialised and prepended by a given slice.
|
||||
pub trait KeyedVec {
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||
|
||||
extern crate substrate_runtime_std as rstd;
|
||||
|
||||
mod endiansensitive;
|
||||
mod slicable;
|
||||
mod joiner;
|
||||
@@ -29,12 +31,3 @@ pub use self::endiansensitive::EndianSensitive;
|
||||
pub use self::slicable::{Slicable, NonTrivialSlicable};
|
||||
pub use self::joiner::Joiner;
|
||||
pub use self::keyedvec::KeyedVec;
|
||||
|
||||
// TODO: move these into runtime-std and `extern crate runtime_std as std;`
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod std {
|
||||
extern crate alloc;
|
||||
|
||||
pub use core::*;
|
||||
pub use self::alloc::vec;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
//! Serialisation.
|
||||
|
||||
use std::{mem, slice};
|
||||
use std::vec::Vec;
|
||||
use rstd::{mem, slice};
|
||||
use rstd::vec::Vec;
|
||||
use super::joiner::Joiner;
|
||||
use super::endiansensitive::EndianSensitive;
|
||||
|
||||
@@ -44,7 +44,7 @@ impl<T: EndianSensitive> Slicable for T {
|
||||
let size = mem::size_of::<T>();
|
||||
assert!(size > 0, "EndianSensitive can never be implemented for a zero-sized type.");
|
||||
if value.len() >= size {
|
||||
let x: T = unsafe { ::std::ptr::read(value.as_ptr() as *const T) };
|
||||
let x: T = unsafe { ::rstd::ptr::read(value.as_ptr() as *const T) };
|
||||
*value = &value[size..];
|
||||
Some(x.from_le())
|
||||
} else {
|
||||
@@ -115,7 +115,7 @@ impl<T: NonTrivialSlicable> Slicable for Vec<T> {
|
||||
}
|
||||
|
||||
fn to_vec(&self) -> Vec<u8> {
|
||||
use std::iter::Extend;
|
||||
use rstd::iter::Extend;
|
||||
|
||||
let len = self.len();
|
||||
assert!(len <= u32::max_value() as usize, "Attempted to serialize vec with too many elements.");
|
||||
|
||||
Reference in New Issue
Block a user