Load and serialize change data from the repository. Loads the change from the repository and serializes it to bytes suitable for uploading to a remote. # Arguments `repo` - The repository to load from `hash` - The hash of the change to load # Returns The serialized change data as bytes. # Errors Returns `CliError::ChangeNotFound` if the change doesn't exist, or `CliError::Internal` if seria
(repo: &Repository, hash: &Hash)
| 158 | /// Returns `CliError::ChangeNotFound` if the change doesn't exist, |
| 159 | /// or `CliError::Internal` if serialization fails. |
| 160 | pub fn load_change_data(repo: &Repository, hash: &Hash) -> CliResult<Bytes> { |
| 161 | // Load the change |
| 162 | let change = repo |
| 163 | .load_change(hash) |
| 164 | .map_err(|_| CliError::ChangeNotFound { |
| 165 | hash: hash.to_base32(), |
| 166 | })?; |
| 167 | |
| 168 | // Serialize to bytes |
| 169 | let mut buffer = Vec::new(); |
| 170 | change |
| 171 | .serialize(&mut buffer) |
| 172 | .map_err(|e| CliError::Internal(anyhow::anyhow!("Failed to serialize change: {}", e)))?; |
| 173 | |
| 174 | Ok(Bytes::from(buffer)) |
| 175 | } |
| 176 | |
| 177 | // ============================================================================= |
| 178 | // Error Conversion |
nothing calls this directly
no test coverage detected