Skip to main content

WriteValue

Enum WriteValue 

Source
pub enum WriteValue {
    Intercepted {
        at: StorePath,
        said: SmolStr,
    },
    Recursed {
        at: StorePath,
    },
    Absent {
        at: StorePath,
    },
    NotAPath(StorePathError),
    TooDeep {
        at: StorePath,
        why: Because,
    },
    WillNotEncode {
        at: StorePath,
        why: Because,
    },
    Closed {
        at: StorePath,
    },
    SourceGone,
    Store(Because),
}
Expand description

Everything a write through a reactive primitive can fail with, and nothing else.

Fields, cells and maps fail in the same ways, so they share one set; the per-primitive names below are aliases kept for readability at call sites.

Ordinary std::error::Error, so a caller who does not want to look can ? it into anyhow, eyre or a Box<dyn Error> and be done - and get the whole diagnosis out of it. Display says what this write was and where; source descends through the contexts under it, each carrying what was attached to it, so a {:?} of an anyhow::Error names the operation, the key, the file and the engine’s own words without a match anywhere.

A caller who wants a fact as a type rather than as a sentence reads it back with facts::all over the report the variant carries - facts::all::<StoreFile, _>(why) for the file, Key for the key. That is the typed way in; the chain is the readable one.

{:?} prints the same thing anyhow prints, because that is the shape a reader has learnt: fn main() -> anyhow::Result<()> renders with Debug, and so does every tracing::error!("{err:?}"). What the report holds beyond the chain - the frame each context was raised at - is in explain, which is where a dump belongs.

Variants§

§

Intercepted

An interceptor turned the change down, in its own words.

Fields

§said: SmolStr
§

Recursed

Interceptors wrote back into the value they guard, nested deeper than a write may go, and the guard stopped them.

Nothing turned the change down - a rule that refuses is Intercepted. This is a loop in the interceptors themselves.

Fields

§

Absent

Nothing is stored where the write was aimed, and this write only changes what is already there.

Fields

§

NotAPath(StorePathError)

The name handed in cannot be a level, so nothing can sit under it.

§

TooDeep

The path or the value nests deeper than this store reads back.

why is kept whole because the numbers are the diagnosis: which budget ran out, what it was, and how much the path had already spent are attached to it.

Fields

§

WillNotEncode

The value will not turn into what the store keeps, with what the codec said kept whole.

Fields

§

Closed

The store has let go of its file, so nothing lands.

No report, because there is never one to keep: every StorageError::Closed is minted fresh at the refusal - the store checks whether it is closed and answers - so nothing has failed underneath. What the report did carry is the store’s own file, and that is dropped here rather than lost from somewhere deeper.

Fields

§

SourceGone

The field or map this cell views has been dropped. into_cell is the form that keeps it alive.

§

Store(Because)

The disk, in every sense: the file, the engine, the codec.

Carries the report whole, so the facts attached along the way - the key, the table, how many bytes - are still there for whoever wants them.

Implementations§

Source§

impl WriteValue

Source

pub fn from_store(at: &StorePath, why: Report<StorageError>) -> Self

What the store said, told apart where a caller would act on it differently.

Source

pub fn explain(&self) -> String

The whole report as a string, facts and all, for a caller handing this to anyhow: .context(why.explain()).

The chain source walks is the readable half and is usually enough. This is the rest of it - every frame, every attachment, laid out the way the report renders itself - for a log record that has to carry everything.

Source§

impl WriteValue

Source

pub fn from_backend<E>( at: &StorePath, doing: StorageError, why: Report<E>, ) -> Self
where E: Error + Send + Sync + 'static,

The same, for a backend whose failures are its own rather than the store’s - a client talking to one over a wire. doing is the operation the wire was carrying, and what the transport said is the frame below.

Source

pub fn intercepted(at: &StorePath, said: impl AsRef<str>) -> Self

The refusal an interceptor gave.

Source

pub fn refused(at: &StorePath, refusal: Refusal) -> Self

What running a change past its interceptors refused, as a write’s failure.

Trait Implementations§

Source§

impl Debug for WriteValue

Source§

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

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

impl Display for WriteValue

Source§

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

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

impl Error for WriteValue

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 From<Report<StorageError>> for WriteValue

Source§

fn from(why: Report<StorageError>) -> Self

Converts to this type from the input type.
Source§

impl From<StorePathError> for WriteValue

Source§

fn from(why: StorePathError) -> Self

Converts to this type from the input type.
Source§

impl From<WriteValue> for Report<StorageError>

Back into a report, for the plumbing under the boundary.

The sets are what a caller outside the library meets; inside it, everything still travels as a report, and this is what lets a ? cross from one to the other without a map_err at every line.

Source§

fn from(why: WriteValue) -> Self

Converts to this type from the input type.

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> Attachment for T

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<E> IntoReport for E
where E: Into<Report<E>>,

Source§

type Context = E

The context type that will be used in the resulting Report.
Source§

fn into_report(self) -> Report<<E as IntoReport>::Context>

Converts this value into a Report.
Source§

impl<T> OpaqueAttachment for T
where T: Send + Sync + 'static,

Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more