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
+2
View File
@@ -0,0 +1,2 @@
/target
/Cargo.lock
+11
View File
@@ -0,0 +1,11 @@
[package]
name = "bytes"
version = "0.0.1"
authors = ["Carl Lerche <[email protected]>"]
description = "Types and traits for working with bytes"
license = "MIT"
# include = [
# "Cargo.toml",
# "src/**/*.rs",
# ]
View File
+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];
}