1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::io;
use git_object::Object;
pub trait Write {
type Error: std::error::Error + From<io::Error>;
fn write(&self, object: &Object, hash: git_hash::Kind) -> Result<git_hash::ObjectId, Self::Error> {
let mut buf = Vec::with_capacity(2048);
object.write_to(&mut buf)?;
self.write_stream(object.kind(), buf.len() as u64, buf.as_slice(), hash)
}
fn write_buf(
&self,
object: git_object::Kind,
from: &[u8],
hash: git_hash::Kind,
) -> Result<git_hash::ObjectId, Self::Error> {
self.write_stream(object, from.len() as u64, from, hash)
}
fn write_stream(
&self,
kind: git_object::Kind,
size: u64,
from: impl io::Read,
hash: git_hash::Kind,
) -> Result<git_hash::ObjectId, Self::Error>;
}