pub enum Invariant {
Show 16 variants
CarriageReturn,
BidiControl(char),
IslandSlotMismatch {
slots: usize,
islands: usize,
},
LineCountMismatch {
lines: usize,
segments: usize,
},
MarkOutOfRange {
start: Usv,
end: Usv,
len: Usv,
},
ZeroWidthFormatting {
at: Usv,
},
BadHeadingLevel(u8),
FirstLineContinues,
ReservedUnknownTag(String),
MarkEdgeOnNewline {
at: Usv,
},
TableAlignsMismatch {
aligns: usize,
cols: usize,
},
TableRaggedRow {
row: usize,
width: usize,
cols: usize,
},
TableCellNewline {
cell: usize,
},
IslandIdCollision {
id: String,
},
AnchorIdCollision {
id: String,
},
TableHeaderNotArray,
}Expand description
Ways a Content can violate its invariants. Returned by
Content::validate; import normalization guarantees none of these.
Variants§
CarriageReturn
\r in the text (line endings must be normalized to \n).
BidiControl(char)
A bidi formatting control in the text.
IslandSlotMismatch
island_slot_count != islands.len().
LineCountMismatch
lines.len() != newline_segment_count.
MarkOutOfRange
A mark range runs past the content or is inverted (start > end).
ZeroWidthFormatting
A zero-width formatting mark survived normalization.
BadHeadingLevel(u8)
A heading level outside 1..=6.
FirstLineContinues
The first line has continues: true (nothing precedes it to continue).
ReservedUnknownTag(String)
An MarkKind::Unknown reused a reserved built-in type name.
MarkEdgeOnNewline
A formatting mark edge sits on a \n (normalization should have trimmed
it) — a hand-built content that skipped normalize.
TableAlignsMismatch
A table island’s aligns length differs from its column count (the
header width). normalize syncs aligns to the column count.
TableRaggedRow
A table island body row’s width differs from the column count (the header
width). normalize pads short rows (and the header) to the widest.
TableCellNewline
A table cell’s text carries a \n — cells are single-line (a newline
would break the exported table). cell is the flat header-then-rows
index; normalize rewrites the newline to a space.
IslandIdCollision
Two islands share an id. Ids are deterministic, session-stable
identities (hash input, so never ambient); import mints them by index so
they never collide, but a hand-built or round-tripped content can.
Downstream code that keys islands by id would otherwise silently pick the
wrong one. Uniqueness is the id invariant validate enforces — positional
equality is not, since edits keep an island’s id stable across renumbers.
AnchorIdCollision
Two prose anchors share an id, or one carries the empty id. An anchor
id is a caller-supplied, opaque handle, unique per Content (hash input,
never ambient in the twin’s sense; DOCUMENT_STORAGE.md § Anchor-id
identity). RemoveAnchor { id } retains-out every match, so a shared id
makes removing one destroy both; the empty id is a degenerate handle.
Scope is prose marks — cell anchors are outside the op surface.
TableHeaderNotArray
A table island’s header prop is present but not a JSON array — it
cannot carry column cells. normalize rewrites a non-array header to an
empty array (a zero-column, content-free table).
Trait Implementations§
impl Eq for Invariant
impl StructuralPartialEq for Invariant
Auto Trait Implementations§
impl Freeze for Invariant
impl RefUnwindSafe for Invariant
impl Send for Invariant
impl Sync for Invariant
impl Unpin for Invariant
impl UnsafeUnpin for Invariant
impl UnwindSafe for Invariant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.