Skip to main content

mdmodels_core/
lib.rs

1/*
2 * Copyright (c) 2025 Jan Range
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 *
22 */
23
24#[cfg(feature = "python")]
25use crate::bindings::python;
26#[cfg(feature = "python")]
27use crate::exporters::Templates;
28#[cfg(feature = "python")]
29use pyo3::prelude::*;
30
31pub mod attribute;
32pub mod datamodel;
33pub mod error;
34pub mod exporters;
35#[cfg(not(target_arch = "wasm32"))]
36pub mod git;
37pub mod object;
38pub mod option;
39pub mod pipeline;
40pub mod tree;
41pub mod validation;
42pub mod xmltype;
43
44pub mod prelude {
45    pub use crate::datamodel::DataModel;
46    pub use crate::exporters::Templates;
47    pub use crate::validation::Validator;
48}
49
50pub mod json {
51    pub mod export;
52    pub mod import;
53    pub mod schema;
54    pub mod validation;
55}
56
57pub mod jsonld {
58    pub mod export;
59    pub mod schema;
60}
61
62pub(crate) mod markdown {
63    pub mod frontmatter;
64    pub(crate) mod parser;
65    pub(crate) mod position;
66}
67
68#[cfg(feature = "openai")]
69pub mod llm {
70    pub mod extraction;
71    pub mod input;
72}
73
74pub mod bindings {
75    #[cfg(feature = "python")]
76    pub(crate) mod python;
77
78    #[cfg(feature = "wasm")]
79    pub(crate) mod wasm;
80}
81
82pub mod linkml {
83    pub mod export;
84    pub mod import;
85    pub mod schema;
86}
87
88#[cfg(feature = "python")]
89#[pymodule(name = "mdmodels_core")]
90fn mdmodels_core(m: &Bound<'_, PyModule>) -> PyResult<()> {
91    m.add("__version__", env!("CARGO_PKG_VERSION"))?;
92    m.add("__all__", ["DataModel", "Templates"])?;
93    m.add_class::<python::DataModel>()?;
94    m.add_class::<Templates>()?;
95    Ok(())
96}