Implement ostree::checksum_file

This commit is contained in:
Felix Krull authored and Colin Walters committed 2022-05-06 12:53:54 -04:00
1 parent 4cd981d01b
commit 7f3bd56d0d
6 files changed
+60 -1

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
use crate::{Checksum, ObjectType};
use glib::prelude::*;
use glib::translate::*;
use glib_sys::GFALSE;
use std::error::Error;
use std::ptr;
pub fn checksum_file<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(
f: &P,
objtype: ObjectType,
cancellable: Option<&Q>,
) -> Result<Checksum, Box<dyn Error>> {
unsafe {
let mut out_csum = ptr::null_mut();
let mut error = ptr::null_mut();
let ret = ostree_sys::ostree_checksum_file(
f.as_ref().to_glib_none().0,
objtype.to_glib(),
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if !error.is_null() {
Err(Box::<glib::Error>::new(from_glib_full(error)))
} else if ret == GFALSE {
Err(Box::new(glib_bool_error!(
"unknown error in ostree_checksum_file"
)))
} else {
Ok(Checksum::from_glib_full(out_csum))
}
}
}
+2
View File
@@ -37,6 +37,7 @@ pub use crate::auto::*;
mod checksum;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
mod collection_ref;
mod functions;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
mod kernel_args;
mod object_name;
@@ -47,6 +48,7 @@ mod se_policy;
pub use crate::checksum::*;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
pub use crate::collection_ref::*;
pub use crate::functions::*;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub use crate::kernel_args::*;
pub use crate::object_name::*;
+1 -1
View File
@@ -1,4 +1,4 @@
use functions::{object_name_deserialize, object_name_serialize, object_to_string};
use crate::{object_name_deserialize, object_name_serialize, object_to_string};
use glib;
use glib::translate::*;
use glib::GString;
+1
View File
@@ -11,6 +11,7 @@ use glib::Error;
use glib::IsA;
use glib_sys;
use ostree_sys;
#[cfg(feature = "futures")]
use std::boxed::Box as Box_;
use std::collections::{HashMap, HashSet};
use std::path::Path;