Struct lib_ruby_parser::Bytes[][src]

pub struct Bytes {
    pub raw: Vec<u8>,
}

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.

impl PartialEq<Bytes> for Bytes[src]

impl StructuralPartialEq for Bytes[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.