Skip to main content

nativeview_codegen/frontend/
mod.rs

1//! Input specification parsers: React Native specs (`rn_spec`) and declarative hybrid Rust specs
2//! (`hybrid_spec`, delegated to [`nativeview_hybrid_spec::frontend`]).
3
4pub mod rn_spec;
5
6/// Declarative hybrid Rust spec frontend (delegated to [`nativeview_hybrid_spec::frontend`]).
7pub mod hybrid_spec {
8    use std::path::Path;
9
10    use crate::error::CodegenError;
11    use crate::schema::hybrid::HybridFileSpec;
12
13    /// Parses a declarative Rust `.rs` hybrid specification source string into a validated
14    /// [`HybridFileSpec`].
15    pub fn parse_hybrid_rust_spec(source: &str) -> Result<HybridFileSpec, CodegenError> {
16        nativeview_hybrid_spec::parse_hybrid_rust_spec(source).map_err(CodegenError::from)
17    }
18
19    /// Reads and parses a `.rs` hybrid specification file on disk.
20    pub fn parse_hybrid_rust_spec_file(path: &Path) -> Result<HybridFileSpec, CodegenError> {
21        nativeview_hybrid_spec::parse_hybrid_rust_spec_file(path).map_err(CodegenError::from)
22    }
23}
24
25pub use hybrid_spec::{parse_hybrid_rust_spec, parse_hybrid_rust_spec_file};
26pub use rn_spec::{parse_rn_spec, parse_rn_spec_file};