Files
pezkuwi-subxt/signer/src/utils.rs
T
James Wilson b4eb406ee5 Add subxt_signer crate for native & WASM compatible signing (#1016)
* Add and use subxt-signer crate for WASM compatible signing

* cargo fmt

* dev keypairs already references

* WIP fix various breakages

* re-jig features to be simpler and various test fixes etc

* doc and web fix

* fix various bits and pieces

* fix a test I broke

* dev-deps can't be linked to in docs, hrmph

* cargo fmt

* another doc link

* document the subxt_signer crate more thoroughly

* move feature flag for consistency

* more docs, no default subxt feature flag on signer, update release instrs

* Add missing license header

* unwrap_inner => into_inner

* extend a test a little to better check derive junctions

* note more clearly that the crypto bits come from sp_core::crypto
2023-06-20 11:32:12 +01:00

40 lines
1.2 KiB
Rust

// 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 like:
///
/// ```rust,ignore
/// once_static!{
/// /// Some documentation.
/// fn foo() -> Vec<u8> {
/// vec![1,2,3,4]
/// }
/// }
/// ```
macro_rules! once_static {
($($(#[$attr:meta])* $vis:vis fn $name:ident() -> $ty:ty { $expr:expr } )+) => {
$(
$(#[$attr])*
$vis fn $name() -> &'static $ty {
static VAR: std::sync::OnceLock<$ty> = std::sync::OnceLock::new();
VAR.get_or_init(|| { $expr })
}
)+
};
}
/// Like `once_static!` but clones the item out of static storage. Useful if it
/// takes a while to create the item but cloning it is fairly cheap.
macro_rules! once_static_cloned {
($($(#[$attr:meta])* $vis:vis fn $name:ident() -> $ty:ty { $expr:expr } )+) => {
$(
$(#[$attr])*
$vis fn $name() -> $ty {
static VAR: std::sync::OnceLock<$ty> = std::sync::OnceLock::new();
VAR.get_or_init(|| { $expr }).clone()
}
)+
};
}