Merge pull request #2660 from cgwalters/fix-load-file-api
repo: Metadata return values from `load_file` are not nullable
This commit is contained in:
commit
bba9724317
|
|
@ -168,6 +168,11 @@ concurrency = "send"
|
||||||
name = "destination_path"
|
name = "destination_path"
|
||||||
string_type = "filename"
|
string_type = "filename"
|
||||||
|
|
||||||
|
# Cases where we use nullable output parameters that shouldn't be `Option<T>`
|
||||||
|
[[object.function]]
|
||||||
|
pattern = "^(load_file)$"
|
||||||
|
ignore = true
|
||||||
|
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "OSTree.RepoFinder"
|
name = "OSTree.RepoFinder"
|
||||||
status = "generate"
|
status = "generate"
|
||||||
|
|
|
||||||
|
|
@ -486,18 +486,6 @@ impl Repo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "ostree_repo_load_file")]
|
|
||||||
pub fn load_file<P: IsA<gio::Cancellable>>(&self, checksum: &str, cancellable: Option<&P>) -> Result<(Option<gio::InputStream>, Option<gio::FileInfo>, Option<glib::Variant>), glib::Error> {
|
|
||||||
unsafe {
|
|
||||||
let mut out_input = ptr::null_mut();
|
|
||||||
let mut out_file_info = ptr::null_mut();
|
|
||||||
let mut out_xattrs = ptr::null_mut();
|
|
||||||
let mut error = ptr::null_mut();
|
|
||||||
let _ = ffi::ostree_repo_load_file(self.to_glib_none().0, checksum.to_glib_none().0, &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
|
|
||||||
if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(alias = "ostree_repo_load_object_stream")]
|
#[doc(alias = "ostree_repo_load_object_stream")]
|
||||||
pub fn load_object_stream<P: IsA<gio::Cancellable>>(&self, objtype: ObjectType, checksum: &str, cancellable: Option<&P>) -> Result<(gio::InputStream, u64), glib::Error> {
|
pub fn load_object_stream<P: IsA<gio::Cancellable>>(&self, objtype: ObjectType, checksum: &str, cancellable: Option<&P>) -> Result<(gio::InputStream, u64), glib::Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
Generated by gir (https://github.com/gtk-rs/gir @ e8f82cf6)
|
Generated by gir (https://github.com/gtk-rs/gir @ e8f82cf6)
|
||||||
from gir-files (@ 21901c2d)
|
from gir-files (@ ee5b3c76)
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,39 @@ impl Repo {
|
||||||
Ok(self.resolve_rev(refspec, false)?.unwrap())
|
Ok(self.resolve_rev(refspec, false)?.unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Load the contents (for regular files) and metadata for a content object.
|
||||||
|
#[doc(alias = "ostree_repo_load_file")]
|
||||||
|
pub fn load_file<P: IsA<gio::Cancellable>>(
|
||||||
|
&self,
|
||||||
|
checksum: &str,
|
||||||
|
cancellable: Option<&P>,
|
||||||
|
) -> Result<(Option<gio::InputStream>, gio::FileInfo, glib::Variant), glib::Error> {
|
||||||
|
unsafe {
|
||||||
|
let mut out_input = ptr::null_mut();
|
||||||
|
let mut out_file_info = ptr::null_mut();
|
||||||
|
let mut out_xattrs = ptr::null_mut();
|
||||||
|
let mut error = ptr::null_mut();
|
||||||
|
let _ = ffi::ostree_repo_load_file(
|
||||||
|
self.to_glib_none().0,
|
||||||
|
checksum.to_glib_none().0,
|
||||||
|
&mut out_input,
|
||||||
|
&mut out_file_info,
|
||||||
|
&mut out_xattrs,
|
||||||
|
cancellable.map(|p| p.as_ref()).to_glib_none().0,
|
||||||
|
&mut error,
|
||||||
|
);
|
||||||
|
if error.is_null() {
|
||||||
|
Ok((
|
||||||
|
from_glib_full(out_input),
|
||||||
|
from_glib_full(out_file_info),
|
||||||
|
from_glib_full(out_xattrs),
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
Err(from_glib_full(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Query metadata for a content object.
|
/// Query metadata for a content object.
|
||||||
///
|
///
|
||||||
/// This is similar to [`load_file`], but is more efficient if reading the file content is not needed.
|
/// This is similar to [`load_file`], but is more efficient if reading the file content is not needed.
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ fn should_checksum_file_from_input() {
|
||||||
.load_file(obj.checksum(), NONE_CANCELLABLE)
|
.load_file(obj.checksum(), NONE_CANCELLABLE)
|
||||||
.expect("load file");
|
.expect("load file");
|
||||||
let result = checksum_file_from_input(
|
let result = checksum_file_from_input(
|
||||||
file_info.as_ref().unwrap(),
|
&file_info,
|
||||||
xattrs.as_ref(),
|
Some(&xattrs),
|
||||||
stream.as_ref(),
|
stream.as_ref(),
|
||||||
ObjectType::File,
|
ObjectType::File,
|
||||||
NONE_CANCELLABLE,
|
NONE_CANCELLABLE,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue