JFLib

doc_core#

structured documents, sources, citations and undo/redo -- crate root lib/doc_core/lib.rs

Structured document and source model, with atomic edits and bounded undo/redo.
New native functionality, independent of UI, file formats and operating system.

doc_core crate root#

  • type Id = u64 Stable identity inside a document. IDs are never reused by an editing session.

  • enum ParagraphChange A paragraph command applied atomically to a selection. Individual properties preserve each paragraph's other overrides; Format replaces the complete set of overrides.

    • Style(ParagraphStyle)
    • Format(ParagraphFormat)
    • Properties(ParagraphFormat)
    • Tabs(TabStops) -- Replace the effective tab list, preserving explicit suppression of inherited stops.
    • Alignment(Alignment)
    • PageBreakBefore(bool)
  • enum ParagraphStyle Stable paragraph-style identity. Definitions and inheritance belong to the document.

    • Normal
    • Title
    • Heading1
    • Heading2
    • Named(u32)
  • enum Inline Text or a structured citation; a citation remains linked to a source after edits.

    • Text(String)
    • StyledText { text: String, format: TextFormat, }
    • Citation { source: Id, locator: String, }
    • CitationCluster(Vec<CitationItem>)
    • Formula(Formula) -- Bounded live arithmetic, using the containing table for cell references.
    • Bibliography
    • NoteReference(Id) -- Stable note identity; a note has exactly one anchor, in the main body.

impl Inline

  • fn text(&self) -> Option<&str> Editable text, excluding generated citation and bibliography fields.

  • fn format(&self) -> TextFormat Character overrides; plain text and fields inherit the paragraph style.

  • fn with_format(text: String, format: TextFormat) -> Self Canonical text node: inherited formatting uses the compact plain-text variant.

  • struct Paragraph A paragraph with stable identity and structured inline content.

    • id: Id
    • style: ParagraphStyle
    • format: ParagraphFormat
    • content: Vec<Inline>
  • struct Document Document data. Public for codecs; validate() is mandatory at trust boundaries.

    • tables: Vec<Table>
    • table_styles: Vec<TableStyle>
    • styles: Vec<StyleDefinition>
    • paragraphs: Vec<Paragraph>
    • sources: Vec<Source>
    • notes: Vec<Note>
    • page: PageSettings
  • enum Error Invalid structure, dangling citation, source in use, or a resource budget exceeded.

    • Invalid
    • Missing
    • InUse
    • Limit

impl Document

  • fn source(&self, id: Id) -> Option<&Source> Lookup by stable source identity.

  • fn validate(&self) -> Result<(), Error> Validate identities, source references, XML-compatible text and conservative budgets.

  • fn byte_size(&self) -> usize Approximate retained payload size for history budgets (including node overhead).

  • fn citation_text(&self, source: Id, locator: &str) -> String Cached display text for a citation; this basic author/year rendering is not CSL/APA.

  • fn paragraph_text(&self, p: &Paragraph) -> String Paragraph text including live citation labels.

  • fn plain_text(&self) -> String Plain-text view used for counts and explicit text exports.

  • fn bibliography(&self) -> Vec<String> Deterministic basic list of cited sources, including notes at their anchor position.

  • enum Edit One atomic edit; invalid edits leave document, redo history and dirty state untouched.

    • InsertFormula { paragraph:Id, inline:usize, offset:usize, formula:Formula } -- Insert a live formula at a UTF-8 caret, retaining adjacent text and formatting.
    • SetFormula { paragraph:Id, inline:usize, formula:Formula } -- Replace a calculation field without touching its neighbours, as one undo step.
    • InsertTable { paragraph: Id, offset: usize, rows: usize, columns: usize }
    • ChangeTable { table: Id, change: TableChange }
    • SetTableStyle { style: TableStyle, table: Option<Id> }
    • SetStyleDefinition(StyleDefinition) -- Create or replace one definition; validation rejects cycles and dangling bases atomically.
    • RemoveField { paragraph: Id, inline: usize, } -- Remove one generated field by native position, including zero-width bibliography. Removing a note anchor removes its body in the same undo transaction.
    • ReplaceStoryFragment { paragraph: Id, start: usize, end: usize, fragment: DocumentFragment, } -- Replace a rich selection, including complete fields, in one atomic transaction. Imported identities are remapped and exactly identical sources are reused.
    • FormatStoryParagraphs { paragraph: Id, start: usize, end: usize, change: ParagraphChange, } -- Change all paragraphs touched by a story selection without changing their inline objects. An end caret at the beginning of the next paragraph excludes that paragraph.
    • ReplaceStoryText { paragraph: Id, start: usize, end: usize, text: String, paragraph_breaks: bool, } -- Replace a UTF-8 selection in one complete story (main body or one note). Newlines optionally create paragraphs; false keeps them as soft line breaks inside a run. Crossing generated fields is rejected atomically, including the paragraph structure.
    • FormatStoryText { paragraph: Id, start: usize, end: usize, format: TextFormat, } -- Apply character overrides over several paragraphs as a single history step.
    • ReplaceStoryFormat { paragraph: Id, start: usize, end: usize, format: TextFormat, } -- Replace all character overrides in a story range as one undoable edit. Default formatting clears overrides and restores paragraph-style inheritance. Text, paragraph styles and generated fields retain their original structure; selections intersecting generated fields are rejected before committing.
    • ReplaceParagraphText { paragraph: Id, start: usize, end: usize, text: String, } -- Replace a UTF-8 range across adjacent formatted runs; generated fields are protected.
    • FormatParagraphText { paragraph: Id, start: usize, end: usize, format: TextFormat, } -- Apply explicit character overrides across adjacent formatted runs as one transaction.
    • SplitParagraphText { paragraph: Id, start: usize, end: usize, } -- Split a selection across adjacent formatted runs into a new paragraph atomically.
    • SplitParagraph { paragraph: Id, inline: usize, start: usize, end: usize, } -- Replace a selection in one text run with a paragraph boundary. Formatting and all following fields/notes move intact; returns the new paragraph identity. A heading split at its end continues in Normal style. The new half never repeats a page break.
    • JoinParagraphs { first: Id, second: Id, } -- Join adjacent paragraphs in one story, retaining the first identity/style and every inline object. Matching character overrides at the seam coalesce into one text run.
    • InsertNote { paragraph: Id, inline: usize, offset: usize, kind: NoteKind, text: String, } -- Insert one note at a main-body UTF-8 text caret, preserving both text formatting and suffix.
    • SetNoteKind { note: Id, kind: NoteKind, } -- Convert a note without changing its identity, anchor or body.
    • RemoveNote(Id) -- Remove a note and its sole anchor in one undo transaction.
    • FormatText { paragraph: Id, inline: usize, start: usize, end: usize, format: TextFormat, } -- Format a UTF-8 range in one text run, preserving its prefix/suffix and field neighbors.
    • SetParagraphFormat { paragraph: Id, format: ParagraphFormat, }
    • SetPage(PageSettings)
    • ReplaceMatch { found: TextMatch, expected: String, replacement: String, } -- Replace a previously found range only if its text still matches the expected value.
    • ReplaceAll { query: String, replacement: String, options: SearchOptions, } -- One undo transaction for all matching text, excluding generated fields.
    • SetText { paragraph: Id, inline: usize, text: String, } -- Replace an editable run. An empty paragraph exposes virtual run zero; writing a nonempty value creates its first text run, while an empty value preserves the structure.
    • SetStyle { paragraph: Id, style: ParagraphStyle, }
    • AddParagraph { after: Id, }
    • InsertBibliography { after: Id, }
    • RemoveParagraph(Id)
    • PutSource(Source)
    • ImportSources(Vec<Source>) -- Import a complete list atomically, allocating IDs and skipping exact content duplicates.
    • MergeSources(SourceMerge) -- Merge two existing sources and redirect all citation occurrences in one transaction.
    • RemoveSource(Id)
    • Cite { paragraph: Id, source: Id, locator: String, }
    • InsertCitation { paragraph: Id, inline: usize, offset: usize, items: Vec<CitationItem>, } -- Insert a citation at a UTF-8 caret inside one editable run, preserving its formatting. The suffix is always retained as editable text, including insertion at the run end.
    • UpdateCitation { paragraph: Id, inline: usize, items: Vec<CitationItem>, } -- Replace an existing citation's items in a single undo transaction.
    • ConvertCitationToText { paragraph: Id, inline: usize, } -- Replace one citation field by its current display text, disconnecting its sources.
    • RemoveCitation { paragraph: Id, inline: usize, }
  • struct Editor Editing session with a saved checkpoint and bounded snapshot history.

impl Editor

  • fn new(doc: Document) -> Result<Self, Error> Create a validated editing session; loading starts with an empty history.
  • fn document(&self) -> &Document Current immutable document.
  • fn revision(&self) -> u64 Changes on every successful content edit/undo/redo; suitable for a layout cache.
  • fn state_id(&self) -> u64 Identity of this history state. Unlike revision(), undo/redo restore this identity, allowing a view to restore transaction-associated caret positions without model data. Identities are local to one Editor session; no-op/failed edits do not change them.
  • fn dirty(&self) -> bool Content differs from the last successfully saved checkpoint.
  • fn mark_saved(&mut self) Call only after a successful durable write.
  • fn can_undo(&self) -> bool Whether an undo step exists.
  • fn can_redo(&self) -> bool Whether a redo step exists.
  • fn undo(&mut self) -> bool Undo a complete model edit, including source/citation changes.
  • fn redo(&mut self) -> bool Redo a complete model edit.
  • fn apply(&mut self, edit: Edit) -> Result<Id, Error> Apply an edit; returns the created/affected identity. New sources use id=0.
  • fn apply_checked(&mut self, edit:Edit,check:impl FnOnce(&Document)->Result<(),Error>)->Result<Id,Error> Validate an additional shared constraint before committing a transaction. A rejected edit leaves identities, history, saved state and revision untouched.

doc_core/citation.rs#

Source: lib/doc_core/citation.rs

Structured multi-source citation fields, rendering and source-usage lookup.
New shared document functionality, independent of external citation processors.
  • struct CitationItem One source reference in an ordered citation field. Affixes are kept verbatim.
    • source: Id -- Stable document-local source ID; zero is only an unbound draft value.
    • locator: String -- Page or other location, currently rendered with the basic style's page prefix.
    • prefix: String -- Literal text before this reference, including any desired whitespace.
    • suffix: String -- Literal text after this reference, including any desired whitespace.
    • suppress_author: bool -- Hide personal or corporate authors in this reference.
    • suppress_year: bool -- Hide the publication year in this reference.
    • suppress_title: bool -- Hide the title fallback when this source has no authors.

impl CitationItem

  • fn validate(&self) -> Result<(), Error> Validate field-code-safe text and the source ID range; references require a document.

  • struct CitationLocation Location of one citation field, even when that field cites a source more than once.

    • paragraph: Id -- Stable paragraph ID containing the field.
    • inline: usize -- Zero-based inline index of the field within its paragraph.

impl Inline

  • fn citation(items: Vec<CitationItem>) -> Result<Self, Error> Create a bounded citation field, keeping simple single references in the legacy form. Source existence is checked when validating or applying the containing document.
  • fn citation_items(&self) -> Option<Vec<CitationItem>> Owned edit draft for either citation representation; other inline nodes return None.

impl Document

  • fn citation_cluster_text(&self, items: &[CitationItem]) -> String Basic author/year rendering of an ordered multi-source field; this is not CSL/APA. Prefixes/suffixes are literal. Author suppression hides people/corporations; title suppression hides the title fallback of anonymous sources. Locators use "S. ".
  • fn cited_source_ids(&self) -> Vec<Id> Distinct cited source IDs in first-use order, scanning the document only once. Bibliography fields and unreferenced sources do not add IDs. Validate the document at trust boundaries; for valid documents at most 1,024 IDs are returned.
  • fn source_uses(&self, source: Id) -> Vec<CitationLocation> Citation fields using a source, once per field in document order.

doc_core/format.rs#

Source: lib/doc_core/format.rs

Document formatting in typographic units; independent of pixels, GUI styles and codecs.
  • enum TextColor Direct WordprocessingML text color; automatic remains distinct from inherited color.

    • Auto
    • Rgb(u32) -- Opaque RGB (0x000000..=0xFFFFFF), without an alpha channel.
  • struct TextFormat Explicit character overrides. None inherits the paragraph style; false can disable bold headings.

    • font_family: Option<FontFamily>
    • bold: Option<bool>
    • italic: Option<bool>
    • underline: Option<bool>
    • strike: Option<bool>
    • color: Option<TextColor>
    • size_half_points: Option<u16>
    • highlight: Option<Highlight>
    • positioning: Option<TextPositioning>

impl TextFormat

  • fn common(self, other: Self) -> Self Keep only equal, effective properties when summarizing a selection. A missing property in the result means mixed formatting, not an instruction to change text.

  • fn explicit(self, style: ParagraphStyle) -> Self Capture the original built-in defaults. For a document's named or modified styles, use Document::resolve_text(...).explicit() to include the document's inheritance.

  • fn overlay(self, direct: Self) -> Self Apply only properties present in direct, preserving all other overrides.

  • fn validate(self) -> Result<(), Error> Supported size range: 4–144 points, in half-point increments.

  • fn resolve(self, style: ParagraphStyle) -> ResolvedFormat Resolve the original built-in defaults. Use Document::resolve_text for style graphs.

  • struct ResolvedFormat Fully resolved attributes consumed by layout and rendering.

    • font_family: FontFamily
    • bold: bool
    • italic: bool
    • underline: bool
    • strike: bool
    • size_half_points: u16
    • color: u32
    • highlight: Highlight
    • positioning: TextPositioning

impl ResolvedFormat

  • fn explicit(self) -> TextFormat Capture all resolved properties as direct formatting for cross-style transfers.

  • fn display_size_half_points(self) -> u16 Shared typographic policy: scripts use two thirds of the nominal size, rounded to half points. The nominal size remains unchanged in the document and file formats.

  • fn baseline_shift(self) -> i32 Baseline displacement in twips, positive downwards. GUI zoom never enters this value.

  • enum Alignment Horizontal alignment of a paragraph's lines.

    • Left
    • Center
    • Right
    • Justify
  • struct ParagraphFormat Paragraph overrides. Distances are twips (1/20 point); line spacing is in 1/240 lines.

    • explicit: u16 -- Explicit default-valued overrides: alignment, before, after, line, left, right, first-line, page break, tabs (bits 0..8). Non-default values are always overrides.
    • alignment: Alignment
    • before: u16
    • after: u16
    • line: u16
    • left: u16
    • right: u16
    • first_line: i32 -- Additional first-line indent in twips; negative values create a hanging indent. Applies once per paragraph, including paragraphs that continue on another page.
    • page_break_before: bool
    • tabs: crate::TabStops -- Custom tab declarations, merged by position through the style hierarchy (bit 8).

impl ParagraphFormat

  • fn select(self, mask: u16) -> Self Retain only selected properties as an explicit patch (bits follow explicit).

  • fn overlay(self, patch: Self) -> Self Merge a property patch without making untouched inherited values explicit.

  • fn mask(self) -> u16 The properties this value overrides. This retains compatibility with existing callers that construct non-default properties with a struct update.

  • fn over(self, mut base: Self) -> Self Apply this set of overrides to an inherited paragraph format.

  • fn validate(self, page: PageSettings) -> Result<(), Error> Validate resolved spacing and ensure that the paragraph retains a usable text area.

  • struct PageSettings One document-wide page setup in twips. A4 portrait with 25 mm margins by default.

    • width: u32
    • height: u32
    • top: u32
    • right: u32
    • bottom: u32
    • left: u32

impl PageSettings

  • fn content_width(self) -> u32 Remaining line width after page margins; saturating for unvalidated public models.
  • fn content_height(self) -> u32 Remaining text height after page margins.
  • fn validate(self) -> Result<(), Error> Keep arithmetic bounded and at least two inches available for text in each direction.

doc_core/tabs.rs#

Source: lib/doc_core/tabs.rs

  • enum TabAlignment Tab alignment. Clear removes an inherited stop at the same position.

    • Left -- Tab alignment. Clear removes an inherited stop at the same position.
    • Center -- Tab alignment. Clear removes an inherited stop at the same position.
    • Right -- Tab alignment. Clear removes an inherited stop at the same position.
    • Decimal -- Tab alignment. Clear removes an inherited stop at the same position.
    • Bar -- Tab alignment. Clear removes an inherited stop at the same position.
    • Clear -- Tab alignment. Clear removes an inherited stop at the same position.
  • enum TabLeader Repeated visual fill between the cursor and a tab target (never document text).

    • None -- Repeated visual fill between the cursor and a tab target (never document text).
    • Dot -- Repeated visual fill between the cursor and a tab target (never document text).
    • Hyphen -- Repeated visual fill between the cursor and a tab target (never document text).
    • Underscore -- Repeated visual fill between the cursor and a tab target (never document text).
    • Heavy -- Repeated visual fill between the cursor and a tab target (never document text).
    • MiddleDot -- Repeated visual fill between the cursor and a tab target (never document text).

impl TabAlignment

  • fn name(self) -> &'static str
  • fn from_name(name: &str) -> Option<Self>

impl TabLeader

  • fn name(self) -> &'static str

  • fn from_name(name: &str) -> Option<Self>

  • struct TabStop Position in twips from the page's left text margin, independent of paragraph indents.

    • position: i32 -- Position in twips from the page's left text margin, independent of paragraph indents.
    • alignment: TabAlignment -- Position in twips from the page's left text margin, independent of paragraph indents.
    • leader: TabLeader -- Position in twips from the page's left text margin, independent of paragraph indents.

impl TabStop

  • fn clear(position: i32) -> Self

  • fn validate(self) -> Result<(), Error>

  • struct TabStops Sorted, unique tab definitions. Bounded storage preserves the lightweight Copy paragraph-format contract; overflowing inheritance is rejected by validation.

impl TabStops

  • fn as_slice(&self) -> &[TabStop]
  • fn is_empty(&self) -> bool
  • fn validate(&self) -> Result<(), Error>
  • fn set(&mut self, stop: TabStop) -> Result<(), Error> Insert or replace a position. On error this collection remains unchanged.
  • fn remove(&mut self, position: i32) Remove a definition locally; use TabStop::clear to suppress inherited stops.
  • fn relative_to(self, inherited: Self) -> Result<Self, Error> Declarations that transform inherited effective stops into the desired list. Desired stops cannot contain clear markers. No input is changed on overflow.

doc_core/tables.rs#

Source: lib/doc_core/tables.rs

  • enum CellAlignment

    • Top
    • Center
    • Bottom
  • struct TableCell

    • id: Id
    • row_span: u16 -- Grid extent of an anchor; both are zero for a covered grid slot.
    • column_span: u16
    • paragraphs: Vec<Paragraph>
    • fill: Option<u32>
    • alignment: CellAlignment
    • borders: crate::CellBorders
  • struct TableRow

    • cells: Vec<TableCell>
    • min_height: u32 -- Requested row height in twips. Zero means automatic for AtLeast.
    • height_rule: RowHeightRule
    • cant_split: bool -- Keep the row on one page when possible. Oversized rows still flow without losing text.
    • grid_before: u16 -- Omitted leading/trailing grid intervals. These are space, not empty cells.
    • grid_after: u16
  • enum RowHeightRule Whether cell content may increase the requested row height.

    • AtLeast
    • Exact -- A positive fixed height; overflow stays in the model and is clipped in the view.
  • struct Table A body or cell block immediately before before. Several tables may share an anchor, in storage order.

    • id: Id
    • before: Id
    • position: Option<crate::TablePosition>
    • header_rows: u16 -- Contiguous leading rows repeated at automatic page breaks.
    • style: Option<String>
    • look: crate::TableLook
    • border_override: bool -- False inherits the border from the named table style.
    • columns: Vec<u32>
    • rows: Vec<TableRow>
    • padding: u16 -- Uniform cell padding in twips (1/20 point).
    • border_width: u16 -- Uniform border width in eighth-points, matching WordprocessingML w:sz.
    • border_color: u32 -- Opaque RGB color; application themes do not change it.
  • enum TableChange Structural operations are one validated undo transaction; indices are zero based.

    • Position(Option<crate::TablePosition>)
    • Borders { row:usize, column:usize, borders:crate::CellBorders }
    • HeaderRows(u16)
    • Style { style: Option<String>, look: crate::TableLook }
    • Look(crate::TableLook)
    • Merge { row: usize, column: usize, rows: usize, columns: usize, }
    • Split { row: usize, column: usize, }
    • Properties { row: usize, column: usize, width: u32, height: u32, height_rule: RowHeightRule, cant_split: bool, fill: Option<u32>, alignment: CellAlignment, }
    • InsertRow(usize)
    • RemoveRow(usize)
    • InsertColumn(usize)
    • RemoveColumn(usize)
    • Columns(Vec<u32>)
    • RowHeight { row: usize, height: u32, }
    • RowSizing { row: usize, height: u32, rule: RowHeightRule } -- Set height and rule together. RowHeight alone preserves the current rule.
    • RowBreak { row: usize, allow_split: bool }
    • Cell { row: usize, column: usize, fill: Option<u32>, alignment: CellAlignment, }
    • Appearance { padding: u16, border_width: u16, border_color: u32, }
    • Delete

impl Table

  • fn width(&self) -> u32
  • fn cell(&self, row: usize, column: usize) -> Option<&TableCell>
  • fn cells(&self) -> impl Iterator<Item = &TableCell>

impl Document

  • fn table(&self, id: Id) -> Option<&Table>
  • fn cell(&self, id: Id) -> Option<&TableCell>
  • fn table_location(&self, paragraph: Id) -> Option<(Id, usize, usize)> Table, row and column owning a paragraph; cells never share a text-selection story.
  • fn cell_for_paragraph(&self, paragraph: Id) -> Option<&TableCell>
  • fn paragraph_bounds(&self, paragraph: Id) -> (u32, u32) Physical horizontal text bounds in twips. Cell padding is part of its text origin.
  • fn body_paragraphs(&self) -> impl Iterator<Item = &Paragraph> Reading order, excluding note bodies. Tables precede their main-body anchor.
  • fn paragraph_group(&self, id: Id) -> Option<&[Paragraph]> One cell, one note, or a contiguous main-body segment bounded by tables.

doc_core/table_grid.rs#

Source: lib/doc_core/table_grid.rs

impl TableCell

  • fn is_covered(&self) -> bool

impl Table

  • fn omitted(&self,row:usize,column:usize)->bool
  • fn anchors(&self) -> impl Iterator<Item = (usize, usize, &TableCell)> Visible cells, in row-major order, together with their grid origins.
  • fn origin(&self, row: usize, column: usize) -> Option<(usize, usize)> Resolve any covered grid position to the cell that owns it.
  • fn cell_width(&self, row: usize, column: usize) -> Option<u32>

doc_core/table_tree.rs#

Source: lib/doc_core/table_tree.rs

/// Maximum table nesting, including the outermost table.
MAX_TABLE_DEPTH: usize = 8

impl Document

  • fn table_parent(&self, id: Id) -> Option<(Id, usize, usize)> Immediate enclosing table and cell coordinates, or None for the main story.
  • fn table_depth(&self, id: Id) -> Result<usize, Error> One-based containment depth. Rejects orphan anchors and cycles, even before validation.
  • fn table_bounds(&self, id: Id) -> Result<(u32, u32), Error> Horizontal space provided by a table's enclosing story, in document twips.
  • fn ordered_tables(&self) -> Vec<&Table> Depth-first block order, including tables in cells.

doc_core/table_position.rs#

Source: lib/doc_core/table_position.rs

  • enum TableHorizontal

    • Page
    • Margin
    • Column
  • enum TableVertical

    • Page
    • Margin
    • Paragraph
  • struct TablePosition A floating table remains anchored to Table.before; its content is a normal cell story.

    • horizontal: TableHorizontal
    • vertical: TableVertical
    • x: i32
    • y: i32
    • distance: [u16;4] -- Top, right, bottom, left distances from surrounding text.
    • overlap: bool

impl Document

  • fn table_x(&self, table:&Table)->Result<u32,Error> Absolute horizontal origin, including a floating ancestor's displacement.

doc_core/table_styles.rs#

Source: lib/doc_core/table_styles.rs

  • struct TableLook Conditional regions enabled on a table. Header styling and repeated rows are independent.

    • first_row: bool
    • last_row: bool
    • first_column: bool
    • last_column: bool
    • banded_rows: bool
    • banded_columns: bool
  • struct TableRegion Absent values inherit the whole-table region. Explicit white removes inherited shading.

    • fill: Option<u32>
    • text: TextFormat
  • enum TableRegionKind Stable conditional regions shared by editors, codecs and automation.

    • Body -- Stable conditional regions shared by editors, codecs and automation.
    • FirstRow -- Stable conditional regions shared by editors, codecs and automation.
    • LastRow -- Stable conditional regions shared by editors, codecs and automation.
    • FirstColumn -- Stable conditional regions shared by editors, codecs and automation.
    • LastColumn -- Stable conditional regions shared by editors, codecs and automation.
    • Band1 -- Stable conditional regions shared by editors, codecs and automation.
    • Band2 -- Stable conditional regions shared by editors, codecs and automation.
    • Band1Vertical -- Stable conditional regions shared by editors, codecs and automation.
    • Band2Vertical -- Stable conditional regions shared by editors, codecs and automation.
    • TopLeft -- Stable conditional regions shared by editors, codecs and automation.
    • TopRight -- Stable conditional regions shared by editors, codecs and automation.
    • BottomLeft -- Stable conditional regions shared by editors, codecs and automation.
    • BottomRight -- Stable conditional regions shared by editors, codecs and automation.

impl TableRegionKind

  • const ALL: [Self; 13] = [Self::Body,Self::FirstRow,Self::LastRow,Self::FirstColum ...

  • fn key(self)->&'static str

  • struct TableStyle A document-owned style. IDs remain stable when its display name or formatting changes.

    • id: String
    • name: String
    • based_on: Option<String>
    • border_inherit: bool -- Omit the border pair and inherit it. Raw values remain 4 / 808080 in this case.
    • border_width: u16
    • border_color: u32
    • row_band_size: Option<u16> -- None inherits; without a base, one row/column constitutes a band.
    • column_band_size: Option<u16>
    • body: TableRegion
    • first_row: TableRegion
    • last_row: TableRegion
    • first_column: TableRegion
    • last_column: TableRegion
    • band1: TableRegion
    • band2: TableRegion
    • band1_vertical: TableRegion
    • band2_vertical: TableRegion
    • top_left: TableRegion
    • top_right: TableRegion
    • bottom_left: TableRegion
    • bottom_right: TableRegion

impl TableStyle

  • fn new(id: &str, name: &str) -> Self
  • fn derived(id:&str,name:&str,base:&str)->Self Start a live derived style without freezing any properties from its parent.
  • fn region_format(&self,kind:TableRegionKind)->TableRegion
  • fn region_format_mut(&mut self,kind:TableRegionKind)->&mut TableRegion
  • fn validate(&self) -> Result<(), Error>
  • fn region(&self, table: &Table, row: usize, column: usize) -> TableRegion Row/column banding, edge columns, edge rows, corners; direct cell/run formatting wins later. Call on a resolved definition when it has a parent.

impl Document

  • fn table_style_ids(&self) -> Vec<String> Available document definitions, including the shared built-in palette.
  • fn table_style(&self, id: &str) -> Option<TableStyle>
  • fn resolved_table_style(&self,id:&str)->Result<TableStyle,Error> Resolve at most 32 definitions; missing parents, cycles and excessive depth are errors.
  • fn table_style_depends_on(&self,id:&str,ancestor:&str)->bool Whether an existing style depends on a candidate parent, including itself.
  • fn table_region(&self, table: &Table, row: usize, column: usize) -> TableRegion Effective cell shading and character defaults; direct shading takes precedence.
  • fn table_border(&self, table: &Table) -> (u16, u32)
  • fn resolve_paragraph_text(&self, p: &Paragraph, direct: TextFormat) -> ResolvedFormat Table defaults precede paragraph styles and direct character overrides.

doc_core/cell_borders.rs#

Source: lib/doc_core/cell_borders.rs

  • enum BorderStyle
    • Nil
    • None
    • Single
    • Double
    • Dotted
    • Dashed

impl BorderStyle

  • fn name(self)->&'static str

  • fn parse(s:&str)->Option<Self>

  • enum BorderSide

    • Top
    • Right
    • Bottom
    • Left

impl BorderSide

  • const ALL:[Self;4] = [Self::Top,Self::Right,Self::Bottom,Self::Left]

  • fn name(self)->&'static str

  • fn opposite(self)->Self

  • struct CellBorder Width is 2..96 eighth-points for visible lines, color is opaque RGB. Nil suppresses a shared edge; None follows the table default. An absent cell property inherits without a local declaration.

    • style:BorderStyle -- Width is 2..96 eighth-points for visible lines, color is opaque RGB. Nil suppresses a shared edge; None follows the table default. An absent cell property inherits without a local declaration.
    • width:u16 -- Width is 2..96 eighth-points for visible lines, color is opaque RGB. Nil suppresses a shared edge; None follows the table default. An absent cell property inherits without a local declaration.
    • color:u32 -- Width is 2..96 eighth-points for visible lines, color is opaque RGB. Nil suppresses a shared edge; None follows the table default. An absent cell property inherits without a local declaration.
  • type CellBorders=[Option<CellBorder>;4]

impl CellBorder

  • const NIL:Self = Self{style:BorderStyle::Nil,width:0,color:0}
  • fn validate(self)->Result<(),Error>
  • fn visible(self)->bool
  • fn competing(self,other:Self)->Self Word's zero-spacing conflict rules for the supported line styles.

impl Document

  • fn cell_border(&self,t:&Table,row:usize,column:usize,side:BorderSide)->CellBorder
  • fn shared_cell_border(&self,t:&Table,row:usize,column:usize,side:BorderSide,unit:usize)->CellBorder One grid segment on a possibly merged cell edge. unit counts columns for top/bottom and rows for left/right. Direct cell properties precede table borders.

doc_core/character.rs#

Source: lib/doc_core/character.rs

Portable character properties shared by editing, styles and interchange.
  • enum Highlight Word's sixteen highlight colors plus an explicit removal of inherited highlighting. None on TextFormat inherits; Some(Highlight::None) clears it.
    • None
    • Yellow
    • Green
    • Cyan
    • Magenta
    • Blue
    • Red
    • DarkBlue
    • DarkCyan
    • DarkGreen
    • DarkMagenta
    • DarkRed
    • DarkYellow
    • DarkGray
    • LightGray
    • Black
    • White

impl Highlight

  • const ALL: [Self; 17] = [Self::None, Self::Yellow, Self::Green, Self::Cyan, Self: ... Stable palette order; these are document colors independent of the application theme.

  • fn name(self) -> &'static str

  • fn from_name(name: &str) -> Option<Self>

  • fn rgb(self) -> Option<u32> Opaque RGB; absence means that the paper remains visible.

  • fn from_rgb(rgb: u32) -> Option<Self> Exact palette match, never an approximate conversion of imported colors.

  • enum TextPositioning Mutually exclusive script positions; Baseline explicitly clears inherited positioning.

    • Baseline
    • Superscript
    • Subscript

impl TextPositioning

  • fn name(self) -> &'static str
  • fn from_name(name: &str) -> Option<Self>

doc_core/formula/mod.rs#

Source: lib/doc_core/formula/mod.rs

  • struct Formula A live calculation field. Expressions use Word's invariant English function names. Results are derived from the current document; no stale cache is authoritative.

    • expression: String
    • number_format: String
  • enum FormulaError Formula failures are displayable data, not failed document edits.

    • Syntax -- Formula failures are displayable data, not failed document edits.
    • Unsupported -- Formula failures are displayable data, not failed document edits.
    • Reference -- Formula failures are displayable data, not failed document edits.
    • Value -- Formula failures are displayable data, not failed document edits.
    • DivisionByZero -- Formula failures are displayable data, not failed document edits.
    • Cycle -- Formula failures are displayable data, not failed document edits.
    • Number -- Formula failures are displayable data, not failed document edits.
    • Limit -- Formula failures are displayable data, not failed document edits.

impl FormulaError

  • fn code(self)->&'static str Stable code for page rendering and automation; independent of UI language.

  • struct FormulaResult Display result with a separately inspectable error code. Numeric output is decimal text.

    • text:String -- Display result with a separately inspectable error code. Numeric output is decimal text.
    • error:Option<FormulaError> -- Display result with a separately inspectable error code. Numeric output is decimal text.

impl Formula

  • fn new(expression:&str,number_format:&str)->Result<Self,FormulaError> Parse a bounded supported expression and number picture before accepting an edit.
  • fn validate(&self)->Result<(),FormulaError> Validate public codec data without evaluating cell references.

impl Document

  • fn evaluate_formula(&self,paragraph:Id,formula:&Formula)->FormulaResult Evaluate a proposed formula at a paragraph's current table position. Arithmetic also works outside tables; cell references then return #REF!.
  • fn formula_result(&self,paragraph:Id,inline:usize)->Option<FormulaResult> Inspect one calculation field at its stable paragraph and inline position.

doc_core/styles.rs#

Source: lib/doc_core/styles.rs

Document font names and style inheritance. No platform or UI dependencies.
  • struct FontFamily A validated UTF-8 family name, retained even when the renderer must substitute a font.

impl FontFamily

  • fn new(name: &str) -> Result<Self, Error> Family names contain 1–96 UTF-8 bytes, without controls or surrounding whitespace.

  • fn as_str(&self) -> &str Original family name, without a style suffix.

  • struct StyleDefinition One paragraph style. Absent character/paragraph properties inherit from based_on. Built-in definitions can be replaced using the same identity. Level 9 means body text.

    • id: ParagraphStyle
    • name: String
    • based_on: Option<ParagraphStyle>
    • text: TextFormat
    • paragraph: ParagraphFormat
    • outline_level: Option<u8>

impl StyleDefinition

  • fn new(id: ParagraphStyle, name: &str) -> Self Create an otherwise inherited style, initially based on Normal.

impl Document

  • fn style_definition(&self, id: ParagraphStyle) -> Option<StyleDefinition> Explicit definition, or the original built-in definition when unmodified.
  • fn style_ids(&self) -> Vec<ParagraphStyle> Built-in and custom styles, in stable gallery order.
  • fn next_style_id(&self) -> ParagraphStyle Next unused custom identity. Style identities occupy a separate namespace.
  • fn resolve_text(&self, direct: TextFormat, style: ParagraphStyle) -> ResolvedFormat Resolve style inheritance followed by direct character formatting.
  • fn resolve_paragraph(&self, p: &Paragraph) -> ParagraphFormat Resolve inherited paragraph properties followed by per-property direct overrides.
  • fn outline_level(&self, style: ParagraphStyle) -> Option<u8> Outline level for navigation and heading pagination; body text has no level.

doc_core/fragment.rs#

Source: lib/doc_core/fragment.rs

Structured clipboard ranges, independent of platform clipboard ownership and file codecs.
  • struct DocumentFragment A self-contained rich selection. Paragraph boundaries distinguish hard paragraph marks from soft line breaks; sources and anchored notes travel with their native fields. The first and last paragraph can be partial. IDs are local to this fragment and are remapped when inserted. Public codec data must pass document.validate() before use.
    • document: Document

impl Document

  • fn copy_story_range( &self, paragraph: Id, start: usize, end: usize, ) -> Result<DocumentFragment, Error> Copy a story range with native formatting and complete fields. Selecting only part of a generated field fails; no display text is silently substituted for its identity.

impl Editor

  • fn remove_field(&mut self, paragraph: Id, inline: usize) -> Result<(Id, usize), Error> Remove a native field and return its surviving insertion caret. Citation and note removal can change bibliography or marker lengths before and after that caret; the returned paragraph-local UTF-8 offset is measured in the updated document.
  • fn replace_story_fragment( &mut self, paragraph: Id, start: usize, end: usize, fragment: DocumentFragment, ) -> Result<(Id, usize), Error> Insert a rich fragment as one undo transaction and return its trailing caret as (paragraph identity, paragraph-local UTF-8 offset). Live field lengths are measured after insertion, so source reuse and note renumbering cannot misplace the caret.
  • fn replace_story_fragment_checked( &mut self, paragraph:Id, start:usize, end:usize, fragment:DocumentFragment, check:impl FnOnce(&Document)->Result<(),Error>, )->Result<(Id,usize),Error> Insert a fragment with an additional pre-commit constraint, preserving its exact caret. Rejection leaves the document, identity allocation and undo/redo history unchanged.

doc_core/table_fragment.rs#

Source: lib/doc_core/table_fragment.rs

impl Document

  • fn copy_table(&self,id:Id)->Result<DocumentFragment,Error> Copy one complete table, including merged cells, headers, borders, styles and cited sources. A single empty trailing body paragraph anchors this structural fragment.

doc_core/notes.rs#

Source: lib/doc_core/notes.rs

Footnotes and endnotes with stable identities, anchored once in a body or table-cell story.
New shared model functionality, independent of pagination and external formats.
  • enum NoteKind Separate automatically numbered note sequences, in body/table reading order.

    • Footnote
    • Endnote
  • struct Note A note body. Paragraphs support text and citations, but no nested notes or bibliography.

    • id: Id
    • kind: NoteKind
    • paragraphs: Vec<Paragraph>

impl Document

  • fn note(&self, id: Id) -> Option<&Note> Lookup by stable note identity.
  • fn all_paragraphs(&self) -> impl Iterator<Item = &Paragraph> Body paragraphs, note bodies and cell paragraphs in storage order.
  • fn paragraph(&self, id: Id) -> Option<&Paragraph> Lookup a body, cell or note paragraph by its globally unique identity.
  • fn note_for_paragraph(&self, id: Id) -> Option<&Note> Note owning a paragraph, or None for a main-body or missing paragraph.
  • fn note_location(&self, id: Id) -> Option<CitationLocation> Body or cell anchor position for a note.
  • fn note_number(&self, id: Id) -> Option<usize> Live decimal number within this note's kind; identities and storage order do not affect it.
  • fn ordered_notes(&self, kind: NoteKind) -> Vec<&Note> Notes of one kind in body/table reading order.
  • fn note_marker(&self, id: Id) -> String Plain-text marker for a note. Endnotes use an E prefix to distinguish the two sequences.

doc_core/paragraph_edit.rs#

Source: lib/doc_core/paragraph_edit.rs

Atomic paragraph structure edits with stable field/note references. New native model code.
  • struct TextPosition UTF-8 caret inside one editable text run, including virtual run zero of an empty paragraph.
    • paragraph: Id -- Stable paragraph identity, in the main document or a note body.
    • inline: usize -- Zero-based inline text node; zero also addresses a virtual empty paragraph run.
    • offset: usize -- UTF-8 byte offset on a scalar boundary, not a character or display-column count.

impl Document

  • fn join_boundary(&self, first: Id, second: Id) -> Result<TextPosition, Error> Caret at the join seam after joining adjacent paragraphs in the same story. The first paragraph keeps its identity/style/paragraph properties; explicit character overrides remain unchanged. Fields retain their structure and are never textified.

doc_core/text_range.rs#

Source: lib/doc_core/text_range.rs

Paragraph-wide UTF-8 coordinates for continuous editing across formatting runs.
  • struct TextSpan A run's range in a paragraph's displayed text; generated fields are read-only ranges.

    • inline: usize
    • start: usize
    • end: usize
    • editable: bool
  • struct ParagraphText A lossless editing projection. Field text is displayed but never converted into plain runs.

    • paragraph: Id
    • text: String
    • spans: Vec<TextSpan>

impl ParagraphText

  • fn position(&self, offset: usize) -> Result<TextPosition, Error> Resolve a caret to a text run, preferring the preceding editable run at a seam.
  • fn offset(&self, inline: usize, offset: usize) -> Option<usize> Map a native inline caret back to paragraph coordinates.
  • fn selection(&self, start: usize, end: usize) -> Result<TextMatch, Error> Resolve a selection across adjacent text runs; field intersections are rejected.

impl Document

  • fn text_projection(&self, id: Id) -> Result<ParagraphText, Error> Displayed paragraph text with UTF-8 source ranges for editable text and generated fields.

doc_core/story_range.rs#

Source: lib/doc_core/story_range.rs

Continuous story coordinates; paragraph structure never lives in the GUI's text buffer.
  • struct StoryParagraph One paragraph's projection and starting UTF-8 byte offset in its story.

    • start: usize
    • projection: ParagraphText
  • struct StoryText A main body or one note, separated by single LF paragraph marks. Existing soft line breaks also display as LF; paragraph provenance distinguishes them during every edit.

    • text: String
    • paragraphs: Vec<StoryParagraph>

impl StoryText

  • fn position(&self, offset: usize) -> Result<(Id, usize), Error> Resolve a story caret to paragraph identity and paragraph-local byte offset. The caret immediately before a paragraph mark belongs to the preceding paragraph.
  • fn offset(&self, paragraph: Id, offset: usize) -> Option<usize> Translate an existing paragraph-local caret into the story buffer.

impl Document

  • fn story_character_common(&self, paragraph: Id, start: usize, end: usize) -> Result<TextFormat, Error> Effective properties shared by every editable run in a selection. None marks mixed values. A caret samples its insertion format; fields remain protected.
  • fn story_character_format(&self, paragraph: Id, start: usize, end: usize) -> Result<TextFormat, Error> Sample effective character formatting at the start of a UTF-8 story selection. Empty selections use caret affinity; nonempty selections use the selected run. Protected fields and invalid scalar boundaries are rejected consistently with edits.
  • fn story_projection(&self, paragraph: Id) -> Result<StoryText, Error> Project the entire story containing this paragraph. Note bodies remain separate from the main body and from other notes, even when their lines share the same printed page.

doc_core/search.rs#

Source: lib/doc_core/search.rs

Literal Unicode search over adjacent text runs, without searching generated citation fields.
  • struct SearchOptions Literal search behavior. Case-insensitive mode compares Unicode lowercase characters.

    • case_sensitive: bool
    • whole_word: bool
  • struct TextMatch UTF-8 byte positions in one paragraph, possibly crossing adjacent formatting runs.

    • paragraph: Id
    • start_inline: usize
    • start: usize
    • end_inline: usize
    • end: usize

impl Document

  • fn find_text(&self, query: &str, options: SearchOptions) -> Result<Vec<TextMatch>, Error> Find non-overlapping literal matches. Formatting boundaries are transparent; fields and paragraph boundaries are not. Each main paragraph is followed by its anchored note bodies in anchor order, independent of note storage order. At most 10,000 matches and 4,096 query bytes are accepted.

doc_core/source.rs#

Source: lib/doc_core/source.rs

Native scientific source records and the deliberately simple author/year formatter.
  • enum SourceKind Source categories supported by the current editor and bibliography codecs.

    • Book
    • JournalArticle
    • Website
  • struct Person A person's name, kept in separate components without guessing name boundaries.

    • given: String
    • middle: String
    • family: String

impl Person

  • fn short_name(&self) -> String Family name, or given/middle names when no family name was supplied.

  • fn display(&self) -> String Display name in family, given order, preserving Unicode and entered spelling.

  • struct Source A source independent of its file format. Authors are ordered people OR one corporation. id=0 is accepted by source validation and allocated by an editing transaction.

    • id: Id
    • kind: SourceKind
    • authors: Vec<Person>
    • corporate: String
    • title: String
    • year: String
    • publisher: String
    • city: String
    • edition: String
    • journal: String
    • volume: String
    • issue: String
    • pages: String
    • website: String
    • url: String
    • standard_number: String
    • year_accessed: String
    • month_accessed: String
    • day_accessed: String
    • short_title: String
    • comments: String
    • external_id: String
    • language: String

impl Source

  • fn text_fields(&self) -> [&str; 20] Bibliographic scalar fields, for consistent validation and resource accounting.
  • fn validate(&self) -> Result<(), Error> Validate required title, exclusive author modes, field sizes and XML-compatible text.
  • fn byte_size(&self) -> usize Approximate retained source size, including author/string storage.
  • fn author_text(&self) -> String All authors in entered order; corporate spelling is kept verbatim.
  • fn citation_author(&self) -> String Abbreviated authors for the basic citation style (not a CSL implementation).
  • fn bibliography_text(&self) -> String Full entry in the simple author/year style, including available publication details.

doc_core/source_audit.rs#

Source: lib/doc_core/source_audit.rs

Advisory bibliography completeness checks; new native functionality without a reference.
  • enum SourceIssueKind Missing bibliographic metadata, independent of any particular citation style.

    • MissingCreators -- Neither personal authors nor a corporate author were supplied.
    • MissingYear -- The publication year is blank.
    • MissingPublisher -- A book has no publisher.
    • MissingJournal -- A journal article has no journal name.
    • MissingUrl -- A website has no URL.
    • IncompleteAccessDate -- Access-date components skip a preceding year or month component.
  • struct SourceIssue A completeness hint associated with a stable source identity.

    • source: Id -- Source containing the incomplete metadata.
    • kind: SourceIssueKind -- Missing field or incomplete component relationship.

impl Document

  • fn audit_sources(&self) -> Vec<SourceIssue> Inspect all sources, including uncited ones, without changing document or history. Hints never block source saving, mark the document dirty or claim style compliance. Results follow source order, then creators, year, type-specific field and access date. Whitespace-only fields are blank. Access dates are checked only for missing preceding components, not calendar validity; year-only and year/month dates are accepted. A valid document has at most 1,024 sources and fewer than 6,144 returned hints.

doc_core/source_import.rs#

Source: lib/doc_core/source_import.rs

Source-list review and filtering, shared by bibliography UIs and headless consumers.
  • enum SourceTarget Reference to an existing document source or an earlier zero-based import row.

    • Document(Id)
    • Import(usize)
  • enum SourceMatch Advisory import classification. Similar records are never automatically merged.

    • New
    • Identical(SourceTarget)
    • Similar(SourceTarget)

impl Source

  • fn same_content(&self, other: &Self) -> bool Compare all source metadata, ignoring the container-local source ID.
  • fn matches_query(&self, query: &str) -> bool Search title, people and metadata with case-insensitive, normalized whitespace.

impl Document

  • fn review_sources(&self, sources: &[Source]) -> Result<Vec<SourceMatch>, Error> Validate and classify an import without changing the document. Identical rows are safe to skip; a similar title/year or exact URL is only a hint requiring human review. Existing records take precedence over references to earlier rows in the incoming list.

doc_core/source_library.rs#

Source: lib/doc_core/source_library.rs

Reusable source-library transactions and identity allocation; new native functionality.
Storage belongs to doc_io: this model never accesses a filesystem or a document.
  • struct SourceLibrary Independent source collection with a persisted, monotonically increasing ID watermark. Public for codecs; validate at trust boundaries. IDs have no meaning in other containers.
    • sources: Vec<Source> -- Ordered source records, each with an identity local to this library.
    • next_id: Id -- First never-issued ID, or 0x7fff_ffff when the identity space is exhausted.

impl SourceLibrary

  • fn source(&self, id: Id) -> Option<&Source> Find a source by its library-local identity.

  • fn byte_size(&self) -> usize Estimated retained payload, including source, creator and string storage.

  • fn validate(&self) -> Result<(), Error> Check metadata, unique local IDs, allocation watermark and collection budgets.

  • enum LibraryEdit Atomic source-library operations; imported identities are always external to the library.

    • Import(Vec<Source>) -- Import records, ignoring their IDs and skipping exact metadata duplicates. Returns the final record's existing or new library ID, or zero for an empty import.
    • Put(Source) -- ID zero explicitly creates a source; a nonzero ID updates an existing source. Unlike import, explicit creation preserves intentionally identical records.
    • Remove(Id) -- Remove an existing library source without affecting copies in documents.
  • struct SourceLibraryEditor Atomic editor with at most 64 retained history snapshots and an 8 MiB history budget. Undo and redo retain the allocation watermark, including when a library is saved/reloaded.

impl SourceLibraryEditor

  • fn new(library: SourceLibrary) -> Result<Self, Error> Start an editing session from a validated library, without inherited history.
  • fn library(&self) -> &SourceLibrary Current immutable collection, ready for a library codec or copying to a document.
  • fn revision(&self) -> u64 Changes for every successful content edit, undo or redo; unchanged by no-ops/errors.
  • fn can_undo(&self) -> bool Whether a complete transaction can be undone.
  • fn can_redo(&self) -> bool Whether an undone transaction can be reapplied.
  • fn undo(&mut self) -> bool Undo one transaction without making any previously issued identity reusable.
  • fn redo(&mut self) -> bool Redo one transaction, preserving the same source identities and allocation watermark.
  • fn apply(&mut self, edit: LibraryEdit) -> Result<Id, Error> Validate and apply a whole transaction. Errors and no-ops preserve history/revision.

doc_core/source_merge.rs#

Source: lib/doc_core/source_merge.rs

Explicit source reconciliation with complete citation remapping; new native functionality.
  • enum SourceField Selectable source metadata; personal and corporate creators form one exclusive field.
    • Kind
    • Creators
    • Title
    • Year
    • Publisher
    • City
    • Edition
    • Journal
    • Volume
    • Issue
    • Pages
    • Website
    • Url
    • StandardNumber
    • YearAccessed
    • MonthAccessed
    • DayAccessed
    • ShortTitle
    • Comments
    • ExternalId
    • Language

impl SourceField

  • const ALL: [Self; 21] = [ Self::Kind, Self::Creators, Self::Title, Self::Year, Se ... Every reconcilable field in stable form order; source identity is never selectable.

  • struct SourceMerge Explicit field choices: selected fields come from remove, all others remain from keep. An incoming empty field deliberately clears the kept value. Creator choices are atomic.

    • keep: Id -- Existing source identity retained by the transaction.
    • remove: Id -- Existing source removed after its citation references are redirected.
    • incoming: Vec<SourceField> -- Fields explicitly copied from remove, including deliberately selected empty values.
  • struct SourceCandidate An advisory duplicate candidate. Similarity never authorizes an automatic merge.

    • source: Id -- Candidate's stable identity in the same document.
    • identical: bool -- True when every modeled field matches, ignoring only the local source ID.

impl Source

  • fn field_text(&self, field: SourceField) -> String Readable comparison value; exact equality additionally preserves creator structure.
  • fn field_equals(&self, other: &Self, field: SourceField) -> bool Exact metadata comparison, including creator mode, components and entered order.
  • fn field_empty(&self, field: SourceField) -> bool True only for absent metadata. Kind is always present; whitespace is retained data.
  • fn merge_fields(&self, incoming: &Self, fields: &[SourceField]) -> Result<Self, Error> Copy explicitly selected metadata from another scope, retaining this source's ID. Creator mode and ordered people change together. Duplicate choices and invalid resulting metadata are rejected; selecting an empty value deliberately clears it.

impl Document

  • fn plan_source_merge(&self, keep: Id, remove: Id) -> Result<SourceMerge, Error> Prepare explicit reconciliation, suggesting incoming data only for absent kept fields. Both IDs must exist and differ. Populated fields, including Kind, retain their values.
  • fn preview_source_merge(&self, plan: &SourceMerge) -> Result<Source, Error> Preview without mutations, validating the full remapped document and expansion budget. Duplicate selected fields, invalid identities or excessive generated text are errors.
  • fn source_candidates(&self, source: Id) -> Result<Vec<SourceCandidate>, Error> List identical or similar sources in document order, excluding the requested source. The validated document contains at most 1024 sources, so at most 1023 are returned.

Source: docs/API.md in the JFLib repository.