diff options
-rw-r--r-- | src/deserializer/buffered.rs | 2 | ||||
-rw-r--r-- | src/tagged.rs | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/deserializer/buffered.rs b/src/deserializer/buffered.rs index 6568910..b961dd7 100644 --- a/src/deserializer/buffered.rs +++ b/src/deserializer/buffered.rs @@ -117,7 +117,7 @@ impl<TSource: Source> Deserializer for Buffered<TSource> let deserialized = De::deserialize(&start, self).map_err(Error::DeserializeFailed)?; - self.read_end_event(start.name()) + self.read_end_event(start.name_bytes()) .map_err(Error::into_with_de_error)?; deserialized_items.push(deserialized); diff --git a/src/tagged.rs b/src/tagged.rs index 19ae03b..0150697 100644 --- a/src/tagged.rs +++ b/src/tagged.rs @@ -26,24 +26,24 @@ impl<'a> TagStart<'a> } } - /// Returns the tag name. + /// Returns the name. + /// + /// # Errors + /// Returns `Err` if the name is not valid UTF-8. + pub fn name(&self) -> Result<&str, Utf8Error> + { + std::str::from_utf8(self.name_bytes()) + } + + /// Returns the name as bytes. #[must_use] - pub fn name(&self) -> &[u8] + pub fn name_bytes(&self) -> &[u8] { let name_length = self.inner.name().as_ref().len(); &self.inner.as_ref()[..name_length] } - /// Returns the tag name in UTF-8. - /// - /// # Errors - /// Returns `Err` if the name is not valid UTF-8. - pub fn name_utf8(&self) -> Result<&str, Utf8Error> - { - std::str::from_utf8(self.name()) - } - /// Returns the tag attributes. #[must_use] pub fn attributes(&'a self) -> AttributeIter<'a> |