pub struct Bytes<'a> { /* private fields */ }Expand description
A storage type for raw bytes, used by the parser
Implementations§
Source§impl<'a> Bytes<'a>
impl<'a> Bytes<'a>
Sourcepub fn as_utf8_str(&self) -> Cow<'_, str>
pub fn as_utf8_str(&self) -> Cow<'_, str>
Convenient method for lossy-encoding the data as UTF8
Sourcepub fn try_as_utf8_str(&self) -> Option<&str>
pub fn try_as_utf8_str(&self) -> Option<&str>
Tries to convert the inner data to a &str, without allocating in the case
that the inner data is not valid UTF8
Sourcepub fn as_bytes_borrowed(&self) -> Option<&'a [u8]>
pub fn as_bytes_borrowed(&self) -> Option<&'a [u8]>
Returns the raw data referenced by this struct
The lifetime of the returned data is tied to ’a, unlike Bytes::as_bytes
which has a lifetime of ’_ (self) in case it is owned
Trait Implementations§
Source§impl<'a> Ord for Bytes<'a>
impl<'a> Ord for Bytes<'a>
Source§impl<'a> PartialOrd for Bytes<'a>
impl<'a> PartialOrd for Bytes<'a>
impl<'a> Eq for Bytes<'a>
Auto Trait Implementations§
impl<'a> Freeze for Bytes<'a>
impl<'a> RefUnwindSafe for Bytes<'a>
impl<'a> !Send for Bytes<'a>
impl<'a> !Sync for Bytes<'a>
impl<'a> Unpin for Bytes<'a>
impl<'a> UnwindSafe for Bytes<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more