yam_core/error.rs
1use core::str::Utf8Error;
2use alloc::string::String;
3/// A specialized `Result` type where the error is hard-wired to [`Error`].
4///
5/// [`Error`]: enum.Error.html
6pub type YamlResult<T> = Result<T, YamlError>;
7
8#[derive(Debug, Clone, Eq, PartialEq)]
9pub enum YamlError {
10 Utf8(Utf8Error),
11 Io(String),
12 UnexpectedEof,
13 /// Input decoding error. If `encoding` feature is disabled, contains `None`,
14 /// otherwise contains the UTF-8 decoding error
15 NonDecodable(Option<Utf8Error>),
16}
17
18
19impl From<Utf8Error> for YamlError {
20 /// Creates a new `Error::NonDecodable` from the given error
21 #[inline]
22 fn from(error: Utf8Error) -> YamlError {
23 YamlError::NonDecodable(Some(error))
24 }
25}