Initial commit

This commit is contained in:
Carl Lerche
2015-01-30 00:04:33 -08:00
commit 52aeab40ee
4 changed files with 32 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
#![crate_name = "bytes"]
/// A trait for objects that provide random and sequential access to bytes.
pub trait Buf {
fn remaining(&self) -> usize;
fn bytes<'a>(&'a self) -> &'a [u8];
fn advance(&mut self, cnt: usize);
fn has_remaining(&self) -> bool {
self.remaining() > 0
}
}
pub trait MutBuf : Buf {
fn mut_bytes<'a>(&'a mut self) -> &'a mut [u8];
}