testcontainers_build/sources/context.rs
1use crate::ContextLocation;
2
3/// Hold a build context and its optional resource owner.
4/// Release the owner when the context is dropped.
5pub struct BuildContext {
6 /// Get or set the build context location.
7 /// Keep its files available while this context exists.
8 pub location: ContextLocation,
9 _owner: Option<Box<dyn Send + Sync>>,
10}
11
12impl BuildContext {
13 /// Create a context without an owned resource.
14 /// Use this for caller-owned folders and remote URIs.
15 pub fn new(location: ContextLocation) -> Self {
16 Self {
17 location,
18 _owner: None,
19 }
20 }
21
22 /// Create a context with a resource owner.
23 /// Drop the owner after Docker finishes reading the context.
24 pub fn with_owner(location: ContextLocation, owner: impl Send + Sync + 'static) -> Self {
25 Self {
26 location,
27 _owner: Some(Box::new(owner)),
28 }
29 }
30}