#[non_exhaustive]pub enum WriteError {
Io(Error),
Fmt,
ExpectedKey,
UnexpectedKey,
MismatchedEnd,
DocumentComplete,
Incomplete,
}Expand description
Why a Writer call was refused.
The sequence errors (every variant but Io and Fmt) mean the calling
code asked for something that is not JSON; the call wrote nothing and the
writer is unchanged, so the caller may go on with a correct call. An
output error finishes the writer: every later call fails too.
The enum is #[non_exhaustive].
§Examples
use jsonx_lib::{WriteError, Writer};
let mut out = String::new();
let mut w = Writer::new(&mut out);
w.begin_object()?;
assert!(matches!(w.value(&1), Err(WriteError::ExpectedKey)));
w.key("n")?;
w.value(&1)?;
w.end_object()?;
w.finish()?;
assert_eq!(out, r#"{"n":1}"#);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Io(Error)
std only.The io::Write failed. Its first error is returned
once; later calls return an error of the same kind.
Fmt
The fmt::Write failed.
ExpectedKey
A value, or the start of an array or object, where an object member’s key belongs.
UnexpectedKey
A key outside an object, or a second key before the first one’s value.
MismatchedEnd
An end_array or end_object that does not close the innermost open
container (or with none open, or with a key still waiting for its
value).
DocumentComplete
A second top-level value: a document is one value.
Incomplete
finish before the document’s value was complete.
Trait Implementations§
Source§impl Debug for WriteError
impl Debug for WriteError
Source§impl Display for WriteError
impl Display for WriteError
Source§impl Error for WriteError
impl Error for WriteError
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()