workspacer_interface/
cargo_toml_interface.rs

1// ---------------- [ File: workspacer-interface/src/cargo_toml_interface.rs ]
2crate::ix!();
3
4pub trait CargoTomlInterface
5: CheckExistence<Error=CargoTomlError>
6+ Send
7+ Sync
8+ PinWildcardDependencies<Error=CargoTomlError>
9+ CheckRequiredFieldsForPublishing<Error=CargoTomlError>
10+ CheckVersionValidityForPublishing<Error=CargoTomlError>
11+ CheckRequiredFieldsForIntegrity<Error=CargoTomlError>
12+ CheckVersionValidityForIntegrity<Error=CargoTomlError>
13+ GetPackageSection<Error=CargoTomlError>
14+ ReadyForCargoPublish<Error=CargoTomlError>
15+ IsValidVersion
16+ ValidateIntegrity<Error=CargoTomlError>
17+ AsRef<Path>
18{}
19
20#[async_trait]
21pub trait PinWildcardDependencies {
22
23    type Error;
24
25    async fn pin_wildcard_dependencies(
26        &self,
27        lock_versions: &BTreeMap<String, BTreeSet<semver::Version>>,
28    ) -> Result<(), Self::Error>;
29}
30
31pub trait CheckExistence {
32
33    type Error;
34
35    fn check_existence(&self) -> Result<(), Self::Error>;
36}
37
38pub trait CheckRequiredFieldsForPublishing {
39
40    type Error;
41
42    /// Checks if `Cargo.toml` has required fields for publishing
43    fn check_required_fields_for_publishing(&self) -> Result<(), Self::Error>;
44}
45
46pub trait CheckVersionValidityForPublishing {
47
48    type Error;
49
50    /// Ensures that the version field is valid
51    fn check_version_validity_for_publishing(&self) -> Result<(), Self::Error>;
52}
53
54pub trait CheckRequiredFieldsForIntegrity {
55
56    type Error;
57
58    /// Checks if `Cargo.toml` has required fields for integrity purposes
59    fn check_required_fields_for_integrity(&self) -> Result<(), Self::Error>;
60}
61
62pub trait CheckVersionValidityForIntegrity {
63
64    type Error;
65
66    /// Ensures that the version field is valid for integrity purposes
67    fn check_version_validity_for_integrity(&self) -> Result<(), Self::Error>;
68}
69
70pub trait GetPackageSection {
71
72    type Error;
73
74    /// Helper to retrieve the `package` section from `Cargo.toml`
75    fn get_package_section(&self) -> Result<&toml::Value, Self::Error>;
76}
77
78pub trait IsValidVersion {
79
80    /// Checks if the version string is a valid SemVer version
81    fn is_valid_version(&self, version: &str) -> bool;
82}