Skip to main content

EditError

Enum EditError 

Source
#[non_exhaustive]
pub enum EditError { InvalidFieldName(String), UnknownField(String), InvalidKindName(String), ReservedKind, IndexOutOfRange { index: usize, len: usize, }, ValueTooDeep { max: usize, }, Import(ImportError), FieldRichtextDecode { field: String, message: String, }, FieldNotContent { field: String, declared: String, }, FieldRichtextNotInline(String), FieldConform { field: String, target: String, message: String, }, ContentApply(ApplyError), }
Expand description

Errors returned by document and card mutators.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InvalidFieldName(String)

§

UnknownField(String)

A typed write (TypedWriter::set / CardWriter::set) addressed a well-formed name that the bound schema does not declare (or a card whose $kind carries no schema). The typed path resolves every name to a schema type, so an undeclared name is a typo, not a fallback: it fails here instead of landing silently in the opaque store. Reach for the raw Card::store_field when opaque storage is the intent.

§

InvalidKindName(String)

§

ReservedKind

§

IndexOutOfRange

Fields

§index: usize
§len: usize
§

ValueTooDeep

Fields

§max: usize
§

Import(ImportError)

Markdown import failed: the content codec rejected the input for a body or a field path (e.g. container nesting past MAX_NESTING_DEPTH). Returned instead of silently degrading the target to empty on a rejected import.

§

FieldRichtextDecode

A richtext field value in the content-or-markdown encoding could not be decoded: a JSON object that is not a canonical richtext content, a markdown string that failed to import, or a shape that is neither object, string, nor null. Returned by Card::commit_field on a richtext field, by Card::revise_field on a present non-content field, and by Card::apply_field_richtext_change.

Fields

§field: String
§message: String
§

FieldNotContent

A corpus read (TypedReader::get_content) addressed a field whose declared type is not a content leaf. Which codec decodes a value is a property of the declared type, not of the stored shape, so the schema answers this before the payload is consulted: an integer field has no corpus to return even when it happens to hold a string.

The condition is a leaf one, narrower than the subtree test conform walks (field_contains_content): an array<richtext> carries content and still has no one corpus, so it lands here. Read its elements through get.

Fields

§field: String
§declared: String
§

FieldRichtextNotInline(String)

A richtext field written under the richtext(inline) constraint decoded to a multi-block content (more than one line, a container, or an island). The write-time counterpart of the coercion/validation richtext(inline) check; returned by Card::commit_field when the field’s schema is richtext with inline: true.

§

FieldConform

A typed write (Card::commit_field) could not conform the value to the field’s schema type: the general write-commit failure for scalar/array/object types (a "x" for an integer, a non-object for an object, …). Richtext fields report through the dedicated FieldRichtextDecode / FieldRichtextNotInline variants instead, so the richtext write surface is unchanged.

Fields

§field: String
§target: String

The schema type the write was conformed against, carried across from CoercionError so the failure states what the value had to become. message alone is English.

§message: String
§

ContentApply(ApplyError)

A content field-change bundle (text delta, line ops, mark ops) applied out of bounds or broke an invariant normalization could not repair.

Implementations§

Source§

impl EditError

Source

pub fn variant_name(&self) -> &'static str

The bare variant name (e.g. "InvalidFieldName"). Retained as the stable variant discriminator behind code; defined once here so a new variant cannot drift between the two binding error mappers.

Source

pub fn code(&self) -> &'static str

The namespaced diagnostic code (e.g. "edit::invalid_field_name"), one per variant. This is the machine-routable identity both bindings stamp onto the Diagnostic they raise: the edit::* peer of parse::*, validation::*, and the rest of the taxonomy in prose/canon/ERROR.md. Consumers route on this, not on message text.

Source

pub fn args(&self) -> BTreeMap<String, Value>

The facts this error’s message interpolates. See Diagnostic::args; ERROR.md § “Diagnostic args” says per code whether an empty map means a fixed sentence or a fallback to message.

field and kind ride here despite doc_path also folding them into the anchor. The rule against duplicating an anchor bars the assembled path string, and recovering a name from one is unsound anyway: DocPath renders field segments unescaped and parses on . and [, so exactly the malformed names InvalidFieldName reports can round-trip into other segments.

Source

pub fn doc_path(&self, base: &DocPath) -> Option<DocPath>

The DocPath this error anchors to, relative to base, the card root the mutator ran against (main for a main-card mutator, cards.<kind>[i] for a composable card, cards[i] for a structural op on the array; empty only for a card built before it is placed, which has no index yet).

A field-named variant anchors at its field under base (main.<field>, cards.<kind>[i].<field>, or a bare <field> when base is empty: the pre-placement card); IndexOutOfRange at the document-array slot cards[index], base-independent: a structural op names a slot, not a field; and the remaining variants (kind errors, depth, content apply/import) anchor at base itself when it names a card, else carry no anchor (a config-space $seed error keeps an empty base). Both bindings route through this so a mutator diagnostic is addressable the same way a validation diagnostic is.

Trait Implementations§

Source§

impl Clone for EditError

Source§

fn clone(&self) -> EditError

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 EditError

Source§

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

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

impl Display for EditError

Source§

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

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

impl Error for EditError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for EditError

Source§

fn eq(&self, other: &EditError) -> 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 EditError

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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.