From 1ab87e6b979213f540b8b46aece864599da7fa7d Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Wed, 26 Aug 2020 22:18:00 +0200 Subject: [PATCH] conf: anchor function name patterns to avoid unexpected exclusions --- rust-bindings/rust/conf/ostree.toml | 22 +++++++++--------- rust-bindings/rust/src/auto/functions.rs | 12 ++++++++++ rust-bindings/rust/src/auto/repo.rs | 24 ++++++++++++++++++++ rust-bindings/rust/src/auto/versions.txt | 2 +- rust-bindings/rust/sys/src/auto/versions.txt | 2 +- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/rust-bindings/rust/conf/ostree.toml b/rust-bindings/rust/conf/ostree.toml index aeb7734a..a8ca3fb5 100644 --- a/rust-bindings/rust/conf/ostree.toml +++ b/rust-bindings/rust/conf/ostree.toml @@ -127,7 +127,7 @@ name = "OSTree.CollectionRef" status = "generate" [[object.function]] # [IGNORE] helper functions for NULL-terminated arrays - pattern = "dupv|freev" + pattern = "^(dupv|freev)$" ignore = true [[object.function]] @@ -140,12 +140,12 @@ name = "OSTree.Repo" status = "generate" [[object.function]] # [MANUAL] we special-case the checksum value - pattern = "write_content|write_content_async|write_metadata|write_metadata_async" + pattern = "^(write_content|write_content_async|write_metadata|write_metadata_async)$" ignore = true [[object.function]] # [FAIL] these fail because of issues with arrays of dubious lifetimes - pattern = "find_remotes_async|pull_from_remotes_async" + pattern = "^(find_remotes_async|pull_from_remotes_async)$" ignore = true [[object.function]] @@ -167,7 +167,7 @@ name = "OSTree.RepoFinder" status = "generate" [[object.function]] # [FAIL] these fail because of issues with arrays of dubious lifetimes/NULL-terminated arrays - pattern = "resolve_async|resolve_all_async" + pattern = "^(resolve_async|resolve_all_async)$" ignore = true [[object]] @@ -202,7 +202,7 @@ name = "OSTree.Sign" status = "generate" [[object.function]] # [IGNORE] these shouldn't be on this type, they belong to subclasses - pattern = "dummy_.+|ed25519_.+" + pattern = "^(dummy_.+|ed25519_.+)$" ignore = true [[object]] @@ -219,30 +219,30 @@ name = "OSTree.*" status = "generate" [[object.function]] # [MANUAL] probably can't be autogenerated because of the custom Checksum type - pattern = "checksum_file|checksum_file_async|checksum_file_at|checksum_file_from_input" + pattern = "^(checksum_file|checksum_file_async|checksum_file_at|checksum_file_from_input)$" ignore = true [[object.function]] # [IGNORE] low-level checksum functions, we have a custom checksum API - pattern = "cmp_checksum_bytes|checksum_from_bytes|checksum_to_bytes|checksum_inplace_from_bytes|checksum_inplace_to_bytes|checksum_b64_from_bytes|checksum_b64_to_bytes|checksum_b64_inplace_from_bytes|checksum_b64_inplace_to_bytes" + pattern = "^(cmp_checksum_bytes|checksum_from_bytes|checksum_to_bytes|checksum_inplace_from_bytes|checksum_inplace_to_bytes|checksum_b64_from_bytes|checksum_b64_to_bytes|checksum_b64_inplace_from_bytes|checksum_b64_inplace_to_bytes)$" ignore = true [[object.function]] # [IGNORE] needs custom handling to deal with its raw pointer parameter - pattern = "hash_object_name" + name = "hash_object_name" ignore = true [[object.function]] # [IGNORE] private API - pattern = "cmd__private__" + name = "cmd__private__" ignore = true [[object.constant]] # [IGNORE] version-dependent constants - pattern = "VERSION|VERSION_S|YEAR_VERSION|RELEASE_VERSION" + pattern = "^(VERSION|VERSION_S|YEAR_VERSION|RELEASE_VERSION)$" ignore = true [[object.constant]] # [IGNORE] build-dependent constants - pattern = "BUILT_FEATURES" + name = "BUILT_FEATURES" ignore = true diff --git a/rust-bindings/rust/src/auto/functions.rs b/rust-bindings/rust/src/auto/functions.rs index 7adfe315..8d514309 100644 --- a/rust-bindings/rust/src/auto/functions.rs +++ b/rust-bindings/rust/src/auto/functions.rs @@ -41,6 +41,18 @@ pub fn check_version(required_year: u32, required_release: u32) -> bool { // unsafe { TODO: call ostree_sys:ostree_checksum_bytes_peek_validate() } //} +pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_checksum_from_bytes_v(csum_v.to_glib_none().0)) + } +} + +pub fn checksum_to_bytes_v(checksum: &str) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_checksum_to_bytes_v(checksum.to_glib_none().0)) + } +} + #[cfg(any(feature = "v2018_2", feature = "dox"))] pub fn commit_get_content_checksum(commit_variant: &glib::Variant) -> Option { unsafe { diff --git a/rust-bindings/rust/src/auto/repo.rs b/rust-bindings/rust/src/auto/repo.rs index 7e37a713..71dbb159 100644 --- a/rust-bindings/rust/src/auto/repo.rs +++ b/rust-bindings/rust/src/auto/repo.rs @@ -903,6 +903,14 @@ impl Repo { } } + pub fn write_content_trusted, Q: IsA>(&self, checksum: &str, object_input: &P, length: u64, cancellable: Option<&Q>) -> Result<(), glib::Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_content_trusted(self.to_glib_none().0, checksum.to_glib_none().0, object_input.as_ref().to_glib_none().0, length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + pub fn write_dfd_to_mtree, Q: IsA>(&self, dfd: i32, path: &str, mtree: &P, modifier: Option<&RepoCommitModifier>, cancellable: Option<&Q>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); @@ -919,6 +927,22 @@ impl Repo { } } + pub fn write_metadata_stream_trusted, Q: IsA>(&self, objtype: ObjectType, checksum: &str, object_input: &P, length: u64, cancellable: Option<&Q>) -> Result<(), glib::Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_metadata_stream_trusted(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, object_input.as_ref().to_glib_none().0, length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_metadata_trusted>(&self, objtype: ObjectType, checksum: &str, variant: &glib::Variant, cancellable: Option<&P>) -> Result<(), glib::Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_metadata_trusted(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, variant.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + pub fn write_mtree, Q: IsA>(&self, mtree: &P, cancellable: Option<&Q>) -> Result { unsafe { let mut out_file = ptr::null_mut(); diff --git a/rust-bindings/rust/src/auto/versions.txt b/rust-bindings/rust/src/auto/versions.txt index 518b4e22..5ed5c39f 100644 --- a/rust-bindings/rust/src/auto/versions.txt +++ b/rust-bindings/rust/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 2d1ffab1) -from gir-files (https://github.com/gtk-rs/gir-files @ 26bb987) +from gir-files (https://github.com/gtk-rs/gir-files @ ea146ce) diff --git a/rust-bindings/rust/sys/src/auto/versions.txt b/rust-bindings/rust/sys/src/auto/versions.txt index 518b4e22..5ed5c39f 100644 --- a/rust-bindings/rust/sys/src/auto/versions.txt +++ b/rust-bindings/rust/sys/src/auto/versions.txt @@ -1,2 +1,2 @@ Generated by gir (https://github.com/gtk-rs/gir @ 2d1ffab1) -from gir-files (https://github.com/gtk-rs/gir-files @ 26bb987) +from gir-files (https://github.com/gtk-rs/gir-files @ ea146ce)