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

Take fix-length bytes as str

Take bytes until reaching a delimiter

Take bytes until either delimiter or length reached

Trait Implementations

impl Debug for Str
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Str
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Str
[src]

impl Copy for Str
[src]

impl Clone for Str
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Default for Str
[src]

[src]

Returns the "default value" for a type. Read more