Skip to main content

subsoil_macros/
lib.rs

1// This file is part of Soil.
2
3// Copyright (C) Soil contributors.
4// SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later WITH Classpath-exception-2.0
5
6//! Unified procedural macros for the Subsoil runtime.
7
8#![recursion_limit = "512"]
9
10use proc_macro::TokenStream;
11
12mod api;
13mod crypto_hashing;
14mod debug_derive;
15mod runtime_interface;
16mod tracing_macro;
17mod version;
18
19// --- api (3 proc-macro functions) ---
20
21#[proc_macro]
22pub fn impl_runtime_apis(input: TokenStream) -> TokenStream {
23	api::impl_runtime_apis_impl(input)
24}
25
26#[proc_macro]
27pub fn mock_impl_runtime_apis(input: TokenStream) -> TokenStream {
28	api::mock_impl_runtime_apis_impl(input)
29}
30
31#[proc_macro]
32pub fn decl_runtime_apis(input: TokenStream) -> TokenStream {
33	api::decl_runtime_apis_impl(input)
34}
35
36// --- crypto_hashing (8 proc-macro functions) ---
37
38#[proc_macro]
39pub fn blake2b_64(input: TokenStream) -> TokenStream {
40	crypto_hashing::blake2b_64(input)
41}
42
43#[proc_macro]
44pub fn blake2b_256(input: TokenStream) -> TokenStream {
45	crypto_hashing::blake2b_256(input)
46}
47
48#[proc_macro]
49pub fn blake2b_512(input: TokenStream) -> TokenStream {
50	crypto_hashing::blake2b_512(input)
51}
52
53#[proc_macro]
54pub fn twox_64(input: TokenStream) -> TokenStream {
55	crypto_hashing::twox_64(input)
56}
57
58#[proc_macro]
59pub fn twox_128(input: TokenStream) -> TokenStream {
60	crypto_hashing::twox_128(input)
61}
62
63#[proc_macro]
64pub fn keccak_256(input: TokenStream) -> TokenStream {
65	crypto_hashing::keccak_256(input)
66}
67
68#[proc_macro]
69pub fn keccak_512(input: TokenStream) -> TokenStream {
70	crypto_hashing::keccak_512(input)
71}
72
73#[proc_macro]
74pub fn sha2_256(input: TokenStream) -> TokenStream {
75	crypto_hashing::sha2_256(input)
76}
77
78// --- debug_derive (1 derive macro) ---
79
80#[proc_macro_derive(RuntimeDebug)]
81pub fn runtime_debug_derive(input: TokenStream) -> TokenStream {
82	debug_derive::runtime_debug_derive(input)
83}
84
85// --- runtime_interface (1 attribute macro) ---
86
87#[proc_macro_attribute]
88pub fn runtime_interface(attrs: TokenStream, input: TokenStream) -> TokenStream {
89	runtime_interface::runtime_interface(attrs, input)
90}
91
92// --- tracing (1 attribute macro) ---
93
94#[proc_macro_attribute]
95pub fn prefix_logs_with(arg: TokenStream, item: TokenStream) -> TokenStream {
96	tracing_macro::prefix_logs_with(arg, item)
97}
98
99// --- version (1 attribute macro) ---
100
101#[proc_macro_attribute]
102pub fn runtime_version(_: TokenStream, input: TokenStream) -> TokenStream {
103	version::runtime_version(input)
104}