pub struct CaseScope { /* private fields */ }Expand description
The network and volume of one case, and the label and names of everything created in it.
Implementations§
Source§impl CaseScope
impl CaseScope
Sourcepub async fn create_container(
&self,
participant: &str,
spec: ContainerSpec,
deadline: Instant,
) -> Result<Container, GenericError>
pub async fn create_container( &self, participant: &str, spec: ContainerSpec, deadline: Instant, ) -> Result<Container, GenericError>
Creates the container for participant from spec, without starting it.
The container is named CaseScope::container_name, joins the case network under the participant’s name, which
is also its host name, and carries the scope’s labels, so CaseScope::reclaim removes it.
§Errors
Returns an error if Docker refuses the container, for example because the image is missing or the name is
taken, or if deadline passes first.
Source§impl CaseScope
impl CaseScope
Sourcepub fn new(
docker: Docker,
id: impl Into<String>,
platform: ScopePlatform,
) -> Self
pub fn new( docker: Docker, id: impl Into<String>, platform: ScopePlatform, ) -> Self
Creates a scope with the given ID. Nothing is created in Docker until Self::prepare.
The ID must be unique among the scopes that exist on the Docker daemon, and valid in Docker resource names.
Sourcepub fn resource_name(&self) -> String
pub fn resource_name(&self) -> String
Returns the name of the case network, which is also the name of the case volume.
Sourcepub fn container_name(&self, participant: &str) -> String
pub fn container_name(&self, participant: &str) -> String
Returns the name of the container for participant.
Sourcepub async fn prepare(&self, deadline: Instant) -> Result<(), GenericError>
pub async fn prepare(&self, deadline: Instant) -> Result<(), GenericError>
Creates the case network, then the case volume if the platform has one.
§Errors
Returns an error if a network of that name belongs to another case, if a volume of that name exists, if Docker
refuses to create a resource, or if deadline passes first.
Sourcepub async fn reclaim(&self, deadline: Instant) -> Result<(), GenericError>
pub async fn reclaim(&self, deadline: Instant) -> Result<(), GenericError>
Removes every container of the scope with its anonymous volumes, then the case volume, then the case network.
Running containers are killed. Every removal is attempted, each bounded by deadline, and a resource that is
already gone counts as removed. A volume or network of the scope’s name without the scope’s label belongs to
someone else, so it is not removed.
§Errors
Returns an error listing every resource that could not be removed by the deadline, and every volume or network that was not removed because it lacks the scope’s label.