diff options
author | 2024-11-28 18:00:30 +0000 | |
---|---|---|
committer | 2024-11-28 18:00:30 +0000 | |
commit | aa940a8eac74aca8cd3c202a05092538d1140dda (patch) | |
tree | d14997232d48ca723dc2486f0a6346421c9af163 /src/error.rs | |
parent | 381af38a0910ca42ccb36568ebbcd147cfbd237b (diff) | |
download | peanuts-aa940a8eac74aca8cd3c202a05092538d1140dda.tar.gz peanuts-aa940a8eac74aca8cd3c202a05092538d1140dda.tar.bz2 peanuts-aa940a8eac74aca8cd3c202a05092538d1140dda.zip |
create element builder and refactor api
Diffstat (limited to 'src/error.rs')
-rw-r--r-- | src/error.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/error.rs b/src/error.rs index 85b5d70..dd8ea17 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,4 +1,8 @@ -use std::{num::ParseIntError, str::Utf8Error}; +use std::{ + collections::{HashMap, VecDeque}, + num::ParseIntError, + str::{FromStr, Utf8Error}, +}; use crate::{ element::{Content, Name, NamespaceDeclaration}, @@ -6,6 +10,19 @@ use crate::{ }; #[derive(Debug)] +pub enum DeserializeError { + FromStr(String), + UnexpectedAttributes(HashMap<Name, String>), + UnexpectedContent(VecDeque<Content>), + MissingAttribute(Name), + IncorrectName(String), + IncorrectNamespace(String), + Unqualified, + MissingChild, + MissingValue, +} + +#[derive(Debug)] pub enum Error { ReadError(std::io::Error), Utf8Error(Utf8Error), @@ -26,6 +43,13 @@ pub enum Error { UnexpectedNumberOfContents(usize), UnexpectedContent(Content), UnexpectedElement(Name), + Deserialize(DeserializeError), +} + +impl From<DeserializeError> for Error { + fn from(e: DeserializeError) -> Self { + Self::Deserialize(e) + } } impl From<std::io::Error> for Error { |