mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Subxt Metadata: #[no_std] compatibility (#1401)
* no-std tests and porting of subxt-metadata * update pipeline * fix generate custom metadata test * fix cargo run command * adjust pipeline * remove prelude from subxt-metadata * revert autoformatting of Cargo.toml * remove alloc::format! again, still causes linker errors * add no-std-build for thumbv7em-none-eabi target * remove std feature flag * remove libc and add small readme with test instructions * change ci for nightly no std
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use hashbrown::HashMap;
|
||||
|
||||
/// A minimal ordered map to let one search for
|
||||
/// things by key or get the values in insert order.
|
||||
@@ -23,7 +25,7 @@ impl<K, V> Default for OrderedMap<K, V> {
|
||||
|
||||
impl<K, V> OrderedMap<K, V>
|
||||
where
|
||||
K: PartialEq + Eq + std::hash::Hash,
|
||||
K: PartialEq + Eq + core::hash::Hash,
|
||||
{
|
||||
/// Create a new, empty [`OrderedMap`].
|
||||
pub fn new() -> Self {
|
||||
@@ -47,8 +49,8 @@ where
|
||||
where
|
||||
F: FnMut(&V) -> bool,
|
||||
{
|
||||
let values = std::mem::take(&mut self.values);
|
||||
let map = std::mem::take(&mut self.map);
|
||||
let values = mem::take(&mut self.values);
|
||||
let map = mem::take(&mut self.map);
|
||||
|
||||
// Filter the values, storing a map from old to new positions:
|
||||
let mut new_values = Vec::new();
|
||||
@@ -78,8 +80,8 @@ where
|
||||
/// Get an item by its key.
|
||||
pub fn get_by_key<Q>(&self, key: &Q) -> Option<&V>
|
||||
where
|
||||
K: std::borrow::Borrow<Q>,
|
||||
Q: std::hash::Hash + Eq + ?Sized,
|
||||
K: alloc::borrow::Borrow<Q>,
|
||||
Q: core::hash::Hash + Eq + ?Sized,
|
||||
{
|
||||
self.map.get(key).and_then(|&v| self.values.get(v))
|
||||
}
|
||||
@@ -107,7 +109,7 @@ where
|
||||
|
||||
impl<K, V> FromIterator<(K, V)> for OrderedMap<K, V>
|
||||
where
|
||||
K: PartialEq + Eq + std::hash::Hash,
|
||||
K: PartialEq + Eq + core::hash::Hash,
|
||||
{
|
||||
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
|
||||
let mut map = OrderedMap::new();
|
||||
|
||||
@@ -8,8 +8,9 @@ use crate::{
|
||||
ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner, RuntimeApiMetadataInner,
|
||||
StorageEntryType,
|
||||
};
|
||||
use alloc::collections::BTreeMap;
|
||||
use hashbrown::HashSet;
|
||||
use scale_info::TypeDef;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
/// Collect all type IDs needed to represent the provided pallet.
|
||||
fn collect_pallet_types(pallet: &PalletMetadataInner, type_ids: &mut HashSet<u32>) {
|
||||
|
||||
@@ -8,9 +8,10 @@ use crate::{
|
||||
CustomMetadata, CustomValueMetadata, ExtrinsicMetadata, Metadata, PalletMetadata,
|
||||
RuntimeApiMetadata, RuntimeApiMethodMetadata, StorageEntryMetadata, StorageEntryType,
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
use hashbrown::HashMap;
|
||||
use outer_enum_hashes::OuterEnumHashes;
|
||||
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub mod outer_enum_hashes;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Hash representations of the `frame_metadata::v15::OuterEnums`.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use hashbrown::HashMap;
|
||||
|
||||
use scale_info::{PortableRegistry, TypeDef};
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use alloc::borrow::ToOwned;
|
||||
use alloc::string::String;
|
||||
use hashbrown::HashMap;
|
||||
use scale_info::{form::PortableForm, PortableRegistry, TypeDef, Variant};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Given some type ID and type registry, build a couple of
|
||||
/// indexes to look up variants by index or name. If the ID provided
|
||||
@@ -62,8 +64,8 @@ impl VariantIndex {
|
||||
types: &'a PortableRegistry,
|
||||
) -> Option<&'a Variant<PortableForm>>
|
||||
where
|
||||
String: std::borrow::Borrow<K>,
|
||||
K: std::hash::Hash + Eq + ?Sized,
|
||||
String: alloc::borrow::Borrow<K>,
|
||||
K: core::hash::Hash + Eq + ?Sized,
|
||||
{
|
||||
let pos = *self.by_name.get(name)?;
|
||||
let variants = Self::get(variant_id, types)?;
|
||||
|
||||
Reference in New Issue
Block a user