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 binding;
8mod expression;
9mod name;
10mod argument;
11mod sequence;
12mod aspect;
13mod ty_context;
14#[allow(unused)]
15mod interface;
16
17pub use aspect::*;
18pub use binding::*;
19pub use expression::*;
21pub use name::*;
22pub use argument::*;
23pub use interface::*;
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, SEP: ToTokens + Clone + Default {
43 type Presentation = Punctuated<<T as ScopeContextPresentable>::Presentation, SEP>;
44
45 fn present(&self, source: &ScopeContext) -> Self::Presentation {
46 self.iter().map(|presentable| presentable.present(source)).collect()
47 }
48}
49pub trait NameTreeContext: Clone + Debug + ToTokens {
61 fn join_fn(&self, path: Path, sig_context: FnSignatureContext, attrs: Vec<Attribute>) -> Self;
63 fn join_variant(&self, ident: Ident, variant_ident: Ident, attrs: Vec<Attribute>) -> Self;
64}
65
66