summaryrefslogtreecommitdiffstats
path: root/src/transport.rs
diff options
context:
space:
mode:
authorsoftprops <d.tangren@gmail.com>2015-05-03 14:50:51 -0400
committersoftprops <d.tangren@gmail.com>2015-05-03 14:50:51 -0400
commitd96530cb3c63b33e9ace4b26c89a88a6c1c4454f (patch)
tree9228aac501f5b438e70eb41d29787bb3f29b496b /src/transport.rs
parent861e24d362921fafcb5e15415dd3d3bcf2bedc76 (diff)
simplify
Diffstat (limited to 'src/transport.rs')
-rw-r--r--src/transport.rs17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/transport.rs b/src/transport.rs
index 4ea78c9..4b7fab2 100644
--- a/src/transport.rs
+++ b/src/transport.rs
@@ -33,11 +33,6 @@ impl<'a> Body<'a> {
/// Primary interface for communicating with docker daemon
pub trait Transport {
- fn request(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<String>;
- fn stream(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<Box<Read>>;
-}
-
-impl Transport for UnixStream {
fn request(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<String> {
let mut res = match self.stream(method, endpoint, body) {
Ok(r) => r,
@@ -46,7 +41,10 @@ impl Transport for UnixStream {
let mut body = String::new();
res.read_to_string(&mut body).map(|_| body)
}
+ fn stream(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<Box<Read>>;
+}
+impl Transport for UnixStream {
fn stream(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<Box<Read>> {
let method_str = match method {
Method::Put => "PUT",
@@ -65,15 +63,6 @@ impl Transport for UnixStream {
}
impl Transport for (Client, String) {
- fn request(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<String> {
- let mut res = match self.stream(method, endpoint, body) {
- Ok(r) => r,
- Err(e) => panic!("failed request {:?}", e)
- };
- let mut body = String::new();
- res.read_to_string(&mut body).map(|_| body)
- }
-
fn stream(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<Box<Read>> {
let uri = format!("{}{}", self.1, endpoint);
let req = match method {