workspacer_interface/
cargo_toml_interface.rs

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