mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-24 00:00:14 +02:00
Reorganize crate
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
//! Buffer allocation
|
||||||
|
//!
|
||||||
|
//! This module is currently not really in use
|
||||||
|
|
||||||
mod heap;
|
mod heap;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
use alloc;
|
use {alloc, MutBuf, Bytes};
|
||||||
use buf::{MutBuf};
|
|
||||||
use bytes::Bytes;
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
/// A `Buf` backed by a contiguous region of memory.
|
/// A `Buf` backed by a contiguous region of memory.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#![allow(warnings)]
|
#![allow(warnings)]
|
||||||
|
|
||||||
use {Buf, MutBuf, AppendBuf, Bytes};
|
use {alloc, Buf, MutBuf, Bytes};
|
||||||
use alloc::{self, /* Pool */};
|
use buf::AppendBuf;
|
||||||
use std::{cmp, ptr, slice};
|
use std::{cmp, ptr, slice};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@@ -4,7 +4,8 @@ pub mod byte;
|
|||||||
pub mod ring;
|
pub mod ring;
|
||||||
pub mod take;
|
pub mod take;
|
||||||
|
|
||||||
use {Bytes, Take};
|
use {Bytes};
|
||||||
|
use buf::Take;
|
||||||
use byteorder::ByteOrder;
|
use byteorder::ByteOrder;
|
||||||
use std::{cmp, fmt, io, ptr, usize};
|
use std::{cmp, fmt, io, ptr, usize};
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use buf::{Buf, MutBuf};
|
use {Buf, MutBuf};
|
||||||
use std::{cmp};
|
use std::{cmp};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -2,8 +2,7 @@ mod rope;
|
|||||||
mod seq;
|
mod seq;
|
||||||
mod small;
|
mod small;
|
||||||
|
|
||||||
use alloc;
|
use {alloc, Buf};
|
||||||
use buf::Buf;
|
|
||||||
use self::seq::Seq;
|
use self::seq::Seq;
|
||||||
use self::small::Small;
|
use self::small::Small;
|
||||||
use self::rope::{Rope, RopeBuf};
|
use self::rope::{Rope, RopeBuf};
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use {Bytes, MutByteBuf};
|
use {Buf, MutBuf, Bytes};
|
||||||
use buf::{Buf, MutBuf, Source};
|
use super::seq::Seq;
|
||||||
use bytes::seq::Seq;
|
use super::small::{Small};
|
||||||
use bytes::small::{Small};
|
use buf::{Source, MutByteBuf};
|
||||||
use std::{cmp, ops};
|
use std::{cmp, ops};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
//! Immutable set of bytes sequential in memory.
|
//! Immutable set of bytes sequential in memory.
|
||||||
|
|
||||||
use {alloc, MutByteBuf, MutBuf};
|
use {alloc, MutBuf, Bytes};
|
||||||
use bytes::{Bytes};
|
use buf::{MutByteBuf};
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use bytes::{Bytes};
|
use {Bytes};
|
||||||
use std::ops;
|
use std::ops;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
//! Used for internal code structure
|
||||||
|
|
||||||
|
pub mod buf;
|
||||||
|
pub mod bytes;
|
||||||
+23
-10
@@ -3,21 +3,34 @@
|
|||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
extern crate byteorder;
|
extern crate byteorder;
|
||||||
|
|
||||||
mod buf;
|
// Implementation in here
|
||||||
mod bytes;
|
mod imp;
|
||||||
|
|
||||||
pub mod alloc;
|
pub mod alloc;
|
||||||
|
|
||||||
pub use buf::{Buf, MutBuf, Source, Sink, Reader, ReadExt, Writer, WriteExt, Fmt};
|
pub use imp::buf::{Buf, MutBuf};
|
||||||
pub use buf::append::AppendBuf;
|
pub use imp::bytes::Bytes;
|
||||||
pub use buf::block::{BlockBuf, BlockBufCursor};
|
|
||||||
pub use buf::byte::{ByteBuf, MutByteBuf};
|
pub mod buf {
|
||||||
pub use buf::ring::RingBuf;
|
pub use imp::buf::{
|
||||||
pub use buf::take::Take;
|
Source,
|
||||||
pub use bytes::Bytes;
|
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;
|
use std::u32;
|
||||||
|
|
||||||
|
|||||||
+2
-34
@@ -1,4 +1,5 @@
|
|||||||
use bytes::{Buf, MutBuf, AppendBuf};
|
use bytes::{Buf, MutBuf};
|
||||||
|
use bytes::buf::AppendBuf;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_initial_buf_empty() {
|
pub fn test_initial_buf_empty() {
|
||||||
@@ -27,36 +28,3 @@ pub fn test_initial_buf_empty() {
|
|||||||
assert_eq!(dst, b"hello world");
|
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
@@ -1,5 +1,5 @@
|
|||||||
use bytes::{MutBuf, BlockBuf};
|
use bytes::{MutBuf};
|
||||||
|
use bytes::buf::{BlockBuf};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_block_drop() {
|
pub fn test_block_drop() {
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ fn test_read_u16_buffer_underflow() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_vec_sink_capacity() {
|
fn test_vec_sink_capacity() {
|
||||||
use bytes::Sink;
|
use bytes::buf::Sink;
|
||||||
|
|
||||||
let mut sink: Vec<u8> = Vec::new();
|
let mut sink: Vec<u8> = Vec::new();
|
||||||
sink.reserve(16);
|
sink.reserve(16);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use bytes::*;
|
use bytes::*;
|
||||||
|
use bytes::buf::*;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use bytes::{Buf, MutBuf};
|
use bytes::{Buf, MutBuf};
|
||||||
use bytes::MutByteBuf;
|
use bytes::buf::MutByteBuf;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_initial_buf_empty() {
|
pub fn test_initial_buf_empty() {
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
use bytes::{RingBuf, Buf, MutBuf};
|
use bytes::{Buf, MutBuf};
|
||||||
|
use bytes::buf::RingBuf;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_initial_buf_empty() {
|
pub fn test_initial_buf_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user