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 Debug for Str
[src]
impl PartialEq for Str
[src]
fn eq(&self, __arg_0: &Str) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Str) -> bool
[src]
This method tests for !=
.
impl Eq for Str
[src]
impl Copy for Str
[src]
impl Clone for Str
[src]
fn clone(&self) -> Str
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more