mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-23 09:38:00 +00:00
Add 'Static' type and improve type substitution codegen to accept it (#886)
* Add Static type which defers to Encode/Decode and impls EncodeAsType/DecodeAsType * rename to static_type and impl Deref/Mut * Improve type substitution in codegen so that concrete types can be swapped in * A couple of comment tweaks and no need for a macro export * Extend type substitution logic to work recursively on destination type * cargo fmt * Fix a couple of comments * update ui test outpuot * Add docs and missing_docs lint * Add test for replacing multiple of Ident * Update codegen/src/error.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * update copyright year and fix ui test * simplify another error --------- Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::error::FetchMetadataError;
|
||||
use jsonrpsee::{
|
||||
async_client::ClientBuilder,
|
||||
client_transport::ws::{Uri, WsTransportClientBuilder},
|
||||
@@ -67,40 +72,3 @@ async fn fetch_metadata_http(url: &Uri) -> Result<String, FetchMetadataError> {
|
||||
|
||||
Ok(client.request("state_getMetadata", rpc_params![]).await?)
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum FetchMetadataError {
|
||||
DecodeError(hex::FromHexError),
|
||||
RequestError(jsonrpsee::core::Error),
|
||||
InvalidScheme(String),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for FetchMetadataError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
FetchMetadataError::DecodeError(e) => {
|
||||
write!(f, "Cannot decode hex value: {e}")
|
||||
}
|
||||
FetchMetadataError::RequestError(e) => write!(f, "Request error: {e}"),
|
||||
FetchMetadataError::InvalidScheme(s) => {
|
||||
write!(
|
||||
f,
|
||||
"'{s}' not supported, supported URI schemes are http, https, ws or wss."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for FetchMetadataError {}
|
||||
|
||||
impl From<hex::FromHexError> for FetchMetadataError {
|
||||
fn from(e: hex::FromHexError) -> Self {
|
||||
FetchMetadataError::DecodeError(e)
|
||||
}
|
||||
}
|
||||
impl From<jsonrpsee::core::Error> for FetchMetadataError {
|
||||
fn from(e: jsonrpsee::core::Error) -> Self {
|
||||
FetchMetadataError::RequestError(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
//! Utilities to help with fetching and decoding metadata.
|
||||
|
||||
mod fetch_metadata;
|
||||
|
||||
// easy access to this type needed for fetching metadata:
|
||||
@@ -5,5 +11,5 @@ pub use jsonrpsee::client_transport::ws::Uri;
|
||||
|
||||
pub use fetch_metadata::{
|
||||
fetch_metadata_bytes, fetch_metadata_bytes_blocking, fetch_metadata_hex,
|
||||
fetch_metadata_hex_blocking, FetchMetadataError,
|
||||
fetch_metadata_hex_blocking,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user