Skip to main content

CaseScope

Struct CaseScope 

Source
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

Source

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

Source

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.

Source

pub fn resource_name(&self) -> String

Returns the name of the case network, which is also the name of the case volume.

Source

pub fn container_name(&self, participant: &str) -> String

Returns the name of the container for participant.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for CaseScope

Source§

fn clone(&self) -> CaseScope

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CaseScope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more