[−][src]Trait devbox_build::Resource
A resource represents anything that is input or output of a build step.
Typical resources are files and directories with build steps like copying, moving, linking or invoking external commands.
The main resource property is it's optional timestamp. Build steps should treat output resources without one as out of date and build it unconditionally. When input resource does not have it's timestamp it should be considered as changed and therefore rebuild the output the same way as when input is newer the output. Typical scenario for lack or timestamp is when output resources do not exists yet (clean builds)
Required methods
fn timestamp(&self) -> Option<SystemTime>
Name of the resource used for logging and error reporting Return resource timestamp. Can be None for input resources that should be considered as changed in every build run or output resources that do not exists yet.
Provided methods
fn mk_from<F, R, S>(&self, description: &str, src: S, by: F) where
R: Resource,
S: AsResource<R>,
F: FnOnce(),
R: Resource,
S: AsResource<R>,
F: FnOnce(),
Build the resource form a given src
resource as a side product of given function by
respecting resource timestamps meaning that function by
will only be ran if the output
needs to be build.
This method forces the by
function to handle any errors on it's own and stop Cargo build
using a panic. To propagate the error, use mk_from_result()
fn mk_from_result<E, F, R, S>(
&self,
description: &str,
src: S,
by: F
) -> Result<(), E> where
R: Resource,
S: AsRef<R>,
F: FnOnce() -> Result<(), E>,
&self,
description: &str,
src: S,
by: F
) -> Result<(), E> where
R: Resource,
S: AsRef<R>,
F: FnOnce() -> Result<(), E>,
Same as mk_from()
with error propagation
Implementations on Foreign Types
impl<R> Resource for Vec<R> where
R: Resource,
[src]
R: Resource,
fn timestamp(&self) -> Option<SystemTime>
[src]
Implementors
impl Resource for Unit
[src]
fn timestamp(&self) -> Option<SystemTime>
[src]
impl Resource for Dir
[src]
fn timestamp(&self) -> Option<SystemTime>
[src]
impl Resource for File
[src]
fn timestamp(&self) -> Option<SystemTime>
[src]
impl<R> Resource for Set<R> where
R: Resource,
[src]
R: Resource,