#[non_exhaustive]pub enum Error {
Message {
msg: String,
},
Format {
error: Error,
},
IO {
error: Error,
},
Unexpected {
msg: String,
},
InvalidOptions(String),
SingleQuotedRequiresEscaping {
ch: char,
},
EmptyResolvedTag,
InvalidGlobalTagUri {
tag: String,
},
CoreTypeTagAsEnumVariant {
tag: String,
variant: String,
},
}Expand description
Error type used by the YAML serializer.
This type is re-exported as serde_saphyr::SerializeError and
serde_saphyr::ser::Error, and is returned by
the public serialization APIs (for example serde_saphyr::to_string).
It implements serde::ser::Error, which allows user Serialize impls and
Serde derives to report failures via S::Error::custom(...). Such
free‑form messages are stored in the Message variant.
Other variants wrap concrete underlying failures that can occur while serializing:
Formatwraps astd::fmt::Errorproduced when writing to afmt::Writetarget.IOwraps astd::io::Errorproduced when writing to anio::Writetarget.SingleQuotedRequiresEscapingreports aSingleQuotedwrapper value that needs YAML escape sequences and therefore cannot be emitted in single-quoted style.EmptyResolvedTagreports aTaggedwrapper whose explicit resolved tag is empty. UseNoneto represent the absence of a tag.InvalidGlobalTagUrireports a non-localTaggedidentity that is not an absolute URI.CoreTypeTagAsEnumVariantreports a YAML core type tag whose name collides with a non-unit enum variant.Unexpectedis used internally for invariant violations (e.g., around anchors). It should not normally surface; if it does, please file a bug.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Message
Free-form error.
Format
Wrapper for formatting errors.
IO
Wrapper for I/O errors.
Unexpected
This is used with anchors and should normally not surface, please report bug if it does.
InvalidOptions(String)
Options used would produce invalid YAML (0 indentation, etc)
SingleQuotedRequiresEscaping
A crate::SingleQuoted value contains a character that cannot be represented safely in
YAML single-quoted style.
EmptyResolvedTag
A crate::Tagged value uses an empty string as an explicit resolved tag identity.
Use None to represent a value without an explicit tag.
InvalidGlobalTagUri
A non-local crate::Tagged identity is not a valid absolute URI.
CoreTypeTagAsEnumVariant
A YAML core type tag cannot act as the discriminator for a same-named non-unit enum variant.
Trait Implementations§
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()