summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordoug tangren <d.tangren@gmail.com>2017-01-21 14:12:37 -0500
committerGitHub <noreply@github.com>2017-01-21 14:12:37 -0500
commit1ceb10f32bb263bdcdf71da28958f77ca077f16a (patch)
treed271021bdb43ede170cb64bed56a36f01012aa9b
parent9eb00dcb31ff5b58af4f5c2897ca452defd86ad5 (diff)
parent72e97f3596592f62dc50b33ca732c25cadd9c294 (diff)
Merge pull request #41 from petehayes102/master
Store Cow<str> instead of &str
-rw-r--r--examples/export.rs1
-rw-r--r--src/lib.rs17
-rw-r--r--src/tarball.rs2
-rw-r--r--src/transport.rs2
4 files changed, 13 insertions, 9 deletions
diff --git a/examples/export.rs b/examples/export.rs
index 422c19d..d37ebad 100644
--- a/examples/export.rs
+++ b/examples/export.rs
@@ -2,7 +2,6 @@ extern crate shiplift;
use shiplift::Docker;
use std::env;
-use std::io::prelude::*;
use std::io::copy;
use std::fs::OpenOptions;
diff --git a/src/lib.rs b/src/lib.rs
index dc08cea..70fa49f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -50,6 +50,7 @@ use rep::{Output, PullInfo, Change, ContainerCreateInfo, ContainerDetails,
Container as ContainerRep, Event, Exit, History, ImageDetails, Info, SearchResult,
Stats, Status, Top, Version};
use rustc_serialize::json::{self, Json};
+use std::borrow::Cow;
use std::env::{self, VarError};
use std::io::Read;
use std::iter::IntoIterator;
@@ -71,15 +72,17 @@ pub struct Docker {
/// Interface for accessing and manipulating a named docker image
pub struct Image<'a, 'b> {
docker: &'a Docker,
- name: &'b str,
+ name: Cow<'b, str>,
}
impl<'a, 'b> Image<'a, 'b> {
/// Exports an interface for operations that may be performed against a named image
- pub fn new(docker: &'a Docker, name: &'b str) -> Image<'a, 'b> {
+ pub fn new<S>(docker: &'a Docker, name: S) -> Image<'a, 'b>
+ where S: Into<Cow<'b, str>>
+ {
Image {
docker: docker,
- name: name,
+ name: name.into(),
}
}
@@ -261,15 +264,17 @@ impl<'a> Images<'a> {
/// Interface for accessing and manipulating a docker container
pub struct Container<'a, 'b> {
docker: &'a Docker,
- id: &'b str,
+ id: Cow<'b, str>,
}
impl<'a, 'b> Container<'a, 'b> {
/// Exports an interface exposing operations against a container instance
- pub fn new(docker: &'a Docker, id: &'b str) -> Container<'a, 'b> {
+ pub fn new<S>(docker: &'a Docker, id: S) -> Container<'a, 'b>
+ where S: Into<Cow<'b, str>>
+ {
Container {
docker: docker,
- id: id,
+ id: id.into(),
}
}
diff --git a/src/tarball.rs b/src/tarball.rs
index a631c03..1255928 100644
--- a/src/tarball.rs
+++ b/src/tarball.rs
@@ -3,7 +3,7 @@ use flate2::Compression;
use flate2::write::GzEncoder;
use std::fs::{self, File};
use std::path::{Path, MAIN_SEPARATOR};
-use std::io::{self, Write, Read};
+use std::io::{self, Write};
use tar::Archive;
// todo: this is pretty involved. (re)factor this into its own crate
diff --git a/src/transport.rs b/src/transport.rs
index 43852d8..05ac125 100644
--- a/src/transport.rs
+++ b/src/transport.rs
@@ -12,7 +12,7 @@ use self::hyper::header::ContentType;
use self::hyper::status::StatusCode;
use hyper::method::Method;
use std::fmt;
-use std::io::{Read, Write};
+use std::io::Read;
use hyperlocal::DomainUrl;
pub fn tar() -> ContentType {