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;
35pub mod object;
36pub mod option;
37pub mod pipeline;
38pub mod tree;
39pub mod validation;
40pub mod xmltype;
41
42pub mod prelude {
43    pub use crate::datamodel::DataModel;
44    pub use crate::exporters::Templates;
45    pub use crate::validation::Validator;
46}
47
48pub mod json {
49    pub mod export;
50    pub mod import;
51    pub mod schema;
52    pub mod validation;
53}
54
55pub mod jsonld {
56    pub mod export;
57    pub mod schema;
58}
59
60pub(crate) mod markdown {
61    pub mod frontmatter;
62    pub(crate) mod parser;
63    pub(crate) mod position;
64}
65
66#[cfg(feature = "openai")]
67pub mod llm {
68    pub mod extraction;
69    pub mod input;
70}
71
72pub mod bindings {
73    #[cfg(feature = "python")]
74    pub(crate) mod python;
75
76    #[cfg(feature = "wasm")]
77    pub(crate) mod wasm;
78}
79
80pub mod linkml {
81    pub mod export;
82    pub mod import;
83    pub mod schema;
84}
85
86#[cfg(feature = "python")]
87#[pymodule(name = "mdmodels_core")]
88fn mdmodels_core(m: &Bound<'_, PyModule>) -> PyResult<()> {
89    m.add("__version__", env!("CARGO_PKG_VERSION"))?;
90    m.add("__all__", ["DataModel", "Templates"])?;
91    m.add_class::<python::DataModel>()?;
92    m.add_class::<Templates>()?;
93    Ok(())
94}