assemble_core/
lib.rs

1//! # `assemble-core`
2//!
3//! The api defines the structs, functions, and traits that make up the assemble project.
4//!
5//!
6
7#![deny(rustdoc::broken_intra_doc_links)]
8
9#[macro_use]
10extern crate static_assertions;
11
12#[macro_use]
13extern crate serde;
14
15#[macro_use]
16extern crate log;
17
18pub mod cache;
19pub mod cargo;
20pub mod cryptography;
21pub mod defaults;
22pub mod dependencies;
23pub mod error;
24pub mod exception;
25pub mod file;
26pub mod file_collection;
27pub mod fingerprint;
28pub mod flow;
29pub mod identifier;
30pub mod immutable;
31pub mod lazy_evaluation;
32pub mod logging;
33pub mod named;
34pub mod plugins;
35pub mod project;
36pub mod resources;
37pub mod startup;
38pub mod task;
39pub(crate) mod unstable;
40pub mod utilities;
41pub mod version;
42pub mod web;
43pub mod work_queue;
44pub mod workflow;
45pub mod workspace;
46
47// Re-exports
48pub use exception::BuildResult;
49pub use plugins::Plugin;
50pub use project::Project;
51pub use task::Executable;
52pub use task::Task;
53#[cfg(feature = "unstable")]
54pub use unstable::enabled::*;
55
56pub use workspace::{default_workspaces::ASSEMBLE_HOME, Workspace};
57
58pub mod prelude {
59    //! Provides many useful, often use types and functions within assemble
60
61    pub use super::*;
62    pub use crate::project::shared::SharedProject;
63    pub use lazy_evaluation::{Provider, ProviderExt};
64    pub use plugins::{Plugin, PluginAware, PluginManager};
65    #[cfg(feature = "unstable")]
66    pub use unstable::enabled::prelude::*;
67
68    pub use startup::{initialization::*, invocation::*, listeners};
69
70    pub use crate::error::Result;
71    pub use crate::project::error::ProjectError;
72    pub use crate::project::error::ProjectResult;
73    pub use identifier::{ProjectId, TaskId};
74
75    pub use std::result::Result as StdResult;
76}
77
78pub(crate) use utilities::ok;
79
80#[cfg(feature = "derive")]
81pub use assemble_macros::*;
82
83mod private {
84    use crate::prelude::{Assemble, Settings};
85    use parking_lot::RwLock;
86    use std::sync::Arc;
87
88    /// Trait can only be implemented in the assemble core library.
89    pub trait Sealed {}
90
91    impl Sealed for Arc<RwLock<Settings>> {}
92}
93
94use std::fmt::Display;
95
96/// Executes some function. If an error is returned by the function, then `None` is returned and
97/// the error is printed to the error output. Otherwise, `Some(R)` is returned.
98pub fn execute_assemble<R, E, F>(func: F) -> Option<R>
99where
100    E: Display,
101    F: FnOnce() -> Result<R, E>,
102{
103    match func() {
104        Ok(o) => Some(o),
105        Err(e) => {
106            eprintln!("error: {}", e);
107            None
108        }
109    }
110}
111
112#[doc(hidden)]
113pub mod __export {
114    pub use crate::identifier::TaskId;
115    pub use crate::lazy_evaluation::{Provider, ProviderExt};
116    pub use crate::project::error::ProjectError;
117    pub use crate::project::error::ProjectResult;
118    pub use crate::project::Project;
119    pub use crate::task::create_task::CreateTask;
120    pub use crate::task::initialize_task::InitializeTask;
121    pub use crate::task::task_io::TaskIO;
122    pub use crate::task::{work_handler::serializer::*, Executable};
123}