Struct lib_ruby_parser::Bytes [−][src]
Representation of a byte sequence
Fields
raw: Vec<u8>
Raw vector of bytes
Implementations
impl Bytes
[src]
pub fn new(raw: Vec<u8>) -> Self
[src]
Constructs an instance of Bytes
with a given byte vector
pub fn empty() -> Self
[src]
Constructs an empty instance of Bytes
pub fn as_bytes(&self) -> &[u8]
[src]
Returns a slice of the byte sequence
pub fn as_bytes_mut(&mut self) -> &mut [u8]
[src]
Returns a mutable slice of the byte sequence
pub fn into_bytes(self) -> Vec<u8>
[src]
Consumes itself and converts it into a vector of bytes
pub fn as_str_lossy(&self) -> Result<&str, Utf8Error>
[src]
Converts byte sequence to a string slice, returns error if there are invalid UTF-8 chars
pub fn to_string_lossy(&self) -> String
[src]
Converts byte sequnce to a string, all invalid UTF-8 chars are converted into "replacement char"
pub fn to_string(&self) -> Result<String, FromUtf8Error>
[src]
Converts byte sequence to a String, returns error if there are invalid UTF-8 chars
pub fn into_string(self) -> Result<String, FromUtf8Error>
[src]
Consumes itself and convrters it into a string, returns error if there are invalid UTF-8 chars
pub fn is_valid_utf8(&self) -> bool
[src]
Returns true
if self
represents a valid UTF-8 string
pub fn is_empty(&self) -> bool
[src]
Returns true
if byte sequence is empty
pub fn len(&self) -> usize
[src]
Returns length of the byte sequence
Trait Implementations
impl Clone for Bytes
[src]
impl Debug for Bytes
[src]
impl Default for Bytes
[src]
impl Index<usize> for Bytes
[src]
type Output = u8
The returned type after indexing.
fn index(&self, index: usize) -> &Self::Output
[src]
impl PartialEq<Bytes> for Bytes
[src]
impl StructuralPartialEq for Bytes
[src]
Auto Trait Implementations
impl RefUnwindSafe for Bytes
[src]
impl Send for Bytes
[src]
impl Sync for Bytes
[src]
impl Unpin for Bytes
[src]
impl UnwindSafe for Bytes
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,