Skip to main content

moss_core/
lib.rs

1//! moss-core: Pure Rust content processing.
2//!
3//! Zero I/O, zero async. Takes strings in, returns strings out.
4//! All filesystem access happens in the Tauri layer.
5//!
6//! **Panic-free contract:** Every public function in moss-core is invoked from
7//! Tauri command handlers in the host process. The host is configured with
8//! `panic = "abort"` for release builds, so any panic on user input crashes
9//! the whole desktop app (see fix in `date.rs` for the editor-mount panic on
10//! Chinese filenames). Treat moss-core as panic-free on user input: never
11//! `unwrap`/`expect` a value derived from arbitrary user data, and never use
12//! byte-indexed `&str` slicing without a `char_boundary` guarantee.
13
14#![forbid(unsafe_code)]
15// `clippy::string_slice` flags `&s[..n]` byte-indexed slicing on `&str`. That
16// pattern crashed the editor on `纽约诸法门.md` — `len() < 10` is bytes, not
17// chars, so the guard let the slice cut inside `法`. Safe call sites must
18// carry a per-site `#[allow(clippy::string_slice)]` with a one-line rationale
19// (e.g. "char-aligned: pos came from `find('/')`"). Audited at PR time, not
20// "we hope no one writes the bug shape again."
21#![deny(clippy::string_slice)]
22// `clippy::unwrap_used` / `clippy::expect_used` enforce the second half of the
23// panic-free contract: production code must never `.unwrap()` / `.expect()`
24// a value that could be `None`/`Err` at runtime. Test code (`#[cfg(test)]
25// mod tests`) is exempted via `cfg_attr(not(test), ...)` because tests
26// legitimately want to fail fast on assertion violations. Safe call sites
27// must annotate with `#[allow(clippy::unwrap_used)]` + per-site rationale,
28// same pattern as `clippy::string_slice`.
29#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used))]
30
31pub mod ast;
32pub mod asset_paths;
33pub(crate) mod path_ext;
34pub mod asset_snapshot;
35pub mod content_graph;
36pub mod contract;
37pub mod csv_table;
38pub mod date;
39pub mod extract_headings;
40pub use extract_headings::{extract_headings, HeadingInfo};
41pub mod home;
42pub mod frontmatter;
43pub mod frontmatter_union;
44pub mod heading;
45pub mod link_candidates;
46pub mod link_completions;
47pub mod heading_anchor;
48pub mod media;
49pub mod page_kind;
50pub use page_kind::PageKind;
51pub mod render;
52pub mod resolve;
53pub mod resolved;
54pub use resolved::{Resolved, ResolvedOrigin};
55pub mod schema;
56pub mod schema_fields;
57pub mod sort;
58pub mod shortcode_tokens;
59pub mod validation;