[−][src]Struct yukikaze::client::upgrade::websocket::SecKey
Websocket's Sec-Websocket-Key
value
Added during upgrade
Methods
impl SecKey
[src]
Methods from Deref<Target = Bytes>
pub fn len(&self) -> usize
[src]
Returns the number of bytes contained in this Bytes
.
Examples
use bytes::Bytes; let b = Bytes::from(&b"hello"[..]); assert_eq!(b.len(), 5);
pub fn is_empty(&self) -> bool
[src]
Returns true if the Bytes
has a length of 0.
Examples
use bytes::Bytes; let b = Bytes::new(); assert!(b.is_empty());
pub fn slice(&self, begin: usize, end: usize) -> Bytes
[src]
Returns a slice of self for the index range [begin..end)
.
This will increment the reference count for the underlying memory and
return a new Bytes
handle set to the slice.
This operation is O(1)
.
Examples
use bytes::Bytes; let a = Bytes::from(&b"hello world"[..]); let b = a.slice(2, 5); assert_eq!(&b[..], b"llo");
Panics
Requires that begin <= end
and end <= self.len()
, otherwise slicing
will panic.
pub fn slice_from(&self, begin: usize) -> Bytes
[src]
Returns a slice of self for the index range [begin..self.len())
.
This will increment the reference count for the underlying memory and
return a new Bytes
handle set to the slice.
This operation is O(1)
and is equivalent to self.slice(begin, self.len())
.
Examples
use bytes::Bytes; let a = Bytes::from(&b"hello world"[..]); let b = a.slice_from(6); assert_eq!(&b[..], b"world");
Panics
Requires that begin <= self.len()
, otherwise slicing will panic.
pub fn slice_to(&self, end: usize) -> Bytes
[src]
Returns a slice of self for the index range [0..end)
.
This will increment the reference count for the underlying memory and
return a new Bytes
handle set to the slice.
This operation is O(1)
and is equivalent to self.slice(0, end)
.
Examples
use bytes::Bytes; let a = Bytes::from(&b"hello world"[..]); let b = a.slice_to(5); assert_eq!(&b[..], b"hello");
Panics
Requires that end <= self.len()
, otherwise slicing will panic.
pub fn slice_ref(&self, subset: &[u8]) -> Bytes
[src]
Returns a slice of self that is equivalent to the given subset
.
When processing a Bytes
buffer with other tools, one often gets a
&[u8]
which is in fact a slice of the Bytes
, i.e. a subset of it.
This function turns that &[u8]
into another Bytes
, as if one had
called self.slice()
with the offsets that correspond to subset
.
This operation is O(1)
.
Examples
use bytes::Bytes; let bytes = Bytes::from(&b"012345678"[..]); let as_slice = bytes.as_ref(); let subset = &as_slice[2..6]; let subslice = bytes.slice_ref(&subset); assert_eq!(&subslice[..], b"2345");
Panics
Requires that the given sub
slice is in fact contained within the
Bytes
buffer; otherwise this function will panic.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.