A trait for storing and retrieving changes. The primary operations are: - Loading complete changes by hash - Reading content bytes for specific vertices - Checking for change/content existence # Type Parameters Implementations define their own `Error` type, which must be convertible from `ChangeError` for change loading operations. # Thread Safety Implementations should be safe for concurrent
| 87 | /// Implementations should be safe for concurrent read access. The trait |
| 88 | /// methods take `&self`, enabling shared references across threads. |
| 89 | pub trait ChangeStore: Send + Sync { |
| 90 | /// Error type for change store operations. |
| 91 | type Error: std::error::Error + Send + Sync + 'static; |
| 92 | |
| 93 | /// Load a complete change by its hash. |
| 94 | /// |
| 95 | /// # Arguments |
| 96 | /// |
| 97 | /// * `hash` - The content hash of the change |
| 98 | /// |
| 99 | /// # Returns |
| 100 | /// |
| 101 | /// The complete [`Change`] if found. |
| 102 | /// |
| 103 | /// # Errors |
| 104 | /// |
| 105 | /// Returns an error if the change is not found or cannot be loaded. |
| 106 | fn get_change(&self, hash: &Hash) -> Result<Change, Self::Error>; |
| 107 | |
| 108 | /// Load an immutable identity-bound value. Custom stores keep conservative |
| 109 | /// canonical hash verification unless they provide a checked encoded reader. |
| 110 | fn get_verified_change( |
| 111 | &self, |
| 112 | hash: &Hash, |
| 113 | ) -> Result<super::VerifiedChange, super::VerifiedLoadError<Self::Error>> { |
| 114 | let change = self |
| 115 | .get_change(hash) |
| 116 | .map_err(super::VerifiedLoadError::Store)?; |
| 117 | let verified = super::VerifiedChange::from_change(change)?; |
| 118 | verified.check_hash(hash)?; |
| 119 | Ok(verified) |
| 120 | } |
| 121 | |
| 122 | /// Revalidate a cache hit against current backing data. The default reloads |
| 123 | /// and verifies; stores must not trust a pathname, mtime or a prior receipt. |
| 124 | fn revalidate_verified_change( |
| 125 | &self, |
| 126 | hash: &Hash, |
| 127 | _cached: &super::VerifiedChange, |
| 128 | ) -> Result<super::VerifiedChange, super::VerifiedLoadError<Self::Error>> { |
| 129 | self.get_verified_change(hash) |
| 130 | } |
| 131 | |
| 132 | /// Check if a change exists. |
| 133 | /// |
| 134 | /// # Arguments |
| 135 | /// |
| 136 | /// * `hash` - The content hash of the change |
| 137 | /// |
| 138 | /// # Returns |
| 139 | /// |
| 140 | /// `true` if the change exists in the store. |
| 141 | fn has_change(&self, hash: &Hash) -> bool { |
| 142 | self.get_change(hash).is_ok() |
| 143 | } |
| 144 | |
| 145 | /// Check if a change has content bytes. |
| 146 | /// |
no outgoing calls
no test coverage detected