flower_core/lib.rs
1//! flower-core — the frontend-neutral structural editing model for config files.
2//!
3//! Given a config document's bytes and format, it exposes the document as a
4//! navigable projection of fig's `Value` — plus structural navigation and
5//! path-addressed edits routed through fig's lossless editor. It knows nothing
6//! about terminals, GUIs, or the filesystem — a frontend (flower-ratatui,
7//! a future flower-gpui, …) renders the projection and drives the model's
8//! methods; the embedder owns file I/O.
9//!
10//! There are two projections, selected by [`ViewMode`], over one document and one
11//! set of edits:
12//!
13//! - the **[`tree`]** — every visible node at once, indented by depth
14//! ([`Model::rows`]). The document as a document.
15//! - the **[`page`]** — one container at a time, pushed and popped
16//! ([`Model::page`]), with containers that fit the [`InlineBudget`] inlined.
17//! The document as a settings menu, and the one that stays legible when it is
18//! deep — or, under a generous budget, the whole document on one page.
19
20pub mod backend;
21pub mod format;
22pub mod model;
23pub mod page;
24pub mod schema;
25pub mod tree;
26
27pub use backend::{Backend, BackendError, EditOp, FigBackend};
28pub use format::detect;
29pub use model::{Mode, Model, ViewMode};
30pub use page::{InlineBudget, ItemKind, Page, PageItem};
31pub use schema::{Constraint, FieldRule, FieldRuleExt, Schema};
32pub use tree::{Row, VKind};
33
34// The generic, prov-agnostic pieces (path matching, field type, controlled
35// vocabulary, presentation hints) live in fig-schema now; re-exported here so
36// existing callers importing them from flower_core keep working.
37//
38// **This list is the reachability boundary.** An embedder that depends on
39// flower and not on fig-schema — which is the arrangement flower's facade
40// exists to offer — can name a fig-schema type only if it appears here, so a
41// new type upstream is invisible downstream until it is added.
42//
43// The asymmetry is easy to miss because it does not apply to *methods*:
44// `FieldRule` and `Schema` are plain aliases (see `schema`), so a new inherent
45// method on either arrives free and needs no edit here. Only names need
46// naming. An embedder can therefore end up able to call a method and unable to
47// name the type it returns, which is a compile error a long way from its
48// cause.
49//
50// It is also not something a semver check can catch: adding a type upstream is
51// additive and passes, while remaining unreachable through this list. Adding a
52// fig-schema type is two edits, and this is the second.
53pub use fig_schema::{
54 Cardinality, Consequence, FieldType, Icon, PathPat, Presentation, Seg, SegPat, Severity, Term,
55 Tint, Validation, guards_without_terms,
56};