testcontainers-build 0.1.0

Build Testcontainers images from folders, remote contexts, and pluggable Git providers
Documentation
use crate::ContextLocation;

/// Hold a build context and its optional resource owner.
/// Release the owner when the context is dropped.
pub struct BuildContext {
    /// Get or set the build context location.
    /// Keep its files available while this context exists.
    pub location: ContextLocation,
    _owner: Option<Box<dyn Send + Sync>>,
}

impl BuildContext {
    /// Create a context without an owned resource.
    /// Use this for caller-owned folders and remote URIs.
    pub fn new(location: ContextLocation) -> Self {
        Self {
            location,
            _owner: None,
        }
    }

    /// Create a context with a resource owner.
    /// Drop the owner after Docker finishes reading the context.
    pub fn with_owner(location: ContextLocation, owner: impl Send + Sync + 'static) -> Self {
        Self {
            location,
            _owner: Some(Box::new(owner)),
        }
    }
}