Enum byte::ctx::Str[][src]

pub enum Str {
    Len(usize),
    Delimiter(u8),
    DelimiterUntil(u8, usize),
}

Context for &str to determine where a &str ends.

Pattern will not be included in the result

Default to NULL delimiter.

Example

use byte::*;
use byte::ctx::*;

let bytes: &[u8] = b"hello, world!\0";

let str: &str = bytes.read(&mut 0).unwrap();
assert_eq!(str, "hello, world!");

let str: &str = bytes.read_with(&mut 0, Str::Len(5)).unwrap();
assert_eq!(str, "hello");

let str: &str = bytes.read_with(&mut 0, Str::Delimiter(b"!"[0])).unwrap();
assert_eq!(str, "hello, world");

let str: &str = bytes.read_with(&mut 0, Str::DelimiterUntil(NULL, 5)).unwrap();
assert_eq!(str, "hello");

Variants

Len(usize)

Take fix-length bytes as str

Delimiter(u8)

Take bytes until reaching a delimiter

DelimiterUntil(u8, usize)

Take bytes until either delimiter or length reached

Trait Implementations

impl Clone for Str[src]

impl Copy for Str[src]

impl Debug for Str[src]

impl Default for Str[src]

impl Eq for Str[src]

impl PartialEq<Str> for Str[src]

impl StructuralEq for Str[src]

impl StructuralPartialEq for Str[src]

impl<'a> TryRead<'a, Str> for &'a str[src]

Auto Trait Implementations

impl Send for Str

impl Sync for Str

impl Unpin for Str

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, 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.