ferment_sys/presentable/
mod.rs1use std::fmt::Debug;
2use quote::ToTokens;
3use syn::punctuated::Punctuated;
4use proc_macro2::{Ident, TokenStream as TokenStream2};
5use crate::context::ScopeContext;
6
7mod arg;
8mod aspect;
9mod binding;
10mod conversion_expression_kind;
11mod expression;
12#[allow(unused)]
13mod interface;
14mod name;
15mod sequence;
16
17pub use arg::*;
18pub use aspect::*;
19pub use binding::*;
20pub use conversion_expression_kind::*;
21pub use expression::*;
22pub use interface::*;
23pub use name::*;
24pub use sequence::*;
25use syn::{Attribute, Path};
26use crate::composable::FnSignatureContext;
27
28pub trait ScopeContextPresentable {
29 type Presentation: Clone + ToTokens;
30 fn present(&self, source: &ScopeContext) -> Self::Presentation;
31}
32
33impl ScopeContextPresentable for TokenStream2 {
34 type Presentation = TokenStream2;
35
36 fn present(&self, _source: &ScopeContext) -> Self::Presentation {
37 self.to_token_stream()
38 }
39}
40
41impl<T, SEP> ScopeContextPresentable for Punctuated<T, SEP>
42 where T: ScopeContextPresentable,
43 SEP: ToTokens + Clone + Default {
44 type Presentation = Punctuated<<T as ScopeContextPresentable>::Presentation, SEP>;
45
46 fn present(&self, source: &ScopeContext) -> Self::Presentation {
47 self.iter().map(|presentable| presentable.present(source)).collect()
48 }
49}
50
51pub trait NameTreeContext: Clone + Debug + ToTokens {
52 fn join_fn(&self, path: Path, sig_context: FnSignatureContext, attrs: Vec<Attribute>) -> Self;
53 fn join_variant(&self, ident: Ident, variant_ident: Ident, attrs: Vec<Attribute>) -> Self;
54}
55
56