container-pid 1.0.0

Resolve container names to their PIDs
Documentation
use anyhow::bail;

use crate::cmd;
use crate::docker::parse_docker_output;
use crate::result::Result;
use crate::Container;

#[derive(Clone, Debug)]
pub(crate) struct Podman {}

impl Container for Podman {
    fn lookup(&self, container_id: &str) -> Result<libc::pid_t> {
        let cmd = vec![
            "podman",
            "inspect",
            "--format",
            "{{.State.Running}};{{.State.Pid}}",
            container_id,
        ];
        parse_docker_output(cmd.as_slice(), container_id)
    }
    fn check_required_tools(&self) -> Result<()> {
        if cmd::which("podman").is_some() {
            Ok(())
        } else {
            bail!("podman runtime not found: 'podman' command is not available")
        }
    }
}