podman_client/exec/
resize.rs

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