[][src]Trait devbox_build::Resource

pub trait Resource: Debug {
    fn timestamp(&self) -> Option<SystemTime>;

    fn mk_from<F, R, S>(&self, description: &str, src: S, by: F)
    where
        R: Resource,
        S: AsResource<R>,
        F: FnOnce()
, { ... }
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>
, { ... } }

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.

Loading content...

Provided methods

fn mk_from<F, R, S>(&self, description: &str, src: S, by: F) where
    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>, 

Same as mk_from() with error propagation

Loading content...

Implementations on Foreign Types

impl<R> Resource for Vec<R> where
    R: Resource
[src]

Loading content...

Implementors

impl Resource for Unit[src]

impl Resource for Dir[src]

impl Resource for File[src]

impl<R> Resource for Set<R> where
    R: Resource
[src]

Loading content...