build_utils/source/
mod.rs

1use std::path::PathBuf;
2
3mod file;
4pub use file::*;
5
6mod download;
7pub use download::*;
8use crate::build::BuildStepError;
9use std::hash::Hasher;
10
11#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)]
12pub enum SourceSetupError {
13    SourceDoesNotExists,
14    SourceIsNotReadable,
15    NoSpaceOnDisk,
16    TemporaryPathNotWriteable,
17    AlreadyInitialized,
18    Unknown(String)
19}
20
21pub trait BuildSource {
22    /// The name of the source
23    fn name(&self) -> &str;
24
25    /// Generate a unique hash which identifies the source and possible changes
26    fn hash(&self, target: &mut Box<dyn Hasher>);
27
28    fn setup(&mut self) -> Result<(), BuildStepError>;
29    fn local_directory(&self) -> &PathBuf;
30    fn cleanup(&mut self);
31}