ploidy_codegen_rust/
statics.rs1use ploidy_core::codegen::IntoCode;
2use proc_macro2::TokenStream;
3use quote::{ToTokens, TokenStreamExt, quote};
4
5#[derive(Clone, Copy, Debug)]
6pub struct CodegenLibrary;
7
8impl ToTokens for CodegenLibrary {
9 fn to_tokens(&self, tokens: &mut TokenStream) {
10 tokens.append_all(quote! {
11 pub mod types;
12 pub mod client;
13 pub mod error;
14
15 #[cfg(feature = "tracing")]
16 extern crate self as tracing;
17
18 #[cfg(feature = "tracing")]
19 pub(crate) use ::ploidy_util::tracing::*;
20
21 pub use ::ploidy_util as util;
24
25 pub use client::Client;
26 pub use error::Error;
27 });
28 }
29}
30
31impl IntoCode for CodegenLibrary {
32 type Code = (&'static str, TokenStream);
33
34 fn into_code(self) -> Self::Code {
35 ("src/lib.rs", self.into_token_stream())
36 }
37}
38
39#[derive(Clone, Copy, Debug)]
40pub struct CodegenErrorModule;
41
42impl ToTokens for CodegenErrorModule {
43 fn to_tokens(&self, tokens: &mut TokenStream) {
44 tokens.append_all(quote! {
45 pub use ::ploidy_util::error::*;
46 });
47 }
48}
49
50impl IntoCode for CodegenErrorModule {
51 type Code = (&'static str, TokenStream);
52
53 fn into_code(self) -> Self::Code {
54 ("src/error.rs", self.into_token_stream())
55 }
56}