podman_client/containers/
resize.rs

1use http_body_util::Empty;
2use hyper::body::Bytes;
3use url::form_urlencoded;
4
5use crate::{
6    client::Client,
7    models::{
8        connection::SendRequestOptions,
9        lib::Error,
10        podman::containers::resize::{ContainerResize, ContainerResizeOptions},
11    },
12};
13
14impl Client {
15    pub async fn container_resize(
16        &self,
17        options: ContainerResizeOptions<'_>,
18    ) -> Result<ContainerResize, Error> {
19        let mut path = ["/libpod/containers/", options.name, "/resize"].concat();
20
21        let mut query = form_urlencoded::Serializer::new(String::new());
22        if let Some(h) = options.h {
23            query.append_pair("h", itoa::Buffer::new().format(h));
24        }
25        if let Some(w) = options.w {
26            query.append_pair("w", itoa::Buffer::new().format(w));
27        }
28        let query_string = query.finish();
29        if !query_string.is_empty() {
30            path += &["?", &query_string].concat();
31        }
32
33        let (_, data) = self
34            .send_request::<_, (), _>(SendRequestOptions {
35                method: "POST",
36                path: &path,
37                header: None,
38                body: Empty::<Bytes>::new(),
39            })
40            .await?;
41
42        Ok(data)
43    }
44}