1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
mod r#enum;
mod exception_trait;
mod module;
mod rust_mod;
mod traits_mod;

use crate::utils::{BuildContext, NamesTracker};

pub(crate) const EXTERN_EXCEPTION_TRAIT_MODULE_NAME: &str = "ExceptionTrait";
pub(crate) const TRAITS_MODULE_NAME: &str = "Traits";
pub(crate) const RUST_MODULE_NAME: &str = "Rust";

pub struct Context {
    build_context: BuildContext,
    name_tracker: NamesTracker,
}

impl Context {
    pub fn new(build_context: BuildContext, name_tracker: NamesTracker) -> Self {
        Self {
            build_context,
            name_tracker,
        }
    }
}

pub trait Parser<T>
where
    Self: Sized,
{
    fn parse(data: &T, context: &mut Context) -> anyhow::Result<Self>;
}