diff options
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/transport.rs | 14 |
2 files changed, 11 insertions, 11 deletions
@@ -44,12 +44,12 @@ use std::io::{ Read, Result }; use std::iter::IntoIterator; use std::path::Path; use std::sync::Arc; -use transport::{ Body, Transporter }; +use transport::{ Body, Transport }; use url::{ Host, RelativeSchemeData, SchemeData }; /// Entrypoint interface for communicating with docker daemon pub struct Docker { - transport: Transporter + transport: Transport } /// Interface for accessing and manipulating a named docker image @@ -304,7 +304,7 @@ impl Docker { "unix" => { println!("unix.."); Docker { - transport: Transporter::Unix { + transport: Transport::Unix { client: Client::with_connector(UnixSocketConnector), path: domain } } @@ -328,7 +328,7 @@ impl Docker { } else { Client::new() }; - Docker { transport: Transporter::Tcp { client: client, host: format!("https:{}", domain.to_string()) } } + Docker { transport: Transport::Tcp { client: client, host: format!("https:{}", domain.to_string()) } } } } } diff --git a/src/transport.rs b/src/transport.rs index 8c76e88..a2c8d72 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -29,25 +29,25 @@ fn lift_status_err(status: u16) -> Result<Box<Read>> { } } -pub enum Transporter { +pub enum Transport { Tcp { client: Client, host: String }, Unix { client: Client, path: String } } -impl fmt::Debug for Transporter { +impl fmt::Debug for Transport { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Transporter::Tcp { ref host, .. } => { + Transport::Tcp { ref host, .. } => { write!(f, "Tcp({})", host) }, - Transporter::Unix { ref path, .. } => { + Transport::Unix { ref path, .. } => { write!(f, "Unix({})", path) } } } } -impl Transporter { +impl Transport { pub 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, @@ -60,10 +60,10 @@ impl Transporter { pub fn stream(&mut self, method: Method, endpoint: &str, body: Option<Body>) -> Result<Box<Read>> { println!("requesting {:?} {:?}", self, endpoint); let req = match *self { - Transporter::Tcp { ref client, ref host } => { + Transport::Tcp { ref client, ref host } => { client.request(method, &format!("{}{}", host, endpoint)[..]) }, - Transporter::Unix { ref client, ref path } => { + Transport::Unix { ref client, ref path } => { client.request(method, DomainUrl::new(&path, endpoint)) } }; |