From aa940a8eac74aca8cd3c202a05092538d1140dda Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Thu, 28 Nov 2024 18:00:30 +0000 Subject: create element builder and refactor api --- src/error.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs index 85b5d70..dd8ea17 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,10 +1,27 @@ -use std::{num::ParseIntError, str::Utf8Error}; +use std::{ + collections::{HashMap, VecDeque}, + num::ParseIntError, + str::{FromStr, Utf8Error}, +}; use crate::{ element::{Content, Name, NamespaceDeclaration}, Element, }; +#[derive(Debug)] +pub enum DeserializeError { + FromStr(String), + UnexpectedAttributes(HashMap), + UnexpectedContent(VecDeque), + MissingAttribute(Name), + IncorrectName(String), + IncorrectNamespace(String), + Unqualified, + MissingChild, + MissingValue, +} + #[derive(Debug)] pub enum Error { ReadError(std::io::Error), @@ -26,6 +43,13 @@ pub enum Error { UnexpectedNumberOfContents(usize), UnexpectedContent(Content), UnexpectedElement(Name), + Deserialize(DeserializeError), +} + +impl From for Error { + fn from(e: DeserializeError) -> Self { + Self::Deserialize(e) + } } impl From for Error { -- cgit