Merge pull request #2791 from cgwalters/enable-trust-return-nullability

This commit is contained in:
Jonathan Lebon 2023-03-17 09:37:40 -04:00 committed by GitHub
commit 7e93837e67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 157 additions and 104 deletions

View File

@ -9,7 +9,7 @@ name = "ostree"
readme = "rust-bindings/README.md"
repository = "https://github.com/ostreedev/ostree"
rust-version = "1.63.0"
version = "0.17.1"
version = "0.18.0"
exclude = [
"/*.am", "/apidoc", "/autogen.sh", "/bash", "/bsdiff",
@ -42,7 +42,7 @@ base64 = "0.20.0"
bitflags = "1.2.1"
cap-std = { version = "1.0", optional = true}
io-lifetimes = { version = "1.0", optional = true}
ffi = { package = "ostree-sys", path = "rust-bindings/sys", version = "0.12.0" }
ffi = { package = "ostree-sys", path = "rust-bindings/sys", version = "0.13.0" }
gio = "0.16"
glib = "0.16"
hex = "0.4.2"

View File

@ -11,6 +11,7 @@ target_path = ".."
doc_target_path = "../target/vendor.md"
deprecate_by_min_version = true
single_version_file = true
trust_return_value_nullability = true
generate_display_trait = true
girs_directories = [ "../gir-files" ]

View File

@ -26,7 +26,7 @@ impl BootconfigParser {
#[doc(alias = "ostree_bootconfig_parser_clone")]
#[must_use]
pub fn clone(&self) -> Option<BootconfigParser> {
pub fn clone(&self) -> BootconfigParser {
unsafe {
from_glib_full(ffi::ostree_bootconfig_parser_clone(self.to_glib_none().0))
}

View File

@ -18,7 +18,7 @@ glib::wrapper! {
impl CollectionRef {
#[doc(alias = "ostree_collection_ref_new")]
pub fn new(collection_id: Option<&str>, ref_name: &str) -> Option<CollectionRef> {
pub fn new(collection_id: Option<&str>, ref_name: &str) -> CollectionRef {
unsafe {
from_glib_full(ffi::ostree_collection_ref_new(collection_id.to_glib_none().0, ref_name.to_glib_none().0))
}

View File

@ -28,7 +28,7 @@ impl Deployment {
#[doc(alias = "ostree_deployment_clone")]
#[must_use]
pub fn clone(&self) -> Option<Deployment> {
pub fn clone(&self) -> Deployment {
unsafe {
from_glib_full(ffi::ostree_deployment_clone(self.to_glib_none().0))
}
@ -51,7 +51,7 @@ impl Deployment {
#[doc(alias = "ostree_deployment_get_bootcsum")]
#[doc(alias = "get_bootcsum")]
pub fn bootcsum(&self) -> Option<glib::GString> {
pub fn bootcsum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_deployment_get_bootcsum(self.to_glib_none().0))
}
@ -67,7 +67,7 @@ impl Deployment {
#[doc(alias = "ostree_deployment_get_csum")]
#[doc(alias = "get_csum")]
pub fn csum(&self) -> Option<glib::GString> {
pub fn csum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_deployment_get_csum(self.to_glib_none().0))
}
@ -99,7 +99,7 @@ impl Deployment {
#[doc(alias = "ostree_deployment_get_origin_relpath")]
#[doc(alias = "get_origin_relpath")]
pub fn origin_relpath(&self) -> Option<glib::GString> {
pub fn origin_relpath(&self) -> glib::GString {
unsafe {
from_glib_full(ffi::ostree_deployment_get_origin_relpath(self.to_glib_none().0))
}
@ -107,7 +107,7 @@ impl Deployment {
#[doc(alias = "ostree_deployment_get_osname")]
#[doc(alias = "get_osname")]
pub fn osname(&self) -> Option<glib::GString> {
pub fn osname(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_deployment_get_osname(self.to_glib_none().0))
}
@ -188,7 +188,7 @@ impl Deployment {
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_deployment_unlocked_state_to_string")]
pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> Option<glib::GString> {
pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_deployment_unlocked_state_to_string(state.into_glib()))
}

View File

@ -46,14 +46,14 @@ pub fn check_version(required_year: u32, required_release: u32) -> bool {
//}
#[doc(alias = "ostree_checksum_from_bytes_v")]
pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> Option<glib::GString> {
pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> glib::GString {
unsafe {
from_glib_full(ffi::ostree_checksum_from_bytes_v(csum_v.to_glib_none().0))
}
}
#[doc(alias = "ostree_checksum_to_bytes_v")]
pub fn checksum_to_bytes_v(checksum: &str) -> Option<glib::Variant> {
pub fn checksum_to_bytes_v(checksum: &str) -> glib::Variant {
unsafe {
from_glib_full(ffi::ostree_checksum_to_bytes_v(checksum.to_glib_none().0))
}
@ -82,7 +82,7 @@ pub fn commit_get_object_sizes(commit_variant: &glib::Variant) -> Result<Vec<Com
}
#[doc(alias = "ostree_commit_get_parent")]
pub fn commit_get_parent(commit_variant: &glib::Variant) -> Option<glib::GString> {
pub fn commit_get_parent(commit_variant: &glib::Variant) -> glib::GString {
unsafe {
from_glib_full(ffi::ostree_commit_get_parent(commit_variant.to_glib_none().0))
}
@ -144,7 +144,7 @@ pub fn content_stream_parse(compressed: bool, input: &impl IsA<gio::InputStream>
}
#[doc(alias = "ostree_create_directory_metadata")]
pub fn create_directory_metadata(dir_info: &gio::FileInfo, xattrs: Option<&glib::Variant>) -> Option<glib::Variant> {
pub fn create_directory_metadata(dir_info: &gio::FileInfo, xattrs: Option<&glib::Variant>) -> glib::Variant {
unsafe {
from_glib_full(ffi::ostree_create_directory_metadata(dir_info.to_glib_none().0, xattrs.to_glib_none().0))
}
@ -202,7 +202,7 @@ pub fn gpg_error_quark() -> glib::Quark {
}
#[doc(alias = "ostree_metadata_variant_type")]
pub fn metadata_variant_type(objtype: ObjectType) -> Option<glib::VariantType> {
pub fn metadata_variant_type(objtype: ObjectType) -> glib::VariantType {
unsafe {
from_glib_none(ffi::ostree_metadata_variant_type(objtype.into_glib()))
}
@ -229,14 +229,14 @@ pub fn object_name_deserialize(variant: &glib::Variant) -> (glib::GString, Objec
}
#[doc(alias = "ostree_object_name_serialize")]
pub fn object_name_serialize(checksum: &str, objtype: ObjectType) -> Option<glib::Variant> {
pub fn object_name_serialize(checksum: &str, objtype: ObjectType) -> glib::Variant {
unsafe {
from_glib_none(ffi::ostree_object_name_serialize(checksum.to_glib_none().0, objtype.into_glib()))
}
}
#[doc(alias = "ostree_object_to_string")]
pub fn object_to_string(checksum: &str, objtype: ObjectType) -> Option<glib::GString> {
pub fn object_to_string(checksum: &str, objtype: ObjectType) -> glib::GString {
unsafe {
from_glib_full(ffi::ostree_object_to_string(checksum.to_glib_none().0, objtype.into_glib()))
}
@ -250,7 +250,7 @@ pub fn object_type_from_string(str: &str) -> ObjectType {
}
#[doc(alias = "ostree_object_type_to_string")]
pub fn object_type_to_string(objtype: ObjectType) -> Option<glib::GString> {
pub fn object_type_to_string(objtype: ObjectType) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_object_type_to_string(objtype.into_glib()))
}

View File

@ -34,13 +34,13 @@ impl GpgVerifyResult {
}
//#[doc(alias = "ostree_gpg_verify_result_get")]
//pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 29 }) -> Option<glib::Variant> {
//pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 29 }) -> glib::Variant {
// unsafe { TODO: call ffi:ostree_gpg_verify_result_get() }
//}
#[doc(alias = "ostree_gpg_verify_result_get_all")]
#[doc(alias = "get_all")]
pub fn all(&self, signature_index: u32) -> Option<glib::Variant> {
pub fn all(&self, signature_index: u32) -> glib::Variant {
unsafe {
from_glib_none(ffi::ostree_gpg_verify_result_get_all(self.to_glib_none().0, signature_index))
}

View File

@ -93,7 +93,7 @@ impl MutableTree {
#[doc(alias = "ostree_mutable_tree_get_contents_checksum")]
#[doc(alias = "get_contents_checksum")]
pub fn contents_checksum(&self) -> Option<glib::GString> {
pub fn contents_checksum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_mutable_tree_get_contents_checksum(self.to_glib_none().0))
}
@ -107,7 +107,7 @@ impl MutableTree {
#[doc(alias = "ostree_mutable_tree_get_metadata_checksum")]
#[doc(alias = "get_metadata_checksum")]
pub fn metadata_checksum(&self) -> Option<glib::GString> {
pub fn metadata_checksum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_mutable_tree_get_metadata_checksum(self.to_glib_none().0))
}

View File

@ -3,6 +3,7 @@
// DO NOT EDIT
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
@ -18,7 +19,7 @@ glib::wrapper! {
impl Remote {
#[doc(alias = "ostree_remote_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
pub fn name(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_remote_get_name(self.to_glib_none().0))
}
@ -26,9 +27,16 @@ impl Remote {
#[doc(alias = "ostree_remote_get_url")]
#[doc(alias = "get_url")]
pub fn url(&self) -> Option<glib::GString> {
pub fn url(&self) -> glib::GString {
unsafe {
from_glib_full(ffi::ostree_remote_get_url(self.to_glib_none().0))
}
}
}
impl fmt::Display for Remote {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&self.name())
}
}

View File

@ -161,7 +161,7 @@ impl Repo {
}
#[doc(alias = "ostree_repo_copy_config")]
pub fn copy_config(&self) -> Option<glib::KeyFile> {
pub fn copy_config(&self) -> glib::KeyFile {
unsafe {
from_glib_full(ffi::ostree_repo_copy_config(self.to_glib_none().0))
}
@ -217,7 +217,7 @@ impl Repo {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2019_2")))]
#[doc(alias = "ostree_repo_get_bootloader")]
#[doc(alias = "get_bootloader")]
pub fn bootloader(&self) -> Option<glib::GString> {
pub fn bootloader(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_repo_get_bootloader(self.to_glib_none().0))
}
@ -235,7 +235,7 @@ impl Repo {
#[doc(alias = "ostree_repo_get_config")]
#[doc(alias = "get_config")]
pub fn config(&self) -> Option<glib::KeyFile> {
pub fn config(&self) -> glib::KeyFile {
unsafe {
from_glib_none(ffi::ostree_repo_get_config(self.to_glib_none().0))
}
@ -302,7 +302,7 @@ impl Repo {
#[doc(alias = "ostree_repo_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> Option<gio::File> {
pub fn path(&self) -> gio::File {
unsafe {
from_glib_none(ffi::ostree_repo_get_path(self.to_glib_none().0))
}
@ -340,7 +340,7 @@ impl Repo {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_5")))]
#[doc(alias = "ostree_repo_get_remote_option")]
#[doc(alias = "get_remote_option")]
pub fn remote_option(&self, remote_name: &str, option_name: &str, default_value: Option<&str>) -> Result<glib::GString, glib::Error> {
pub fn remote_option(&self, remote_name: &str, option_name: &str, default_value: Option<&str>) -> Result<Option<glib::GString>, glib::Error> {
unsafe {
let mut out_value = ptr::null_mut();
let mut error = ptr::null_mut();
@ -353,7 +353,7 @@ impl Repo {
#[cfg(any(feature = "v2020_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_8")))]
#[doc(alias = "ostree_repo_gpg_sign_data")]
pub fn gpg_sign_data(&self, data: &glib::Bytes, old_signatures: &glib::Bytes, key_id: &[&str], homedir: Option<&str>, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<glib::Bytes, glib::Error> {
pub fn gpg_sign_data(&self, data: &glib::Bytes, old_signatures: Option<&glib::Bytes>, key_id: &[&str], homedir: Option<&str>, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<glib::Bytes, glib::Error> {
unsafe {
let mut out_signatures = ptr::null_mut();
let mut error = ptr::null_mut();
@ -1001,7 +1001,7 @@ impl Repo {
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
#[doc(alias = "ostree_repo_signature_verify_commit_data")]
pub fn signature_verify_commit_data(&self, remote_name: &str, commit_data: &glib::Bytes, commit_metadata: &glib::Bytes, flags: RepoVerifyFlags) -> Result<Option<glib::GString>, glib::Error> {
pub fn signature_verify_commit_data(&self, remote_name: &str, commit_data: &glib::Bytes, commit_metadata: &glib::Bytes, flags: RepoVerifyFlags) -> Result<glib::GString, glib::Error> {
unsafe {
let mut out_results = ptr::null_mut();
let mut error = ptr::null_mut();

View File

@ -31,7 +31,7 @@ impl RepoFile {
#[doc(alias = "ostree_repo_file_get_checksum")]
#[doc(alias = "get_checksum")]
pub fn checksum(&self) -> Option<glib::GString> {
pub fn checksum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_checksum(self.to_glib_none().0))
}
@ -39,7 +39,7 @@ impl RepoFile {
#[doc(alias = "ostree_repo_file_get_repo")]
#[doc(alias = "get_repo")]
pub fn repo(&self) -> Option<Repo> {
pub fn repo(&self) -> Repo {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_repo(self.to_glib_none().0))
}
@ -48,7 +48,7 @@ impl RepoFile {
#[doc(alias = "ostree_repo_file_get_root")]
#[doc(alias = "get_root")]
#[must_use]
pub fn root(&self) -> Option<RepoFile> {
pub fn root(&self) -> RepoFile {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_root(self.to_glib_none().0))
}
@ -77,28 +77,28 @@ impl RepoFile {
}
#[doc(alias = "ostree_repo_file_tree_get_contents")]
pub fn tree_get_contents(&self) -> Option<glib::Variant> {
pub fn tree_get_contents(&self) -> glib::Variant {
unsafe {
from_glib_full(ffi::ostree_repo_file_tree_get_contents(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_contents_checksum")]
pub fn tree_get_contents_checksum(&self) -> Option<glib::GString> {
pub fn tree_get_contents_checksum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_repo_file_tree_get_contents_checksum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_metadata")]
pub fn tree_get_metadata(&self) -> Option<glib::Variant> {
pub fn tree_get_metadata(&self) -> glib::Variant {
unsafe {
from_glib_full(ffi::ostree_repo_file_tree_get_metadata(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_metadata_checksum")]
pub fn tree_get_metadata_checksum(&self) -> Option<glib::GString> {
pub fn tree_get_metadata_checksum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_repo_file_tree_get_metadata_checksum(self.to_glib_none().0))
}

View File

@ -55,7 +55,7 @@ impl SePolicy {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_5")))]
#[doc(alias = "ostree_sepolicy_get_csum")]
#[doc(alias = "get_csum")]
pub fn csum(&self) -> Option<glib::GString> {
pub fn csum(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_csum(self.to_glib_none().0))
}
@ -63,7 +63,7 @@ impl SePolicy {
#[doc(alias = "ostree_sepolicy_get_label")]
#[doc(alias = "get_label")]
pub fn label(&self, relpath: &str, unix_mode: u32, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<glib::GString, glib::Error> {
pub fn label(&self, relpath: &str, unix_mode: u32, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<Option<glib::GString>, glib::Error> {
unsafe {
let mut out_label = ptr::null_mut();
let mut error = ptr::null_mut();
@ -75,7 +75,7 @@ impl SePolicy {
#[doc(alias = "ostree_sepolicy_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
pub fn name(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_name(self.to_glib_none().0))
}
@ -83,14 +83,14 @@ impl SePolicy {
#[doc(alias = "ostree_sepolicy_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> Option<gio::File> {
pub fn path(&self) -> gio::File {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_path(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sepolicy_restorecon")]
pub fn restorecon(&self, path: &str, info: Option<&gio::FileInfo>, target: &impl IsA<gio::File>, flags: SePolicyRestoreconFlags, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<glib::GString, glib::Error> {
pub fn restorecon(&self, path: &str, info: Option<&gio::FileInfo>, target: &impl IsA<gio::File>, flags: SePolicyRestoreconFlags, cancellable: Option<&impl IsA<gio::Cancellable>>) -> Result<Option<glib::GString>, glib::Error> {
unsafe {
let mut out_new_label = ptr::null_mut();
let mut error = ptr::null_mut();
@ -116,10 +116,11 @@ impl SePolicy {
}
}
unsafe impl Send for SePolicy {}
impl fmt::Display for SePolicy {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("SePolicy")
f.write_str(&self.name())
}
}
unsafe impl Send for SePolicy {}

View File

@ -85,7 +85,7 @@ pub trait SignExt: 'static {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
#[doc(alias = "ostree_sign_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> Option<glib::GString>;
fn name(&self) -> glib::GString;
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
@ -95,12 +95,12 @@ pub trait SignExt: 'static {
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
#[doc(alias = "ostree_sign_metadata_format")]
fn metadata_format(&self) -> Option<glib::GString>;
fn metadata_format(&self) -> glib::GString;
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
#[doc(alias = "ostree_sign_metadata_key")]
fn metadata_key(&self) -> Option<glib::GString>;
fn metadata_key(&self) -> glib::GString;
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
@ -190,7 +190,7 @@ impl<O: IsA<Sign>> SignExt for O {
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
fn name(&self) -> Option<glib::GString> {
fn name(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_sign_get_name(self.as_ref().to_glib_none().0))
}
@ -209,7 +209,7 @@ impl<O: IsA<Sign>> SignExt for O {
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
fn metadata_format(&self) -> Option<glib::GString> {
fn metadata_format(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_sign_metadata_format(self.as_ref().to_glib_none().0))
}
@ -217,7 +217,7 @@ impl<O: IsA<Sign>> SignExt for O {
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
fn metadata_key(&self) -> Option<glib::GString> {
fn metadata_key(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::ostree_sign_metadata_key(self.as_ref().to_glib_none().0))
}

View File

@ -185,7 +185,7 @@ impl Sysroot {
#[doc(alias = "ostree_sysroot_get_deployment_directory")]
#[doc(alias = "get_deployment_directory")]
pub fn deployment_directory(&self, deployment: &Deployment) -> Option<gio::File> {
pub fn deployment_directory(&self, deployment: &Deployment) -> gio::File {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_directory(self.to_glib_none().0, deployment.to_glib_none().0))
}
@ -193,7 +193,7 @@ impl Sysroot {
#[doc(alias = "ostree_sysroot_get_deployment_dirpath")]
#[doc(alias = "get_deployment_dirpath")]
pub fn deployment_dirpath(&self, deployment: &Deployment) -> Option<glib::GString> {
pub fn deployment_dirpath(&self, deployment: &Deployment) -> glib::GString {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_dirpath(self.to_glib_none().0, deployment.to_glib_none().0))
}
@ -225,7 +225,7 @@ impl Sysroot {
#[doc(alias = "ostree_sysroot_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> Option<gio::File> {
pub fn path(&self) -> gio::File {
unsafe {
from_glib_none(ffi::ostree_sysroot_get_path(self.to_glib_none().0))
}
@ -369,7 +369,7 @@ impl Sysroot {
}
#[doc(alias = "ostree_sysroot_origin_new_from_refspec")]
pub fn origin_new_from_refspec(&self, refspec: &str) -> Option<glib::KeyFile> {
pub fn origin_new_from_refspec(&self, refspec: &str) -> glib::KeyFile {
unsafe {
from_glib_full(ffi::ostree_sysroot_origin_new_from_refspec(self.to_glib_none().0, refspec.to_glib_none().0))
}
@ -400,7 +400,7 @@ impl Sysroot {
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "ostree_sysroot_repo")]
pub fn repo(&self) -> Option<Repo> {
pub fn repo(&self) -> Repo {
unsafe {
from_glib_none(ffi::ostree_sysroot_repo(self.to_glib_none().0))
}
@ -534,7 +534,7 @@ impl Sysroot {
#[doc(alias = "ostree_sysroot_get_deployment_origin_path")]
#[doc(alias = "get_deployment_origin_path")]
pub fn deployment_origin_path(deployment_path: &impl IsA<gio::File>) -> Option<gio::File> {
pub fn deployment_origin_path(deployment_path: &impl IsA<gio::File>) -> gio::File {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_origin_path(deployment_path.as_ref().to_glib_none().0))
}

View File

@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 0eeebbdf9d4d)
from gir-files (@ be0dbf02d770)
from gir-files (@ 1b758c141dda)

View File

@ -54,7 +54,7 @@ mod tests {
#[test]
fn should_get_collection_id() {
let collection_ref = CollectionRef::new(Some("collection.id"), "ref").unwrap();
let collection_ref = CollectionRef::new(Some("collection.id"), "ref");
let id = collection_ref.collection_id().unwrap().to_str().unwrap();
assert_eq!(id, "collection.id");
@ -62,7 +62,7 @@ mod tests {
#[test]
fn should_get_none_collection_id() {
let collection_ref = CollectionRef::new(None, "ref").unwrap();
let collection_ref = CollectionRef::new(None, "ref");
let id = collection_ref.collection_id();
assert_eq!(id, None);
@ -70,7 +70,7 @@ mod tests {
#[test]
fn should_get_ref_name() {
let collection_ref = CollectionRef::new(Some("collection.id"), "ref-name").unwrap();
let collection_ref = CollectionRef::new(Some("collection.id"), "ref-name");
let ref_name = collection_ref.ref_name().to_str().unwrap();
assert_eq!(ref_name, "ref-name");

View File

@ -34,8 +34,7 @@ impl ObjectName {
/// Create a new `ObjectName` with the given checksum and `ObjectType`.
pub fn new<S: Into<GString>>(checksum: S, object_type: ObjectType) -> ObjectName {
let checksum = checksum.into();
let variant = object_name_serialize(checksum.as_str(), object_type)
.expect("type checks should make this safe");
let variant = object_name_serialize(checksum.as_str(), object_type);
ObjectName {
variant,
checksum,
@ -56,7 +55,6 @@ impl ObjectName {
/// Format this `ObjectName` as a string.
fn to_string(&self) -> GString {
object_to_string(self.checksum(), self.object_type())
.expect("type checks should make this safe")
}
}

View File

@ -85,7 +85,7 @@ mod tests {
assert_eq!(sysroot.subbootversion(), 0);
sysroot.cleanup(gio::Cancellable::NONE).unwrap();
sysroot.path().unwrap()
sysroot.path()
};
let path_loaded = {
let tmp_path = Some(tmpdir.path().to_path_buf());
@ -100,7 +100,7 @@ mod tests {
assert_eq!(sysroot.subbootversion(), 0);
sysroot.cleanup(gio::Cancellable::NONE).unwrap();
sysroot.path().unwrap()
sysroot.path()
};
assert_eq!(path_created.to_string(), path_loaded.to_string());
}

View File

@ -12,68 +12,62 @@ fn hash(v: &impl Hash) -> u64 {
#[test]
fn same_value_should_be_equal() {
let r = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let r = CollectionRef::new(Some("io.gitlab.fkrull"), "ref");
assert_eq!(r, r);
}
#[test]
fn equal_values_should_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref");
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref");
assert_eq!(a, b);
}
#[test]
fn equal_values_without_collection_id_should_be_equal() {
let a = CollectionRef::new(None, "ref-name").unwrap();
let b = CollectionRef::new(None, "ref-name").unwrap();
let a = CollectionRef::new(None, "ref-name");
let b = CollectionRef::new(None, "ref-name");
assert_eq!(a, b);
}
#[test]
fn different_values_should_not_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2").unwrap();
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1");
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2");
assert_ne!(a, b);
}
#[test]
fn new_with_invalid_collection_id_should_return_none() {
let r = CollectionRef::new(Some(".abc"), "ref");
assert_eq!(r, None);
}
#[test]
fn hash_for_equal_values_should_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref");
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref");
assert_eq!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_collection_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref").unwrap();
let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref");
let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref");
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_ref_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2").unwrap();
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1");
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2");
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_should_be_different_if_collection_id_is_absent() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(None, "ref").unwrap();
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref");
let b = CollectionRef::new(None, "ref");
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn clone_should_be_equal_to_original_value() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref");
let b = a.clone();
assert_eq!(a, b);
}

View File

@ -84,7 +84,7 @@ license = "MIT"
links = "ostree-1"
name = "ostree-sys"
repository = "https://github.com/ostreedev/ostree-rs"
version = "0.12.0"
version = "0.13.0"
edition = "2021"
[package.metadata.docs.rs]
features = ["dox"]

View File

@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 0eeebbdf9d4d)
from gir-files (@ be0dbf02d770)
from gir-files (@ 1b758c141dda)

View File

@ -1255,21 +1255,21 @@ extern "C" {
pub fn ostree_collection_ref_dup(ref_: *const OstreeCollectionRef) -> *mut OstreeCollectionRef;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn ostree_collection_ref_equal(ref1: gconstpointer, ref2: gconstpointer) -> gboolean;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn ostree_collection_ref_free(ref_: *mut OstreeCollectionRef);
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn ostree_collection_ref_hash(ref_: gconstpointer) -> c_uint;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn ostree_collection_ref_dupv(
refs: *const *const OstreeCollectionRef,
) -> *mut *mut OstreeCollectionRef;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn ostree_collection_ref_equal(ref1: gconstpointer, ref2: gconstpointer) -> gboolean;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn ostree_collection_ref_freev(refs: *mut *mut OstreeCollectionRef);
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn ostree_collection_ref_hash(ref_: gconstpointer) -> c_uint;
//=========================================================================
// OstreeCommitSizesEntry

View File

@ -8,7 +8,7 @@ use ostree::{gio, glib};
#[test]
fn sign_api_should_work() {
let dummy_sign = ostree::Sign::by_name("dummy").unwrap();
assert_eq!(dummy_sign.name().unwrap(), "dummy");
assert_eq!(dummy_sign.name(), "dummy");
let result = ostree::prelude::SignExt::data(
&dummy_sign,
@ -25,7 +25,7 @@ fn sign_api_should_work() {
}
fn inner_sign_ed25519<T: SignExt>(signer: T) {
assert_eq!(signer.name().unwrap(), "ed25519");
assert_eq!(signer.name(), "ed25519");
let td = tempfile::tempdir().unwrap();
let path = td.path();

View File

@ -2445,7 +2445,7 @@ ostree_validate_structureof_dirmeta (GVariant *dirmeta,
* ostree_commit_get_parent:
* @commit_variant: Variant of type %OSTREE_OBJECT_TYPE_COMMIT
*
* Returns: Checksum of the parent commit of @commit_variant, or %NULL
* Returns: (nullable): Checksum of the parent commit of @commit_variant, or %NULL
* if none
*/
gchar *

View File

@ -186,7 +186,7 @@ ostree_remote_get_name (OstreeRemote *remote)
*
* Get the URL from the remote.
*
* Returns: (transfer full): the remote's URL
* Returns: (transfer full) (nullable): the remote's URL
* Since: 2018.6
*/
gchar *

View File

@ -269,6 +269,15 @@ do_resolve_nonroot (OstreeRepoFile *self,
return TRUE;
}
/**
* ostree_repo_file_ensure_resolved:
* @self: A repo file
* @error: Error
*
* Ensure that the backing metadata is loaded.
*
* Returns: %FALSE if the operation failed, %TRUE otherwise
*/
gboolean
ostree_repo_file_ensure_resolved (OstreeRepoFile *self,
GError **error)
@ -321,18 +330,42 @@ ostree_repo_file_get_xattrs (OstreeRepoFile *self,
return TRUE;
}
/**
* ostree_repo_file_tree_get_contents:
* @self: A repo file
*
* This API will return %NULL if the file is not "resolved" i.e. in a loaded
* state. It will also return %NULL if this path is not a directory tree.
*
* Returns: (nullable): The GVariant representing the children of this directory.
*/
GVariant *
ostree_repo_file_tree_get_contents (OstreeRepoFile *self)
{
return self->tree_contents;
}
/**
* ostree_repo_file_tree_get_metadata:
* @self: A repo file
*
* This API will return %NULL if the file is not "resolved" i.e. in a loaded
* state. It will also return %NULL if this path is not a directory tree.
*
* Returns: (nullable): The GVariant representing the metadata for this directory.
*/
GVariant *
ostree_repo_file_tree_get_metadata (OstreeRepoFile *self)
{
return self->tree_metadata;
}
/**
* ostree_repo_file_tree_set_metadata:
* @self: A repo file
*
* Replace the metadata checksum and metadata object.
*/
void
ostree_repo_file_tree_set_metadata (OstreeRepoFile *self,
const char *checksum,
@ -344,12 +377,24 @@ ostree_repo_file_tree_set_metadata (OstreeRepoFile *self,
self->tree_metadata_checksum = g_strdup (checksum);
}
/**
* ostree_repo_file_tree_get_contents_checksum:
* @self: A repo file
*
* Returns: (nullable): The SHA256 digest of the content object, or %NULL if this is not a directory.
*/
const char *
ostree_repo_file_tree_get_contents_checksum (OstreeRepoFile *self)
{
return self->tree_contents_checksum;
}
/**
* ostree_repo_file_tree_get_metadata_checksum:
* @self: A repo file
*
* Returns: (nullable): The SHA256 digest of the metadata object, or %NULL if this is not a directory.
*/
const char *
ostree_repo_file_tree_get_metadata_checksum (OstreeRepoFile *self)
{
@ -384,6 +429,12 @@ ostree_repo_file_get_root (OstreeRepoFile *self)
return parent;
}
/**
* ostree_repo_file_tree_get_checksum:
* @self: A repo file
*
* Returns: For non-directories, the SHA-256 digest of the object. For directories, the metadata digest will be returned.
*/
const char *
ostree_repo_file_get_checksum (OstreeRepoFile *self)
{

View File

@ -982,7 +982,7 @@ _ostree_repo_remote_name_is_file (const char *remote_name)
* underneath that group, or @default_value if the remote exists but not the
* option name. If an error is returned, @out_value will be set to %NULL.
*
* Returns: %TRUE on success, otherwise %FALSE with @error set
* Returns: (nullable): %TRUE on success, otherwise %FALSE with @error set
*
* Since: 2016.5
*/

View File

@ -502,7 +502,7 @@ ostree_sepolicy_new_at (int rootfs_dfd,
* policy objects to be created from file-descriptor relative paths, which
* may not be globally accessible.
*
* Returns: (transfer none): Path to rootfs
* Returns: (transfer none) (nullable): Path to rootfs
*/
GFile *
ostree_sepolicy_get_path (OstreeSePolicy *self)
@ -530,7 +530,7 @@ ostree_sepolicy_get_name (OstreeSePolicy *self)
* ostree_sepolicy_get_csum:
* @self:
*
* Returns: (transfer none): Checksum of current policy
* Returns: (transfer none) (nullable): Checksum of current policy
*
* Since: 2016.5
*/