#[non_exhaustive]pub enum Invariant {
Show 21 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),
ReservedUnknownLineKind(String),
ReservedUnknownContainer(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,
LineKindMismatch {
line: usize,
mismatch: LineKindMismatch,
},
NestingTooDeep {
line: usize,
depth: usize,
max: usize,
},
JsonTooDeep {
what: &'static str,
max: usize,
},
}Expand description
Ways a Content can violate its invariants. Returned by
Content::validate; import normalization guarantees none of these.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
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.
ReservedUnknownLineKind(String)
A LineKind::Unknown reused a reserved built-in kind name: its
serialization would parse back as the built-in, dropping its attrs.
ReservedUnknownContainer(String)
A Container::Unknown reused a reserved built-in container name, the
same non-injectivity as Invariant::ReservedUnknownLineKind.
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).
LineKindMismatch
A line’s LineKind contradicts its text. Export trusts the kind and
never re-reads the segment, so an unchecked mismatch is silent text loss
(an Island-tagged prose line projects to its resolved island alone).
NestingTooDeep
A line’s container path is nested deeper than
MAX_NESTING_DEPTH. Both
emitters recurse one frame per container, so an unbounded path overflows
the stack; import caps it, and this is the same cap for the content that
never went through import (a decoded blob, a hand-built value).
JsonTooDeep
An opaque JSON payload (an island’s props, an unknown line/container/
mark’s attrs) nests deeper than MAX_JSON_DEPTH:
Invariant::NestingTooDeep on the payload axis. what names the bag.
No true depth: the check bails at the first over-deep container rather
than measuring past the limit.
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.