diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-04-09 09:01:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 09:01:46 +0200 |
commit | c9156ea3b157a7d3f1407eb9819c93888bdb2382 (patch) | |
tree | d1c99551e4b7627e46c3e2baa80d26f963be34fc /src/container.rs | |
parent | 2cba96a44c6e9150c38a12b60b55c32c1c345488 (diff) | |
parent | d9848a08b24b36487b1c63264a8eeb10730568d0 (diff) |
Merge pull request #279 from wojciechkepka/docs
Add Docker API reference hyperlinks to doc comments
Diffstat (limited to 'src/container.rs')
-rw-r--r-- | src/container.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/container.rs b/src/container.rs index dad0dc9..24c41d6 100644 --- a/src/container.rs +++ b/src/container.rs @@ -31,6 +31,8 @@ use crate::datetime::datetime_from_unix_timestamp; use chrono::{DateTime, Utc}; /// Interface for accessing and manipulating a docker container +/// +/// Api Reference: <https://docs.docker.com/engine/api/v1.41/#tag/Container> pub struct Container<'docker> { docker: &'docker Docker, id: String, @@ -57,6 +59,8 @@ impl<'docker> Container<'docker> { } /// Inspects the current docker container instance's details + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerInspect> pub async fn inspect(&self) -> Result<ContainerDetails> { self.docker .get_json::<ContainerDetails>(&format!("/containers/{}/json", self.id)[..]) @@ -64,6 +68,8 @@ impl<'docker> Container<'docker> { } /// Returns a `top` view of information about the container process + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerTop> pub async fn top( &self, psargs: Option<&str>, @@ -79,6 +85,8 @@ impl<'docker> Container<'docker> { } /// Returns a stream of logs emitted but the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerLogs> pub fn logs( &self, opts: &LogsOptions, @@ -111,6 +119,8 @@ impl<'docker> Container<'docker> { /// The `[TtyMultiplexer]` implements Stream for returning Stdout and Stderr chunks. It also implements `[AsyncWrite]` for writing to Stdin. /// /// The multiplexer can be split into its read and write halves with the `[split](TtyMultiplexer::split)` method + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerAttach> pub async fn attach(&self) -> Result<TtyMultiPlexer<'docker>> { let tcp_stream = self.attach_raw().await?; @@ -118,6 +128,8 @@ impl<'docker> Container<'docker> { } /// Returns a set of changes made to the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerChanges> pub async fn changes(&self) -> Result<Vec<Change>> { self.docker .get_json::<Vec<Change>>(&format!("/containers/{}/changes", self.id)[..]) @@ -125,6 +137,8 @@ impl<'docker> Container<'docker> { } /// Exports the current docker container into a tarball + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerExport> pub fn export(&self) -> impl Stream<Item = Result<Vec<u8>>> + 'docker { self.docker .stream_get(format!("/containers/{}/export", self.id)) @@ -132,6 +146,8 @@ impl<'docker> Container<'docker> { } /// Returns a stream of stats specific to this container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerStats> pub fn stats(&self) -> impl Stream<Item = Result<Stats>> + Unpin + 'docker { let codec = futures_codec::LinesCodec {}; @@ -152,6 +168,8 @@ impl<'docker> Container<'docker> { } /// Start the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerStart> pub async fn start(&self) -> Result<()> { self.docker .post(&format!("/containers/{}/start", self.id)[..], None) @@ -160,6 +178,8 @@ impl<'docker> Container<'docker> { } /// Stop the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerStop> pub async fn stop( &self, wait: Option<Duration>, @@ -177,6 +197,8 @@ impl<'docker> Container<'docker> { } /// Restart the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerRestart> pub async fn restart( &self, wait: Option<Duration>, @@ -193,6 +215,8 @@ impl<'docker> Container<'docker> { } /// Kill the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerKill> pub async fn kill( &self, signal: Option<&str>, @@ -209,6 +233,8 @@ impl<'docker> Container<'docker> { } /// Rename the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerRename> pub async fn rename( &self, name: &str, @@ -226,6 +252,8 @@ impl<'docker> Container<'docker> { } /// Pause the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerPause> pub async fn pause(&self) -> Result<()> { self.docker .post(&format!("/containers/{}/pause", self.id)[..], None) @@ -234,6 +262,8 @@ impl<'docker> Container<'docker> { } /// Unpause the container instance + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerUnpause> pub async fn unpause(&self) -> Result<()> { self.docker .post(&format!("/containers/{}/unpause", self.id)[..], None) @@ -242,6 +272,8 @@ impl<'docker> Container<'docker> { } /// Wait until the container stops + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerWait> pub async fn wait(&self) -> Result<Exit> { self.docker .post_json(format!("/containers/{}/wait", self.id), Payload::None) @@ -251,6 +283,8 @@ impl<'docker> Container<'docker> { /// Delete the container instance /// /// Use remove instead to use the force/v options. + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerDelete> pub async fn delete(&self) -> Result<()> { self.docker .delete(&format!("/containers/{}", self.id)[..]) @@ -259,6 +293,8 @@ impl<'docker> Container<'docker> { } /// Delete the container instance (todo: force/v) + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerRemove> pub async fn remove( &self, opts: RmContainerOptions, @@ -272,6 +308,8 @@ impl<'docker> Container<'docker> { } /// Execute a command in this container + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#tag/Exec> pub fn exec( &self, opts: &ExecContainerOptions, @@ -287,6 +325,8 @@ impl<'docker> Container<'docker> { /// directory, `path` should end in `/` or `/`. (assuming a path separator of `/`). If `path` /// ends in `/.` then this indicates that only the contents of the path directory should be /// copied. A symlink is always resolved to its target. + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerArchive> pub fn copy_from( &self, path: &Path, @@ -303,6 +343,8 @@ impl<'docker> Container<'docker> { /// /// The file will be copied at the given location (see `path`) and will be owned by root /// with access mask 644. + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/PutContainerArchive> pub async fn copy_file_into<P: AsRef<Path>>( &self, path: P, @@ -332,6 +374,8 @@ impl<'docker> Container<'docker> { /// Copy a tarball (see `body`) to the container. /// /// The tarball will be copied to the container and extracted at the given location (see `path`). + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/PutContainerArchive> pub async fn copy_to( &self, path: &Path, @@ -354,6 +398,8 @@ impl<'docker> Container<'docker> { } /// Interface for docker containers +/// +/// Api Reference: <https://docs.docker.com/engine/api/v1.41/#tag/Containers> pub struct Containers<'docker> { docker: &'docker Docker, } @@ -365,6 +411,8 @@ impl<'docker> Containers<'docker> { } /// Lists the container instances on the docker host + /// + /// Api Reference: <https://docs.docker.com/engine/api/v1.41/#operation/ContainerList> pub async fn list( &self, opts: &ContainerListOptions, |