Struct swimos_encoding::BytesStr
source · pub struct BytesStr(/* private fields */);Expand description
A string based on a sub-range within a Bytes buffer. The bytes are guaranteed to contain valid
UTF-8. The purpose of this type is to allow a tokio_util::codec::Decoders to return a string from
its input buffer without performing a copy or an allocation and without a lifetime dependency on the
buffer.
Implementations§
source§impl BytesStr
impl BytesStr
sourcepub fn try_wrap(bytes: Bytes) -> Result<Self, Bytes>
pub fn try_wrap(bytes: Bytes) -> Result<Self, Bytes>
Attempt to wrap a buffer as a bytes string. If the buffer does not contain only valid UTF-8, the raw buffer is returned instead.
sourcepub const fn from_static_str(content: &'static str) -> BytesStr
pub const fn from_static_str(content: &'static str) -> BytesStr
Create a bytes string from a static string (which is guaranteed to be valid).
Trait Implementations§
source§impl PartialEq<String> for BytesStr
impl PartialEq<String> for BytesStr
source§impl PartialEq for BytesStr
impl PartialEq for BytesStr
source§impl TryFromUtf8Bytes for BytesStr
impl TryFromUtf8Bytes for BytesStr
impl Eq for BytesStr
impl StructuralPartialEq for BytesStr
Auto Trait Implementations§
impl !Freeze for BytesStr
impl RefUnwindSafe for BytesStr
impl Send for BytesStr
impl Sync for BytesStr
impl Unpin for BytesStr
impl UnwindSafe for BytesStr
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)