use crate::{http_client::HttpClient, Result};
use serde::Serialize;
#[derive(Debug)]
pub struct Remove<'a> {
http_client: &'a HttpClient,
container: &'a str,
query: Query,
}
impl<'a> Remove<'a> {
pub(crate) fn new(http_client: &'a HttpClient, container: &'a str) -> Self {
let query = Query::default();
Self {
http_client,
container,
query,
}
}
pub fn remove_volumes(mut self, remove_volumes: bool) -> Self {
self.query.v = remove_volumes;
self
}
#[must_use]
pub fn force(mut self, force: bool) -> Self {
self.query.force = force;
self
}
pub async fn send(self) -> Result<()> {
let endpoint = format!("/containers/{}", self.container);
self.http_client
.delete(&endpoint)
.query(self.query)
.into_response()
.await?;
Ok(())
}
}
#[derive(Debug, Default, Serialize)]
struct Query {
v: bool,
force: bool,
link: bool,
}