pub trait BytesExt: AsBytesRef {
Show 72 methods
// Provided methods
fn bytes_eq(&self, other: impl AsBytesRef) -> bool { ... }
fn has_prefix(&self, prefix: impl AsBytesRef) -> bool { ... }
fn has_suffix(&self, suffix: impl AsBytesRef) -> bool { ... }
fn longest_prefix(&self, other: impl AsBytesRef) -> &[u8] ⓘ { ... }
fn longest_suffix(&self, other: impl AsBytesRef) -> &[u8] ⓘ { ... }
fn longest_prefix_lossy(&self, other: impl AsBytesRef) -> Cow<'_, [u8]> { ... }
fn longest_suffix_lossy(&self, other: impl AsBytesRef) -> Cow<'_, [u8]> { ... }
fn to_be_u16_vec(&self) -> Vec<u16> { ... }
fn to_le_u16_vec(&self) -> Vec<u16> { ... }
fn to_ne_u16_vec(&self) -> Vec<u16> { ... }
fn to_be_u32_vec(&self) -> Vec<u32> { ... }
fn to_le_u32_vec(&self) -> Vec<u32> { ... }
fn to_ne_u32_vec(&self) -> Vec<u32> { ... }
fn to_be_usize_vec(&self) -> Vec<usize> { ... }
fn to_le_usize_vec(&self) -> Vec<usize> { ... }
fn to_ne_usize_vec(&self) -> Vec<usize> { ... }
fn to_be_u64_vec(&self) -> Vec<u64> { ... }
fn to_le_u64_vec(&self) -> Vec<u64> { ... }
fn to_ne_u64_vec(&self) -> Vec<u64> { ... }
fn to_be_u128_vec(&self) -> Vec<u128> { ... }
fn to_le_u128_vec(&self) -> Vec<u128> { ... }
fn to_ne_u128_vec(&self) -> Vec<u128> { ... }
fn to_be_i8_vec(&self) -> Vec<i8> { ... }
fn to_le_i8_vec(&self) -> Vec<i8> { ... }
fn to_ne_i8_vec(&self) -> Vec<i8> { ... }
fn to_be_i16_vec(&self) -> Vec<i16> { ... }
fn to_le_i16_vec(&self) -> Vec<i16> { ... }
fn to_ne_i16_vec(&self) -> Vec<i16> { ... }
fn to_be_i32_vec(&self) -> Vec<i32> { ... }
fn to_le_i32_vec(&self) -> Vec<i32> { ... }
fn to_ne_i32_vec(&self) -> Vec<i32> { ... }
fn to_be_i64_vec(&self) -> Vec<i64> { ... }
fn to_le_i64_vec(&self) -> Vec<i64> { ... }
fn to_ne_i64_vec(&self) -> Vec<i64> { ... }
fn to_be_isize_vec(&self) -> Vec<isize> { ... }
fn to_le_isize_vec(&self) -> Vec<isize> { ... }
fn to_ne_isize_vec(&self) -> Vec<isize> { ... }
fn to_be_i128_vec(&self) -> Vec<i128> { ... }
fn to_le_i128_vec(&self) -> Vec<i128> { ... }
fn to_ne_i128_vec(&self) -> Vec<i128> { ... }
fn to_be_f32_vec(&self) -> Vec<f32> { ... }
fn to_le_f32_vec(&self) -> Vec<f32> { ... }
fn to_ne_f32_vec(&self) -> Vec<f32> { ... }
fn to_be_f64_vec(&self) -> Vec<f64> { ... }
fn to_le_f64_vec(&self) -> Vec<f64> { ... }
fn to_ne_f64_vec(&self) -> Vec<f64> { ... }
fn to_u16_slice_lossy(&self) -> Cow<'_, [u16]> { ... }
fn to_u32_slice_lossy(&self) -> Cow<'_, [u32]> { ... }
fn to_usize_slice_lossy(&self) -> Cow<'_, [usize]> { ... }
fn to_u64_slice_lossy(&self) -> Cow<'_, [u64]> { ... }
fn to_u128_slice_lossy(&self) -> Cow<'_, [u128]> { ... }
fn to_i8_slice_lossy(&self) -> Cow<'_, [i8]> { ... }
fn to_i16_slice_lossy(&self) -> Cow<'_, [i16]> { ... }
fn to_i32_slice_lossy(&self) -> Cow<'_, [i32]> { ... }
fn to_i64_slice_lossy(&self) -> Cow<'_, [i64]> { ... }
fn to_isize_slice_lossy(&self) -> Cow<'_, [isize]> { ... }
fn to_i128_slice_lossy(&self) -> Cow<'_, [i128]> { ... }
fn to_f32_slice_lossy(&self) -> Cow<'_, [f32]> { ... }
fn to_f64_slice_lossy(&self) -> Cow<'_, [f64]> { ... }
fn to_u16_slice(&self) -> &[u16] { ... }
fn to_u32_slice(&self) -> &[u32] { ... }
fn to_usize_slice(&self) -> &[usize] { ... }
fn to_u64_slice(&self) -> &[u64] { ... }
fn to_u128_slice(&self) -> &[u128] { ... }
fn to_i8_slice(&self) -> &[i8] { ... }
fn to_i16_slice(&self) -> &[i16] { ... }
fn to_i32_slice(&self) -> &[i32] { ... }
fn to_i64_slice(&self) -> &[i64] { ... }
fn to_isize_slice(&self) -> &[isize] { ... }
fn to_i128_slice(&self) -> &[i128] { ... }
fn to_f32_slice(&self) -> &[f32] { ... }
fn to_f64_slice(&self) -> &[f64] { ... }
}
Expand description
Extensions for bytes
Provided Methods§
Sourcefn bytes_eq(&self, other: impl AsBytesRef) -> bool
fn bytes_eq(&self, other: impl AsBytesRef) -> bool
Returns whether the underlying bytes is equal
Sourcefn has_prefix(&self, prefix: impl AsBytesRef) -> bool
fn has_prefix(&self, prefix: impl AsBytesRef) -> bool
Returns whether the slice self begins with prefix.
Sourcefn has_suffix(&self, suffix: impl AsBytesRef) -> bool
fn has_suffix(&self, suffix: impl AsBytesRef) -> bool
Returns whether the slice self ends with suffix.
Sourcefn longest_prefix(&self, other: impl AsBytesRef) -> &[u8] ⓘ
fn longest_prefix(&self, other: impl AsBytesRef) -> &[u8] ⓘ
Finds the longest shared prefix
Sourcefn longest_suffix(&self, other: impl AsBytesRef) -> &[u8] ⓘ
fn longest_suffix(&self, other: impl AsBytesRef) -> &[u8] ⓘ
Finds the longest shared suffix
Sourcefn longest_prefix_lossy(&self, other: impl AsBytesRef) -> Cow<'_, [u8]>
fn longest_prefix_lossy(&self, other: impl AsBytesRef) -> Cow<'_, [u8]>
Finds the longest shared prefix, return a Cow<’_, u8>.
Sourcefn longest_suffix_lossy(&self, other: impl AsBytesRef) -> Cow<'_, [u8]>
fn longest_suffix_lossy(&self, other: impl AsBytesRef) -> Cow<'_, [u8]>
Finds the longest shared suffix, return a Cow<’_, u8>.
Sourcefn to_be_u16_vec(&self) -> Vec<u16>
fn to_be_u16_vec(&self) -> Vec<u16>
Copy u8 slice to u16 vec in big-endian
Sourcefn to_le_u16_vec(&self) -> Vec<u16>
fn to_le_u16_vec(&self) -> Vec<u16>
Copy u8 slice to u16 vec in little-endian
Sourcefn to_ne_u16_vec(&self) -> Vec<u16>
fn to_ne_u16_vec(&self) -> Vec<u16>
Copy u8 slice to u16 vec in native-endian
Sourcefn to_be_u32_vec(&self) -> Vec<u32>
fn to_be_u32_vec(&self) -> Vec<u32>
Copy u8 slice to u32 vec in big-endian
Sourcefn to_le_u32_vec(&self) -> Vec<u32>
fn to_le_u32_vec(&self) -> Vec<u32>
Copy u8 slice to u32 vec in little-endian
Sourcefn to_ne_u32_vec(&self) -> Vec<u32>
fn to_ne_u32_vec(&self) -> Vec<u32>
Copy u8 slice to u32 vec in native-endian
Sourcefn to_be_usize_vec(&self) -> Vec<usize>
fn to_be_usize_vec(&self) -> Vec<usize>
Copy u8 slice to usize vec in big-endian
Sourcefn to_le_usize_vec(&self) -> Vec<usize>
fn to_le_usize_vec(&self) -> Vec<usize>
Copy u8 slice to usize vec in little-endian
Sourcefn to_ne_usize_vec(&self) -> Vec<usize>
fn to_ne_usize_vec(&self) -> Vec<usize>
Copy u8 slice to usize vec in native-endian
Sourcefn to_be_u64_vec(&self) -> Vec<u64>
fn to_be_u64_vec(&self) -> Vec<u64>
Copy u8 slice to u64 vec in big-endian
Sourcefn to_le_u64_vec(&self) -> Vec<u64>
fn to_le_u64_vec(&self) -> Vec<u64>
Copy u8 slice to u64 vec in little-endian
Sourcefn to_ne_u64_vec(&self) -> Vec<u64>
fn to_ne_u64_vec(&self) -> Vec<u64>
Copy u8 slice to u64 vec in native-endian
Sourcefn to_be_u128_vec(&self) -> Vec<u128>
fn to_be_u128_vec(&self) -> Vec<u128>
Copy u8 slice to u128 vec in big-endian
Sourcefn to_le_u128_vec(&self) -> Vec<u128>
fn to_le_u128_vec(&self) -> Vec<u128>
Copy u8 slice to u128 vec in little-endian
Sourcefn to_ne_u128_vec(&self) -> Vec<u128>
fn to_ne_u128_vec(&self) -> Vec<u128>
Copy u8 slice to u128 vec in native-endian
Sourcefn to_be_i8_vec(&self) -> Vec<i8>
fn to_be_i8_vec(&self) -> Vec<i8>
Copy u8 slice to i8 vec in big-endian
Sourcefn to_le_i8_vec(&self) -> Vec<i8>
fn to_le_i8_vec(&self) -> Vec<i8>
Copy u8 slice to i8 vec in little-endian
Sourcefn to_ne_i8_vec(&self) -> Vec<i8>
fn to_ne_i8_vec(&self) -> Vec<i8>
Copy u8 slice to i8 vec in native-endian
Sourcefn to_be_i16_vec(&self) -> Vec<i16>
fn to_be_i16_vec(&self) -> Vec<i16>
Copy u8 slice to i16 vec in big-endian
Sourcefn to_le_i16_vec(&self) -> Vec<i16>
fn to_le_i16_vec(&self) -> Vec<i16>
Copy u8 slice to i16 vec in little-endian
Sourcefn to_ne_i16_vec(&self) -> Vec<i16>
fn to_ne_i16_vec(&self) -> Vec<i16>
Copy u8 slice to i16 vec in native-endian
Sourcefn to_be_i32_vec(&self) -> Vec<i32>
fn to_be_i32_vec(&self) -> Vec<i32>
Copy u8 slice to i32 vec in big-endian
Sourcefn to_le_i32_vec(&self) -> Vec<i32>
fn to_le_i32_vec(&self) -> Vec<i32>
Copy u8 slice to i32 vec in little-endian
Sourcefn to_ne_i32_vec(&self) -> Vec<i32>
fn to_ne_i32_vec(&self) -> Vec<i32>
Copy u8 slice to i32 vec in native-endian
Sourcefn to_be_i64_vec(&self) -> Vec<i64>
fn to_be_i64_vec(&self) -> Vec<i64>
Copy u8 slice to i64 vec in big-endian
Sourcefn to_le_i64_vec(&self) -> Vec<i64>
fn to_le_i64_vec(&self) -> Vec<i64>
Copy u8 slice to i64 vec in little-endian
Sourcefn to_ne_i64_vec(&self) -> Vec<i64>
fn to_ne_i64_vec(&self) -> Vec<i64>
Copy u8 slice to i64 vec in native-endian
Sourcefn to_be_isize_vec(&self) -> Vec<isize>
fn to_be_isize_vec(&self) -> Vec<isize>
Copy u8 slice to isize vec in big-endian
Sourcefn to_le_isize_vec(&self) -> Vec<isize>
fn to_le_isize_vec(&self) -> Vec<isize>
Copy u8 slice to isize vec in little-endian
Sourcefn to_ne_isize_vec(&self) -> Vec<isize>
fn to_ne_isize_vec(&self) -> Vec<isize>
Copy u8 slice to isize vec in native-endian
Sourcefn to_be_i128_vec(&self) -> Vec<i128>
fn to_be_i128_vec(&self) -> Vec<i128>
Copy u8 slice to i128 vec in big-endian
Sourcefn to_le_i128_vec(&self) -> Vec<i128>
fn to_le_i128_vec(&self) -> Vec<i128>
Copy u8 slice to i128 vec in little-endian
Sourcefn to_ne_i128_vec(&self) -> Vec<i128>
fn to_ne_i128_vec(&self) -> Vec<i128>
Copy u8 slice to i128 vec in native-endian
Sourcefn to_be_f32_vec(&self) -> Vec<f32>
fn to_be_f32_vec(&self) -> Vec<f32>
Copy u8 slice to f32 vec in big-endian
Sourcefn to_le_f32_vec(&self) -> Vec<f32>
fn to_le_f32_vec(&self) -> Vec<f32>
Copy u8 slice to f32 vec in little-endian
Sourcefn to_ne_f32_vec(&self) -> Vec<f32>
fn to_ne_f32_vec(&self) -> Vec<f32>
Copy u8 slice to f32 vec in native-endian
Sourcefn to_be_f64_vec(&self) -> Vec<f64>
fn to_be_f64_vec(&self) -> Vec<f64>
Copy u8 slice to f64 vec in big-endian
Sourcefn to_le_f64_vec(&self) -> Vec<f64>
fn to_le_f64_vec(&self) -> Vec<f64>
Copy u8 slice to f64 vec in little-endian
Sourcefn to_ne_f64_vec(&self) -> Vec<f64>
fn to_ne_f64_vec(&self) -> Vec<f64>
Copy u8 slice to f64 vec in native-endian
Sourcefn to_u16_slice_lossy(&self) -> Cow<'_, [u16]>
fn to_u16_slice_lossy(&self) -> Cow<'_, [u16]>
convert u8 slice to Cow<’_, u16> in native-endian (zero-copy)
Sourcefn to_u32_slice_lossy(&self) -> Cow<'_, [u32]>
fn to_u32_slice_lossy(&self) -> Cow<'_, [u32]>
convert u8 slice to Cow<’_, u32> in native-endian (zero-copy)
Sourcefn to_usize_slice_lossy(&self) -> Cow<'_, [usize]>
fn to_usize_slice_lossy(&self) -> Cow<'_, [usize]>
convert u8 slice to Cow<’_, usize> in native-endian (zero-copy)
Sourcefn to_u64_slice_lossy(&self) -> Cow<'_, [u64]>
fn to_u64_slice_lossy(&self) -> Cow<'_, [u64]>
convert u8 slice to Cow<’_, u64> in native-endian (zero-copy)
Sourcefn to_u128_slice_lossy(&self) -> Cow<'_, [u128]>
fn to_u128_slice_lossy(&self) -> Cow<'_, [u128]>
convert u8 slice to Cow<’_, u128> in native-endian (zero-copy)
Sourcefn to_i8_slice_lossy(&self) -> Cow<'_, [i8]>
fn to_i8_slice_lossy(&self) -> Cow<'_, [i8]>
convert u8 slice to Cow<’_, i8> in native-endian (zero-copy)
Sourcefn to_i16_slice_lossy(&self) -> Cow<'_, [i16]>
fn to_i16_slice_lossy(&self) -> Cow<'_, [i16]>
convert u8 slice to Cow<’_, i16> in native-endian (zero-copy)
Sourcefn to_i32_slice_lossy(&self) -> Cow<'_, [i32]>
fn to_i32_slice_lossy(&self) -> Cow<'_, [i32]>
convert u8 slice to Cow<’_, i32> in native-endian (zero-copy)
Sourcefn to_i64_slice_lossy(&self) -> Cow<'_, [i64]>
fn to_i64_slice_lossy(&self) -> Cow<'_, [i64]>
convert u8 slice to Cow<’_, i64> in native-endian (zero-copy)
Sourcefn to_isize_slice_lossy(&self) -> Cow<'_, [isize]>
fn to_isize_slice_lossy(&self) -> Cow<'_, [isize]>
convert u8 slice to Cow<’_, isize> in native-endian (zero-copy)
Sourcefn to_i128_slice_lossy(&self) -> Cow<'_, [i128]>
fn to_i128_slice_lossy(&self) -> Cow<'_, [i128]>
convert u8 slice to Cow<’_, i128> in native-endian (zero-copy)
Sourcefn to_f32_slice_lossy(&self) -> Cow<'_, [f32]>
fn to_f32_slice_lossy(&self) -> Cow<'_, [f32]>
convert u8 slice to Cow<’_, f32> in native-endian (zero-copy)
Sourcefn to_f64_slice_lossy(&self) -> Cow<'_, [f64]>
fn to_f64_slice_lossy(&self) -> Cow<'_, [f64]>
convert u8 slice to Cow<’_, f64> in native-endian (zero-copy)
Sourcefn to_u16_slice(&self) -> &[u16]
fn to_u16_slice(&self) -> &[u16]
Convert u8 slice to u16 slice in native-endian(zero-copy)
Sourcefn to_u32_slice(&self) -> &[u32]
fn to_u32_slice(&self) -> &[u32]
Convert u8 slice to u32 slice in native-endian(zero-copy)
Sourcefn to_usize_slice(&self) -> &[usize]
fn to_usize_slice(&self) -> &[usize]
Convert u8 slice to usize slice in native-endian(zero-copy)
Sourcefn to_u64_slice(&self) -> &[u64]
fn to_u64_slice(&self) -> &[u64]
Convert u8 slice to u64 slice in native-endian(zero-copy)
Sourcefn to_u128_slice(&self) -> &[u128]
fn to_u128_slice(&self) -> &[u128]
Convert u8 slice to u128 slice in native-endian(zero-copy)
Sourcefn to_i8_slice(&self) -> &[i8]
fn to_i8_slice(&self) -> &[i8]
Convert u8 slice to i8 slice in native-endian(zero-copy)
Sourcefn to_i16_slice(&self) -> &[i16]
fn to_i16_slice(&self) -> &[i16]
Convert u8 slice to i16 slice in native-endian(zero-copy)
Sourcefn to_i32_slice(&self) -> &[i32]
fn to_i32_slice(&self) -> &[i32]
Convert u8 slice to i32 slice in native-endian(zero-copy)
Sourcefn to_i64_slice(&self) -> &[i64]
fn to_i64_slice(&self) -> &[i64]
Convert u8 slice to i64 slice in native-endian(zero-copy)
Sourcefn to_isize_slice(&self) -> &[isize]
fn to_isize_slice(&self) -> &[isize]
Convert u8 slice to isize slice in native-endian(zero-copy)
Sourcefn to_i128_slice(&self) -> &[i128]
fn to_i128_slice(&self) -> &[i128]
Convert u8 slice to i128 slice in native-endian(zero-copy)
Sourcefn to_f32_slice(&self) -> &[f32]
fn to_f32_slice(&self) -> &[f32]
Convert u8 slice to f32 slice in native-endian(zero-copy)
Sourcefn to_f64_slice(&self) -> &[f64]
fn to_f64_slice(&self) -> &[f64]
Convert u8 slice to f64 slice in native-endian(zero-copy)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
impl BytesExt for Box<[u8]>
alloc
only.impl BytesExt for String
impl BytesExt for Vec<u8>
alloc
only.impl BytesExt for Bytes
bytes
only.impl BytesExt for BytesMut
bytes
only.impl<'a> BytesExt for &'a str
impl<'a> BytesExt for &'a Box<[u8]>
alloc
only.impl<'a> BytesExt for &'a String
impl<'a> BytesExt for &'a Vec<u8>
alloc
only.impl<'a> BytesExt for &'a Bytes
bytes
only.impl<'a> BytesExt for &'a BytesMut
bytes
only.impl<'a> BytesExt for &'a [u8]
impl<'a> BytesExt for &'a mut str
impl<'a> BytesExt for &'a mut Box<[u8]>
alloc
only.impl<'a> BytesExt for &'a mut String
impl<'a> BytesExt for &'a mut Vec<u8>
alloc
only.impl<'a> BytesExt for &'a mut BytesMut
bytes
only.