Skip to main content

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 small all-scalar groups inlined. The document as a
17//!   settings menu, and the one that stays legible when it is deep.
18
19pub mod backend;
20pub mod format;
21pub mod model;
22pub mod page;
23pub mod schema;
24pub mod tree;
25
26pub use backend::{Backend, BackendError, EditOp, FigBackend};
27pub use format::detect;
28pub use model::{Mode, Model, ViewMode};
29pub use page::{ItemKind, Page, PageItem};
30pub use schema::{Constraint, FieldRule, FieldRuleExt, Schema};
31pub use tree::{Row, VKind};
32
33// The generic, prov-agnostic pieces (path matching, field type, controlled
34// vocabulary, presentation hints) live in fig-schema now; re-exported here so
35// existing callers importing them from flower_core keep working.
36//
37// **This list is the reachability boundary.** An embedder that depends on
38// flower and not on fig-schema — which is the arrangement flower's facade
39// exists to offer — can name a fig-schema type only if it appears here, so a
40// new type upstream is invisible downstream until it is added.
41//
42// The asymmetry is easy to miss because it does not apply to *methods*:
43// `FieldRule` and `Schema` are plain aliases (see `schema`), so a new inherent
44// method on either arrives free and needs no edit here. Only names need
45// naming. An embedder can therefore end up able to call a method and unable to
46// name the type it returns, which is a compile error a long way from its
47// cause.
48//
49// It is also not something a semver check can catch: adding a type upstream is
50// additive and passes, while remaining unreachable through this list. Adding a
51// fig-schema type is two edits, and this is the second.
52pub use fig_schema::{
53    Cardinality, Consequence, FieldType, Icon, PathPat, Presentation, Seg, SegPat, Severity, Term,
54    Tint, Validation, guards_without_terms,
55};