pub enum Error {
Duplicate(ElemId),
Conflict {
outer: ElemId,
inner: ElemId,
},
UnknownElement(ElemId),
Removal(RemovalError),
Internal(Error),
OutputTooLarge,
OverlappingSpans {
first: Span,
second: Span,
},
}Expand description
Why a set of Edits could not be applied.
Most of these say the edits asked for something contradictory, or named an element that is
not there, and the caller can act on them. Error::Internal and Error::OverlappingSpans
are different in kind: no set of edits can ask for either, so reaching one is a bug in this
module rather than anything the caller did. They are returned rather than panicked on because
the caller is about to write the result over someone’s tariff, and refusing to is better than
crashing in their process or, worse, handing back JSON that has been corrupted.
Variants§
Duplicate(ElemId)
More than one replacement targets this element, and they disagree about the text.
Conflict
Applying outer would silently discard the edit to inner, which sits inside it.
UnknownElement(ElemId)
The document has no element with this id.
Removal(RemovalError)
The removals could not be resolved to spans.
Internal(Error)
Splicing produced source that is no longer valid JSON, which is a bug in this module.
A replacement carries a payload that is one JSON value by construction, and a value is legal wherever another value was, so no payload should cause this. What is left is the removal spans and the splice itself, so reaching this means one of those is wrong - or, in a release build, that a payload builder is, since its own assertion is compiled out.
OutputTooLarge
The spliced source exceeds the maximum size deemed reasonable.
A caller can reach this: replacements longer than what they stand in for can take a document that was within the limit past it. This is the only size bound in the module, and it is on the whole output, since a bound on one payload would not catch that.
OverlappingSpans
Two resolved spans overlap, so erasing both would corrupt the output. No set of edits should reach this; it means resolution itself is wrong.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoCaveat for T
impl<T> IntoCaveat for T
Source§fn into_caveat<W>(self, warnings: Set<W>) -> Caveat<T, W>where
W: Warning,
fn into_caveat<W>(self, warnings: Set<W>) -> Caveat<T, W>where
W: Warning,
Caveat<T> by supplying a list of Warnings.Source§fn into_infallible_caveat(self) -> Caveat<Self, Infallible>
fn into_infallible_caveat(self) -> Caveat<Self, Infallible>
FromSchema is infallible a Caveat can be created using this method.