pub enum BytesCow<'a> {
Slice(&'a [u8]),
StaticSlice(&'static [u8]),
Vec(Vec<u8>),
Bytes(Bytes),
}
Expand description
A Cow
type for bytes.
Variants§
Slice(&'a [u8])
A borrowed [Bytes
] object.
StaticSlice(&'static [u8])
A staticly borrowed [Bytes
] object.
Vec(Vec<u8>)
An owned Vec
of bytes.
Bytes(Bytes)
An owned [Bytes
] object.
Implementations§
Source§impl<'a> BytesCow<'a>
impl<'a> BytesCow<'a>
Sourcepub fn from_static(slice: &'static [u8]) -> Self
pub fn from_static(slice: &'static [u8]) -> Self
Creates a new BytesCow
from a static slice.
Sourcepub fn from_slice(slice: &'a [u8]) -> Self
pub fn from_slice(slice: &'a [u8]) -> Self
Creates a new BytesCow
from a slice of bytes.
Sourcepub fn from_bytes(bytes: Bytes) -> Self
pub fn from_bytes(bytes: Bytes) -> Self
Creates a new BytesCow
from a [Bytes
] object.
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Converts the object into a [Bytes
] object.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BytesCow<'de>
Available on crate feature serde
only.
impl<'de> Deserialize<'de> for BytesCow<'de>
Available on crate feature
serde
only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<'a> Eq for BytesCow<'a>
Auto Trait Implementations§
impl<'a> !Freeze for BytesCow<'a>
impl<'a> RefUnwindSafe for BytesCow<'a>
impl<'a> Send for BytesCow<'a>
impl<'a> Sync for BytesCow<'a>
impl<'a> Unpin for BytesCow<'a>
impl<'a> UnwindSafe for BytesCow<'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