1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
pub mod data;
pub mod opts;
pub use data::*;
pub use opts::*;
use crate::{util::url::construct_ep, Docker, Error, Result};
use futures_util::{Stream, TryStreamExt};
use std::{convert::TryFrom, io};
impl Docker {
api_doc! { System => Version
|
pub async fn version(&self) -> Result<Version> {
self.get_json("/version").await
}}
api_doc! { System => Info
|
pub async fn info(&self) -> Result<Info> {
self.get_json("/info").await
}}
api_doc! { System => Ping
|
pub async fn ping(&self) -> Result<PingInfo> {
self.get("/_ping")
.await
.and_then(|resp| PingInfo::try_from(resp.headers()))
}}
api_doc! { System => Events
|
pub fn events<'docker>(
&'docker self,
opts: &EventsOpts,
) -> impl Stream<Item = Result<Event>> + Unpin + 'docker {
let ep = construct_ep("/events", opts.serialize());
let reader = Box::pin(
self.stream_get(ep)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e)),
)
.into_async_read();
Box::pin(
futures_codec::FramedRead::new(reader, futures_codec::LinesCodec)
.map_err(Error::IO)
.and_then(|s: String| async move {
serde_json::from_str(&s).map_err(Error::SerdeJsonError)
}),
)
}}
api_doc! { System => DataUsage
|
pub async fn data_usage(&self) -> Result<DataUsage> {
self.get_json("/system/df").await
}}
}