Reorganize crate

This commit is contained in:
Carl Lerche
2016-09-23 12:05:32 -07:00
parent d05bfb6346
commit 98e0d954b5
19 changed files with 54 additions and 65 deletions
+4
View File
@@ -1,3 +1,7 @@
//! Buffer allocation
//!
//! This module is currently not really in use
mod heap;
use std::sync::Arc;
+1 -3
View File
@@ -1,6 +1,4 @@
use alloc;
use buf::{MutBuf};
use bytes::Bytes;
use {alloc, MutBuf, Bytes};
use std::cell::Cell;
/// A `Buf` backed by a contiguous region of memory.
+2 -2
View File
@@ -1,7 +1,7 @@
#![allow(warnings)]
use {Buf, MutBuf, AppendBuf, Bytes};
use alloc::{self, /* Pool */};
use {alloc, Buf, MutBuf, Bytes};
use buf::AppendBuf;
use std::{cmp, ptr, slice};
use std::io::Cursor;
use std::rc::Rc;
+2 -1
View File
@@ -4,7 +4,8 @@ pub mod byte;
pub mod ring;
pub mod take;
use {Bytes, Take};
use {Bytes};
use buf::Take;
use byteorder::ByteOrder;
use std::{cmp, fmt, io, ptr, usize};
+1 -1
View File
@@ -1,4 +1,4 @@
use buf::{Buf, MutBuf};
use {Buf, MutBuf};
use std::{cmp};
#[derive(Debug)]
+1 -2
View File
@@ -2,8 +2,7 @@ mod rope;
mod seq;
mod small;
use alloc;
use buf::Buf;
use {alloc, Buf};
use self::seq::Seq;
use self::small::Small;
use self::rope::{Rope, RopeBuf};
+4 -4
View File
@@ -1,7 +1,7 @@
use {Bytes, MutByteBuf};
use buf::{Buf, MutBuf, Source};
use bytes::seq::Seq;
use bytes::small::{Small};
use {Buf, MutBuf, Bytes};
use super::seq::Seq;
use super::small::{Small};
use buf::{Source, MutByteBuf};
use std::{cmp, ops};
use std::io::Cursor;
use std::sync::Arc;
+2 -2
View File
@@ -1,7 +1,7 @@
//! Immutable set of bytes sequential in memory.
use {alloc, MutByteBuf, MutBuf};
use bytes::{Bytes};
use {alloc, MutBuf, Bytes};
use buf::{MutByteBuf};
use std::ops;
use std::io::Cursor;
@@ -1,4 +1,4 @@
use bytes::{Bytes};
use {Bytes};
use std::ops;
use std::io::Cursor;
+4
View File
@@ -0,0 +1,4 @@
//! Used for internal code structure
pub mod buf;
pub mod bytes;
+23 -10
View File
@@ -3,21 +3,34 @@
#[macro_use]
extern crate log;
extern crate byteorder;
mod buf;
mod bytes;
// Implementation in here
mod imp;
pub mod alloc;
pub use buf::{Buf, MutBuf, Source, Sink, Reader, ReadExt, Writer, WriteExt, Fmt};
pub use buf::append::AppendBuf;
pub use buf::block::{BlockBuf, BlockBufCursor};
pub use buf::byte::{ByteBuf, MutByteBuf};
pub use buf::ring::RingBuf;
pub use buf::take::Take;
pub use bytes::Bytes;
pub use imp::buf::{Buf, MutBuf};
pub use imp::bytes::Bytes;
pub mod buf {
pub use imp::buf::{
Source,
Sink,
Reader,
ReadExt,
Writer,
WriteExt,
Fmt,
};
pub use imp::buf::append::AppendBuf;
pub use imp::buf::block::{BlockBuf, BlockBufCursor};
pub use imp::buf::byte::{ByteBuf, MutByteBuf};
pub use imp::buf::ring::RingBuf;
pub use imp::buf::take::Take;
pub use imp::bytes::BytesBuf;
}
use std::u32;
+2 -34
View File
@@ -1,4 +1,5 @@
use bytes::{Buf, MutBuf, AppendBuf};
use bytes::{Buf, MutBuf};
use bytes::buf::AppendBuf;
#[test]
pub fn test_initial_buf_empty() {
@@ -27,36 +28,3 @@ pub fn test_initial_buf_empty() {
assert_eq!(dst, b"hello world");
}
}
/*
#[test]
pub fn test_append_buf_from_pool() {
use bytes::alloc::Pool;
let pool = Pool::with_capacity(2, 256);
// Run in a loop a bunch in hope that if there is a memory issue, it will
// be exposed
for _ in 0..1000 {
let mut buf = pool.new_append_buf().unwrap();
let mut dst: Vec<u8> = vec![];
assert_eq!(buf.remaining(), 256);
buf.write_slice(b"hello world");
assert_eq!(buf.remaining(), 245);
assert_eq!(buf.bytes(), b"hello world");
let view1 = buf.slice(0, 11);
view1.buf().copy_to(&mut dst);
assert_eq!(dst, b"hello world");
assert_eq!(view1, buf.slice(0, 11));
drop(buf);
let mut buf = pool.new_append_buf().unwrap();
buf.write_slice(b"zomg no no no no");
assert_eq!(dst, b"hello world");
}
}
*/
+2 -2
View File
@@ -1,5 +1,5 @@
use bytes::{MutBuf, BlockBuf};
use bytes::{MutBuf};
use bytes::buf::{BlockBuf};
#[test]
pub fn test_block_drop() {
+1 -1
View File
@@ -48,7 +48,7 @@ fn test_read_u16_buffer_underflow() {
#[test]
fn test_vec_sink_capacity() {
use bytes::Sink;
use bytes::buf::Sink;
let mut sink: Vec<u8> = Vec::new();
sink.reserve(16);
+1
View File
@@ -1,4 +1,5 @@
use bytes::*;
use bytes::buf::*;
use std::io;
#[test]
+1 -1
View File
@@ -1,5 +1,5 @@
use bytes::{Buf, MutBuf};
use bytes::MutByteBuf;
use bytes::buf::MutByteBuf;
#[test]
pub fn test_initial_buf_empty() {
+2 -1
View File
@@ -1,4 +1,5 @@
use bytes::{RingBuf, Buf, MutBuf};
use bytes::{Buf, MutBuf};
use bytes::buf::RingBuf;
#[test]
pub fn test_initial_buf_empty() {