diff options
author | HampusM <hampus@hampusmat.com> | 2023-05-14 17:00:17 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-05-14 17:00:17 +0200 |
commit | 2e4f293cee28cd5fb62ed5e8c95472764f5f5143 (patch) | |
tree | da0ca4a900e5c55e051a7144c8f16ad16fea6e5f /src/tagged.rs | |
parent | 1621882905b6bfd911e0b0ac8be5c369f2707b31 (diff) |
refactor: make the TagStart name function error type TagStartError
Diffstat (limited to 'src/tagged.rs')
-rw-r--r-- | src/tagged.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/tagged.rs b/src/tagged.rs index 1fca458..eada376 100644 --- a/src/tagged.rs +++ b/src/tagged.rs @@ -43,9 +43,9 @@ impl<'a> TagStart<'a> /// /// # Errors /// Returns `Err` if the name is not valid UTF-8. - pub fn name(&self) -> Result<&str, Utf8Error> + pub fn name(&self) -> Result<&str, TagStartError> { - std::str::from_utf8(self.name_bytes()) + std::str::from_utf8(self.name_bytes()).map_err(TagStartError::NameNotUTF8) } /// Returns the name as bytes. @@ -101,4 +101,8 @@ pub enum TagStartError /// Invalid attribute. #[error("Invalid attribute")] InvalidAttribute(#[from] AttributeError), + + /// Name is not valid UTF-8. + #[error("Name is not valid UTF-8")] + NameNotUTF8(#[source] Utf8Error), } |