Struct ntex_bytes::ByteString [−][src]
pub struct ByteString(_);
Expand description
An immutable UTF-8 encoded string with Bytes as a storage.
Implementations
Unwraps this ByteString into the underlying Bytes object.
Creates a new ByteString from a &'static str.
Returns a slice of self for the provided range.
This will increment the reference count for the underlying memory and
return a new ByteString handle set to the slice.
This operation is O(1).
Examples
use ntex_bytes::ByteString; let a = ByteString::from("hello world"); let b = a.slice(2..5); assert_eq!(b, "llo");
Panics
Requires that begin <= end and end <= self.len(), otherwise slicing
will panic.
Splits the bytestring into two at the given index.
Afterwards self contains elements [0, at), and the returned ByteString
contains elements [at, len).
This is an O(1) operation that just increases the reference count and
sets a few indices.
Examples
use ntex_bytes::ByteString; let mut a = ByteString::from("hello world"); let b = a.split_off(5); assert_eq!(a, "hello"); assert_eq!(b, " world");
Panics
Panics if at > len.
Splits the bytestring into two at the given index.
Afterwards self contains elements [at, len), and the returned
Bytes contains elements [0, at).
This is an O(1) operation that just increases the reference count and
sets a few indices.
Examples
use ntex_bytes::ByteString; let mut a = ByteString::from("hello world"); let b = a.split_to(5); assert_eq!(a, " world"); assert_eq!(b, "hello");
Panics
Panics if at > len.
Creates a new ByteString from a Bytes.
Safety
This function is unsafe because it does not check the bytes passed to it are valid UTF-8.
If this constraint is violated, it may cause memory unsafety issues with future users of
the ByteString, as we assume that ByteStrings are valid UTF-8. However, the most likely
issue is that the data gets corrupted.
Trait Implementations
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for ByteStringimpl Send for ByteStringimpl Sync for ByteStringimpl Unpin for ByteStringimpl UnwindSafe for ByteStringBlanket Implementations
Mutably borrows from an owned value. Read more