workspacer_toml_interface/
interface.rs

1// ---------------- [ File: workspacer-toml-interface/src/interface.rs ]
2crate::ix!();
3
4pub trait CargoTomlInterface
5: CheckExistence<Error=CargoTomlError>
6+ Send
7+ Sync
8+ Versioned<Error=CargoTomlError>
9+ GetContent
10//+ PinWildcardDependencies<Error=CargoTomlError>
11+ CheckRequiredFieldsForPublishing<Error=CargoTomlError>
12+ CheckVersionValidityForPublishing<Error=CargoTomlError>
13+ CheckRequiredFieldsForIntegrity<Error=CargoTomlError>
14+ CheckVersionValidityForIntegrity<Error=CargoTomlError>
15+ SaveToDisk<Error=CargoTomlError>
16+ UpdateDependencyVersionRaw<Error=CargoTomlError>
17+ GetPackageSection<Error=CargoTomlError>
18+ GetPackageSectionMut<Error=CargoTomlError>
19//+ ReadyForCargoPublish<Error=CargoTomlError>
20+ IsValidVersion
21+ ValidateIntegrity<Error=CargoTomlError>
22+ GatherBinTargetNames<Error=CargoTomlError>
23+ AsRef<Path>
24+ GetPackageAuthors<Error=CargoTomlError>
25+ GetPackageAuthorsOrFallback<Error=CargoTomlError>
26+ GetRustEdition<Error=CargoTomlError>
27+ GetRustEditionOrFallback<Error=CargoTomlError>
28+ GetLicenseType<Error=CargoTomlError>
29+ GetLicenseTypeOrFallback<Error=CargoTomlError>
30+ GetCrateRepositoryLocation<Error=CargoTomlError>
31+ GetCrateRepositoryLocationOrFallback<Error=CargoTomlError>
32+ WriteDocumentBack<Error=CargoTomlError>
33+ DocumentClone<Error=CargoTomlError>
34{}
35
36pub trait GetContent {
37    fn get_content(&self) -> &toml::Value;
38}
39
40#[async_trait]
41pub trait WriteDocumentBack {
42    type Error;
43    async fn write_document_back(&mut self, doc: &toml_edit::Document) 
44        -> Result<(),Self::Error>; 
45}
46
47#[async_trait]
48pub trait DocumentClone {
49    type Error;
50    async fn document_clone(&self) -> Result<toml_edit::Document,Self::Error>;
51}
52
53#[async_trait]
54pub trait SaveToDisk {
55    type Error;
56    async fn save_to_disk(&self) -> Result<(), Self::Error>;
57}
58
59pub trait UpdateDependencyVersionRaw {
60    type Error;
61    fn update_dependency_version(
62        &mut self,
63        dep_name: &str,
64        new_version: &str,
65    ) -> Result<bool, Self::Error>;
66}
67
68#[async_trait]
69pub trait GatherBinTargetNames {
70    type Error;
71    async fn gather_bin_target_names(&self) -> Result<Vec<String>, Self::Error>;
72}
73
74pub trait Versioned {
75    type Error: std::fmt::Debug;
76    fn version(&self) -> Result<semver::Version,Self::Error>;
77}
78
79pub trait CheckExistence {
80
81    type Error;
82
83    fn check_existence(&self) -> Result<(), Self::Error>;
84}
85
86pub trait CheckRequiredFieldsForPublishing {
87
88    type Error;
89
90    /// Checks if `Cargo.toml` has required fields for publishing
91    fn check_required_fields_for_publishing(&self) -> Result<(), Self::Error>;
92}
93
94pub trait CheckVersionValidityForPublishing {
95
96    type Error;
97
98    /// Ensures that the version field is valid
99    fn check_version_validity_for_publishing(&self) -> Result<(), Self::Error>;
100}
101
102pub trait CheckRequiredFieldsForIntegrity {
103
104    type Error;
105
106    /// Checks if `Cargo.toml` has required fields for integrity purposes
107    fn check_required_fields_for_integrity(&self) -> Result<(), Self::Error>;
108}
109
110pub trait CheckVersionValidityForIntegrity {
111
112    type Error;
113
114    /// Ensures that the version field is valid for integrity purposes
115    fn check_version_validity_for_integrity(&self) -> Result<(), Self::Error>;
116}
117
118pub trait GetPackageSection {
119
120    type Error;
121
122    /// Helper to retrieve the `package` section from `Cargo.toml`
123    fn get_package_section(&self) -> Result<&toml::Value, Self::Error>;
124}
125
126pub trait GetPackageSectionMut {
127
128    type Error;
129
130    /// Helper to retrieve the `package` section from `Cargo.toml`
131    fn get_package_section_mut(&mut self) -> Result<&mut toml::Value, Self::Error>;
132}
133
134pub trait IsValidVersion {
135
136    /// Checks if the version string is a valid SemVer version
137    fn is_valid_version(&self, version: &str) -> bool;
138}
139
140pub trait GetPackageAuthors {
141    type Error;
142    fn get_package_authors(&self) -> Result<Option<Vec<String>>, Self::Error>;
143}
144
145#[async_trait]
146pub trait GetPackageAuthorsOrFallback {
147    type Error;
148    async fn get_package_authors_or_fallback(&self) -> Result<Option<Vec<String>>, Self::Error>;
149}
150
151pub trait GetRustEdition {
152    type Error;
153    fn get_rust_edition(&self) -> Result<Option<String>, Self::Error>;
154}
155
156#[async_trait]
157pub trait GetRustEditionOrFallback {
158    type Error;
159    async fn get_rust_edition_or_fallback(&self) -> Result<Option<String>, Self::Error>;
160}
161
162pub trait GetLicenseType {
163    type Error;
164    fn get_license_type(&self) -> Result<Option<String>, Self::Error>;
165}
166
167#[async_trait]
168pub trait GetLicenseTypeOrFallback {
169    type Error;
170    async fn get_license_type_or_fallback(&self) -> Result<Option<String>, Self::Error>;
171}
172
173pub trait GetCrateRepositoryLocation {
174    type Error;
175    fn get_crate_repository_location(&self) -> Result<Option<String>, Self::Error>;
176}
177
178#[async_trait]
179pub trait GetCrateRepositoryLocationOrFallback {
180    type Error;
181    async fn get_crate_repository_location_or_fallback(&self) -> Result<Option<String>, Self::Error>;
182}