pub struct ContainerStateManager { /* private fields */ }Expand description
Container state manager
Manages persistent state of running containers
Implementations§
Source§impl ContainerStateManager
impl ContainerStateManager
Sourcepub fn new_with_root(root: Option<PathBuf>) -> Result<Self>
pub fn new_with_root(root: Option<PathBuf>) -> Result<Self>
Create a state manager rooted at an explicit directory, falling back to
default candidates if root is None.
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new state manager
Creates the state directory if it doesn’t exist
Sourcepub fn with_state_dir(state_dir: PathBuf) -> Result<Self>
pub fn with_state_dir(state_dir: PathBuf) -> Result<Self>
Create a state manager rooted at an explicit directory.
Sourcepub fn exec_fifo_path(&self, container_id: &str) -> Result<PathBuf>
pub fn exec_fifo_path(&self, container_id: &str) -> Result<PathBuf>
Return the path to the exec FIFO used for two-phase create/start.
Sourcepub fn rootfs_overlay_dir_path(&self, container_id: &str) -> Result<PathBuf>
pub fn rootfs_overlay_dir_path(&self, container_id: &str) -> Result<PathBuf>
Return the persistent overlayfs state directory for a container.
Sourcepub fn resolve_container(&self, reference: &str) -> Result<ContainerState>
pub fn resolve_container(&self, reference: &str) -> Result<ContainerState>
Resolve a container reference by exact ID, name, or ID prefix
Sourcepub fn save_state(&self, state: &ContainerState) -> Result<()>
pub fn save_state(&self, state: &ContainerState) -> Result<()>
Save container state
Sourcepub fn read_file_nofollow(path: &Path) -> Result<String, Error>
pub fn read_file_nofollow(path: &Path) -> Result<String, Error>
Read a file with O_NOFOLLOW to prevent symlink attacks.
Sourcepub fn load_state(&self, container_id: &str) -> Result<ContainerState>
pub fn load_state(&self, container_id: &str) -> Result<ContainerState>
Load container state
Opens with O_NOFOLLOW to prevent symlink-based TOCTOU attacks.
Sourcepub fn delete_state(&self, container_id: &str) -> Result<()>
pub fn delete_state(&self, container_id: &str) -> Result<()>
Delete container state
Sourcepub fn list_states(&self) -> Result<Vec<ContainerState>>
pub fn list_states(&self) -> Result<Vec<ContainerState>>
List all container states
Sourcepub fn list_running(&self) -> Result<Vec<ContainerState>>
pub fn list_running(&self) -> Result<Vec<ContainerState>>
List only running containers
Sourcepub fn cleanup_stale(&self) -> Result<()>
pub fn cleanup_stale(&self) -> Result<()>
Clean up stale state files (for containers that are no longer running)