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
38
39
40
41
42
43
44
45
46
47
48
49
use std::marker;
use crate::util::Binding;
use crate::{raw, Buf, Error, Odb, Repository};
pub struct Mempack<'odb> {
raw: *mut raw::git_odb_backend,
_marker: marker::PhantomData<&'odb Odb<'odb>>,
}
impl<'odb> Binding for Mempack<'odb> {
type Raw = *mut raw::git_odb_backend;
unsafe fn from_raw(raw: *mut raw::git_odb_backend) -> Mempack<'odb> {
Mempack {
raw: raw,
_marker: marker::PhantomData,
}
}
fn raw(&self) -> *mut raw::git_odb_backend {
self.raw
}
}
impl<'odb> Mempack<'odb> {
pub fn dump(&self, repo: &Repository, buf: &mut Buf) -> Result<(), Error> {
unsafe {
try_call!(raw::git_mempack_dump(buf.raw(), repo.raw(), self.raw));
}
Ok(())
}
pub fn reset(&self) -> Result<(), Error> {
unsafe {
try_call!(raw::git_mempack_reset(self.raw));
}
Ok(())
}
}