workspacer_interface/
crate_handle_interface.rs1crate::ix!();
3
4pub trait CrateHandleInterface<P>
5: ValidateIntegrity<Error=CrateError>
6+ Send
7+ Sync
8+ Named
9+ Versioned
10+ IsPrivate<Error=CrateError>
11+ TryPublish<Error=CrateError>
12+ ReadFileString
13+ EnsureGitClean<Error=GitError>
14+ NameAllFiles<Error=CrateError>
15+ PinWildcardDependencies<Error=CrateError>
16+ PinAllWildcardDependencies<Error=CrateError>
17+ ReadyForCargoPublish<Error=CrateError>
18+ CheckIfSrcDirectoryContainsValidFiles
19+ CheckIfReadmeExists
20+ GetReadmePath
21+ GetSourceFilesWithExclusions
22+ GetTestFiles
23+ HasTestsDirectory
24+ GetFilesInDirectory
25+ GetFilesInDirectoryWithExclusions
26+ HasCargoToml
27+ AsRef<Path>
28+ AsyncTryFrom<P,Error=CrateError>
29where
30 for<'async_trait>
31 P
32 : HasCargoTomlPathBuf
33 + AsRef<Path>
34 + Send
35 + Sync
36 + 'async_trait,
37
38 CrateError: From<<P as HasCargoTomlPathBuf>::Error>,
39{}
40
41pub trait Versioned {
42 type Error: std::fmt::Debug;
43 fn version(&self) -> Result<semver::Version,Self::Error>;
44}
45
46pub trait IsPrivate {
47 type Error;
48 fn is_private(&self) -> Result<bool,Self::Error>;
49}
50
51#[async_trait]
52pub trait TryPublish {
53 type Error;
54 async fn try_publish(
55 &self,
56 ) -> Result<(), Self::Error>;
57}
58
59#[async_trait]
63pub trait ReadFileString {
64 async fn read_file_string(&self, path: &Path) -> Result<String, CrateError>;
65}
66
67#[async_trait]
69pub trait NameAllFiles {
70 type Error;
71
72 async fn name_all_files(&self) -> Result<(), Self::Error>;
75}
76
77#[async_trait]
78pub trait GetTestFiles {
79
80 async fn test_files(&self) -> Result<Vec<PathBuf>, CrateError>;
81}
82
83pub trait HasTestsDirectory {
84
85 fn has_tests_directory(&self) -> bool;
86}
87
88pub trait CheckIfReadmeExists {
89
90 fn check_readme_exists(&self) -> Result<(), CrateError>;
91}
92
93#[async_trait]
94pub trait GetReadmePath {
95
96 async fn readme_path(&self) -> Result<Option<PathBuf>, CrateError>;
97}
98
99pub trait HasCargoToml {
100
101 fn cargo_toml<'a>(&'a self) -> &'a dyn CargoTomlInterface;
102}
103
104#[async_trait]
105pub trait HasCargoTomlPathBuf {
106
107 type Error;
108
109 async fn cargo_toml_path_buf(&self) -> Result<PathBuf, Self::Error>;
110}
111
112#[async_trait]
113impl<P> HasCargoTomlPathBuf for P
114where for <'async_trait> P: AsRef<Path> + Send + Sync + 'async_trait
115{
116 type Error = CrateError;
117
118 async fn cargo_toml_path_buf(&self) -> Result<PathBuf, Self::Error>
120 {
121 let cargo_path = self.as_ref().join("Cargo.toml");
122 if fs::metadata(&cargo_path).await.is_ok() {
123 Ok(cargo_path)
124 } else {
125 Err(CrateError::FileNotFound {
126 missing_file: cargo_path,
127 })
128 }
129 }
130}
131
132pub trait CheckIfSrcDirectoryContainsValidFiles {
133
134 fn check_src_directory_contains_valid_files(&self) -> Result<(), CrateError>;
135}
136
137#[async_trait]
138pub trait GetSourceFilesWithExclusions {
139
140 async fn source_files_excluding(&self, exclude_files: &[&str]) -> Result<Vec<PathBuf>, CrateError>;
141}
142
143#[async_trait]
144pub trait GetFilesInDirectory {
145
146 async fn get_files_in_dir(&self, dir_name: &str, extension: &str)
147 -> Result<Vec<PathBuf>, CrateError>;
148}
149
150#[async_trait]
151pub trait GetFilesInDirectoryWithExclusions {
152
153 async fn get_files_in_dir_with_exclusions(
154 &self,
155 dir_name: &str,
156 extension: &str,
157 exclude_files: &[&str]
158 ) -> Result<Vec<PathBuf>, CrateError>;
159}
160
161#[async_trait]
163pub trait ReadyForCargoPublish {
164
165 type Error;
166
167 async fn ready_for_cargo_publish(&self) -> Result<(), Self::Error>;
169}