Skip to content

Commit

Permalink
move buffer to external crate
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Feb 24, 2018
1 parent 961754d commit da77659
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 319 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ default = []

[dependencies]
curl = "0.4"
http = "0.1.1"
http = "0.1"
ringtail = "0.1"

[dependencies.json]
version = "0.11"
Expand Down
312 changes: 0 additions & 312 deletions src/buffer.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ extern crate curl;
pub extern crate http;
#[cfg(feature = "json")]
extern crate json;
extern crate ringtail;

pub mod body;
pub mod client;
pub mod error;
pub mod options;
mod transport;
mod buffer;

pub use body::Body;
pub use client::Client;
Expand Down
9 changes: 4 additions & 5 deletions src/transport.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use buffer::Buffer;
use ringtail::ByteBuffer;
use curl;
use http;
use std::cell::RefCell;
Expand Down Expand Up @@ -43,7 +43,7 @@ struct Data {
/// Indicates if the header has been read completely.
header_complete: bool,
/// Temporary buffer for the response body.
buffer: Buffer,
buffer: ByteBuffer,
}

impl Transport {
Expand All @@ -61,7 +61,7 @@ impl Transport {
request_body: Body::default(),
response: http::response::Builder::new(),
header_complete: false,
buffer: Buffer::new(),
buffer: ByteBuffer::new(),
}));

Transport {
Expand Down Expand Up @@ -344,7 +344,6 @@ impl curl::easy::Handler for Collector {

// Gets called by curl when bytes from the response body are received.
fn write(&mut self, data: &[u8]) -> Result<usize, curl::easy::WriteError> {
self.data.borrow_mut().buffer.push(data);
Ok(data.len())
Ok(self.data.borrow_mut().buffer.push(data))
}
}

0 comments on commit da77659

Please sign in to comment.