Enum byte::ctx::Bytes
[−]
[src]
pub enum Bytes { Len(usize), Pattern(&'static [u8]), PatternUntil(&'static [u8], usize), }
Context for &[u8] to determine where the slice ends.
Pattern will be included in the result
Example
use byte::*; use byte::ctx::*; let bytes: &[u8] = &[0xde, 0xad, 0xbe, 0xef, 0x00, 0xff]; let sub: &[u8] = bytes.read_with(&mut 0, Bytes::Len(2)).unwrap(); assert_eq!(sub, &[0xde, 0xad]); static PATTERN: &'static [u8; 2] = &[0x00, 0xff]; let sub: &[u8] = bytes.read_with(&mut 0, Bytes::Pattern(PATTERN)).unwrap(); assert_eq!(sub, &[0xde, 0xad, 0xbe, 0xef, 0x00, 0xff]); let sub: &[u8] = bytes.read_with(&mut 0, Bytes::PatternUntil(PATTERN, 4)).unwrap(); assert_eq!(sub, &[0xde, 0xad, 0xbe, 0xef]);
Variants
Len(usize)
Take fix-length bytes
Pattern(&'static [u8])
Take bytes until reaching a byte pattern
PatternUntil(&'static [u8], usize)
Take bytes until either byte pattern or length reached
Trait Implementations
impl Debug for Bytes
[src]
impl PartialEq for Bytes
[src]
fn eq(&self, __arg_0: &Bytes) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Bytes) -> bool
[src]
This method tests for !=
.