Implement Repo::write_content

This commit is contained in:
Felix Krull authored and Colin Walters committed 2022-05-06 12:53:54 -04:00
1 parent 17a9d7c855
commit 78a14d15a3
3 files changed
+74 -2

No files matched your search

+28 -1
View File
@@ -1,6 +1,6 @@
use crate::Repo;
#[cfg(any(feature = "v2016_4", feature = "dox"))]
use crate::RepoListRefsExtFlags;
use crate::{Checksum, Repo};
use gio;
use glib;
use glib::translate::*;
@@ -115,4 +115,31 @@ impl Repo {
}
}
}
pub fn write_content<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
&self,
expected_checksum: Option<&str>,
object_input: &P,
length: u64,
cancellable: Option<&Q>,
) -> Result<Checksum, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut out_csum = ptr::null_mut();
let _ = ostree_sys::fixed::ostree_repo_write_content(
self.to_glib_none().0,
expected_checksum.to_glib_none().0,
object_input.as_ref().to_glib_none().0,
length,
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
}
}
}
}