stylus_tools/core/project/
mod.rs

1// Copyright 2025, Offchain Labs, Inc.
2// For licensing, see https://github.com/OffchainLabs/stylus-sdk-rs/blob/main/licenses/COPYRIGHT.md
3
4use std::path::PathBuf;
5
6pub use hash::{hash_project, ProjectHash};
7pub use init::{init_contract, init_workspace, InitError};
8pub use new::{new_contract, new_workspace};
9
10pub mod contract;
11pub mod workspace;
12
13mod hash;
14mod init;
15mod new;
16
17#[derive(Debug, Default)]
18pub struct ProjectConfig {
19    pub source_file_patterns: Vec<String>,
20}
21
22#[derive(Debug)]
23pub enum ProjectKind {
24    Contract,
25    Workspace,
26}
27
28#[derive(Debug, thiserror::Error)]
29pub enum ProjectError {
30    #[error("io error: {0}")]
31    Io(#[from] std::io::Error),
32    #[error("Error processing path: {0}")]
33    Glob(#[from] glob::GlobError),
34
35    #[error("{0}")]
36    Command(#[from] crate::error::CommandError),
37    #[error("rust toolchain error: {0}")]
38    Toolchain(#[from] crate::utils::toolchain::ToolchainError),
39
40    #[error("Unable to read directory {dir}: {1}", dir = .0.display())]
41    DirectoryRead(PathBuf, std::io::Error),
42    #[error("Error finding file in {dir}: {1}", dir = .0.display())]
43    DirectoryEntry(PathBuf, std::io::Error),
44    #[error("Failed to read glob pattern '{0}': {1}")]
45    GlobPattern(String, glob::PatternError),
46    #[error("failed to open file {filename}: {1}", filename = .0.display())]
47    FileOpen(PathBuf, std::io::Error),
48    #[error("failed to read file {filename}: {1}", filename = .0.display())]
49    FileRead(PathBuf, std::io::Error),
50}