gix_index/extension/end_of_index_entry/
write.rs1use crate::extension::{end_of_index_entry::SIGNATURE, Signature};
2
3pub fn write_to(
10 mut out: impl std::io::Write,
11 hash_kind: gix_hash::Kind,
12 offset_to_extensions: u32,
13 prior_extensions: impl IntoIterator<Item = (Signature, u32)>,
14) -> Result<(), std::io::Error> {
15 out.write_all(&SIGNATURE)?;
16 let extension_size: u32 = 4 + hash_kind.len_in_bytes() as u32;
17 out.write_all(&extension_size.to_be_bytes())?;
18
19 out.write_all(&offset_to_extensions.to_be_bytes())?;
20
21 let mut hasher = gix_features::hash::hasher(hash_kind);
22 for (signature, size) in prior_extensions {
23 hasher.update(&signature);
24 hasher.update(&size.to_be_bytes());
25 }
26 out.write_all(&hasher.digest())?;
27
28 Ok(())
29}