d_engine_proto/exts/
storage_ext.rs1use std::error::Error;
2
3use bytes::Bytes;
4
5use crate::server::storage::SnapshotMetadata;
6
7impl SnapshotMetadata {
8 pub fn checksum_array(&self) -> Result<[u8; 32], Box<dyn Error>> {
9 if self.checksum.len() == 32 {
10 let mut array = [0u8; 32];
11 array.copy_from_slice(&self.checksum);
12 Ok(array)
13 } else {
14 Err(format!("Invalid checksum length: {}", self.checksum.len()).into())
15 }
16 }
17
18 pub fn set_checksum_array(
19 &mut self,
20 array: [u8; 32],
21 ) {
22 self.checksum = Bytes::copy_from_slice(&array);
23 }
24}