Skip to main content

Invariant

Enum Invariant 

Source
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().

Fields

§slots: usize
§islands: usize
§

LineCountMismatch

lines.len() != newline_segment_count.

Fields

§lines: usize
§segments: usize
§

MarkOutOfRange

A mark range runs past the content or is inverted (start > end).

Fields

§start: Usv
§end: Usv
§len: Usv
§

ZeroWidthFormatting

A zero-width formatting mark survived normalization.

Fields

§at: Usv
§

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.

Fields

§at: Usv
§

TableAlignsMismatch

A table island’s aligns length differs from its column count (the header width). normalize syncs aligns to the column count.

Fields

§aligns: usize
§cols: usize
§

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.

Fields

§row: usize
§width: usize
§cols: usize
§

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.

Fields

§cell: usize
§

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.

Fields

§

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.

Fields

§

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§

Source§

impl Clone for Invariant

Source§

fn clone(&self) -> Invariant

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Invariant

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Invariant

Source§

impl PartialEq for Invariant

Source§

fn eq(&self, other: &Invariant) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Invariant

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.