Enable `trust_return_value_nullability`
authorColin Walters <walters@verbum.org>
Thu, 1 Dec 2022 13:10:15 +0000 (08:10 -0500)
committerColin Walters <walters@verbum.org>
Fri, 17 Mar 2023 12:13:13 +0000 (08:13 -0400)
Several commonly used APIs currently unnecessarily return
`Option<T>`, like `ostree_deployment_get_csum()`.

Flip the gir flag for this to on; I think our annotations are
correct.

21 files changed:
rust-bindings/conf/ostree.toml
rust-bindings/src/auto/bootconfig_parser.rs
rust-bindings/src/auto/collection_ref.rs
rust-bindings/src/auto/deployment.rs
rust-bindings/src/auto/functions.rs
rust-bindings/src/auto/gpg_verify_result.rs
rust-bindings/src/auto/mutable_tree.rs
rust-bindings/src/auto/remote.rs
rust-bindings/src/auto/repo.rs
rust-bindings/src/auto/repo_file.rs
rust-bindings/src/auto/se_policy.rs
rust-bindings/src/auto/sign.rs
rust-bindings/src/auto/sysroot.rs
rust-bindings/src/auto/versions.txt
rust-bindings/src/collection_ref.rs
rust-bindings/src/object_name.rs
rust-bindings/src/sysroot.rs
rust-bindings/src/tests/collection_ref.rs
rust-bindings/sys/src/auto/versions.txt
rust-bindings/sys/src/lib.rs
rust-bindings/tests/sign/mod.rs

index 6bcfe4f7ee494d55fcd1e754e726a6aa00c7530a..57314db478ba8c6fa7ea63bcf96ffa7e80456e9b 100644 (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" ]
index 042824c30c251c8c58ad0b1e81ca8841b9f55410..0f59255fab3cdf0bc03d3d958f1f1a6b3f291b4e 100644 (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))
         }
index 603b0156cad13704c31dbdd5a33dbbc3ff164a67..cb3bf4093ed647264adb303a098505f002d7686f 100644 (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))
         }
index cba219c35b08a33a4556d5295b857d69fcd5112d..984bbb2506a56b951784965cd8a95f405a7feb12 100644 (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()))
         }
index 26f9fd5a57d6e6e1492cdb1783eb41d4ab0c7098..9f8952170dd16af386d66eb1d01c42531b15df9b 100644 (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()))
     }
index 6748f2545b5627b0de84950baccecbebc72c8612..f4c139fc6a6d3f6724eab0b2dba49d0f4be7dead 100644 (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))
         }
index 98206f312bdcd34026e7c47bb6a553eaaf01627d..d70941c7c9ede851dde722ceba3f9877c29f5816 100644 (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))
         }
index 95939f25d40f95ba07ffa025cb02e35a2af04138..9b80a8c3bc01b50deb156078dafe06046a10b9f8 100644 (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())
+    }
+}
index 58babf96fa439ee0dc43943dd95c0cf643660edd..39bead0949336327ab1c85404e04fae5556f8fc6 100644 (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();
index 3631c3addf624379654b935c3f2d34c1dec480b8..31fe363c8daee32b0ecacbe2b31a5c0f72e8644c 100644 (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))
         }
index 386e5bee5cbea1f55cf8a9e3a2b018284c057927..131993262bdbc77b2aa33bb311c54f7b21c063b2 100644 (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 {}
index 64b1da6c00ca82b4112de4f4d1e9d5546b24cb88..90fa1ded5b43f022f01069612b3ce413799683d2 100644 (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))
         }
index 32d5855e688443972f35f12bf7ccaa2bcff3526f..020a8a1be9c9c6c91e62a82f36c49a1d94c592b4 100644 (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))
         }
index 154f5b0311750f9c63aec49c7404f6292ed02d24..c9131191385ba9248cd357c9d6028bb79ca160eb 100644 (file)
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 0eeebbdf9d4d)
-from gir-files (@ be0dbf02d770)
+from gir-files (@ f4ba299323ae)
index 0fb28deb49253818d781230d3b7adb3051aaee0f..47daaaca8b19d89715d6dd7623ddc26b7bc04f44 100644 (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");
index d6071780e08aed90689af1560b26e6da4528cad5..772b0d88eeb737952deab60b546b66dcf538d9ec 100644 (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")
     }
 }
 
index d7b2b76790c02b8d5cda68e37f292538561a8085..ea8c3cb1e3862edb3817a20818fb4532bd6fe228 100644 (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());
     }
index b6bf050e6b17c63ef8105ea3d3a85f2c26f0bb1c..515bd3858193b0628ad164000cacc2b3efb1208f 100644 (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);
 }
index 154f5b0311750f9c63aec49c7404f6292ed02d24..c9131191385ba9248cd357c9d6028bb79ca160eb 100644 (file)
@@ -1,2 +1,2 @@
 Generated by gir (https://github.com/gtk-rs/gir @ 0eeebbdf9d4d)
-from gir-files (@ be0dbf02d770)
+from gir-files (@ f4ba299323ae)
index d6e576d2f22b7851f3778f51838b9d74e3613086..fe17c5d5494812b20f2c7a8724fd223c36f7ff1c 100644 (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
index aa2a59a0aaa5b886bff2284ef56b4d47b4ea4015..745076cbaa75760e52466b32c28c8dfa16bf68ad 100644 (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();