scale_typegen/typegen/ir/
mod.rs

1use crate::TypeGeneratorSettings;
2
3/// Intermediate Representation of a rust module.
4pub mod module_ir;
5/// Intermediate Representation of a rust type.
6pub mod type_ir;
7
8/// A trait that can translate a type into rust tokens similar to [`quote::ToTokens`], but
9/// takes into account the `alloc_crate_path` from [`TypeGeneratorSettings`].
10pub trait ToTokensWithSettings {
11    /// Translate a type into rust tokens.
12    fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream, settings: &TypeGeneratorSettings);
13
14    /// Translate a type into rust tokens.
15    fn to_token_stream(&self, settings: &TypeGeneratorSettings) -> proc_macro2::TokenStream {
16        let mut tokens = proc_macro2::TokenStream::new();
17        self.to_tokens(&mut tokens, settings);
18        tokens
19    }
20}