From 5e8753b369a657e235fe3dd234e484e8fa9159b1 Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Sun, 30 Sep 2018 15:17:26 +0200 Subject: [PATCH] Generate functions and constants --- rust-bindings/rust/conf/libostree.toml | 6 + rust-bindings/rust/libostree/Cargo.lock | 1 + rust-bindings/rust/libostree/Cargo.toml | 1 + .../rust/libostree/src/auto/async_progress.rs | 59 - .../rust/libostree/src/auto/collection_ref.rs | 66 - .../rust/libostree/src/auto/constants.rs | 61 + .../rust/libostree/src/auto/enums.rs | 9 - .../rust/libostree/src/auto/functions.rs | 376 ++++++ .../libostree/src/auto/gpg_verify_result.rs | 100 -- rust-bindings/rust/libostree/src/auto/mod.rs | 28 + .../rust/libostree/src/auto/mutable_tree.rs | 51 - .../rust/libostree/src/auto/remote.rs | 18 - rust-bindings/rust/libostree/src/auto/repo.rs | 1202 ----------------- .../src/auto/repo_commit_modifier.rs | 25 - .../libostree/src/auto/repo_dev_ino_cache.rs | 11 - .../rust/libostree/src/auto/repo_file.rs | 13 - .../rust/libostree/src/auto/se_policy.rs | 61 - rust-bindings/rust/libostree/src/lib.rs | 2 + rust-bindings/rust/sample/Cargo.lock | 1 + 19 files changed, 476 insertions(+), 1615 deletions(-) create mode 100644 rust-bindings/rust/libostree/src/auto/constants.rs create mode 100644 rust-bindings/rust/libostree/src/auto/functions.rs diff --git a/rust-bindings/rust/conf/libostree.toml b/rust-bindings/rust/conf/libostree.toml index 045041ea..a389aa11 100644 --- a/rust-bindings/rust/conf/libostree.toml +++ b/rust-bindings/rust/conf/libostree.toml @@ -85,3 +85,9 @@ status = "generate" pattern = "lookup" ignore = true +[[object]] +name = "OSTree.*" +status = "generate" + [[object.function]] + pattern = "cmp_checksum_bytes|checksum_inplace_to_bytes" + ignore = true diff --git a/rust-bindings/rust/libostree/Cargo.lock b/rust-bindings/rust/libostree/Cargo.lock index f5f15b57..f79b90cc 100644 --- a/rust-bindings/rust/libostree/Cargo.lock +++ b/rust-bindings/rust/libostree/Cargo.lock @@ -88,6 +88,7 @@ dependencies = [ "glib 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "libostree-sys 0.2.0", ] diff --git a/rust-bindings/rust/libostree/Cargo.toml b/rust-bindings/rust/libostree/Cargo.toml index 8202c2ed..af71b777 100644 --- a/rust-bindings/rust/libostree/Cargo.toml +++ b/rust-bindings/rust/libostree/Cargo.toml @@ -8,6 +8,7 @@ name = "libostree" [dependencies] libc = "^0.2.0" bitflags = "^1.0.0" +lazy_static = "1.1.0" glib = "^0.6.0" gio = "^0.5.0" glib-sys = "^0.7" diff --git a/rust-bindings/rust/libostree/src/auto/async_progress.rs b/rust-bindings/rust/libostree/src/auto/async_progress.rs index b6c130a3..587602d8 100644 --- a/rust-bindings/rust/libostree/src/auto/async_progress.rs +++ b/rust-bindings/rust/libostree/src/auto/async_progress.rs @@ -25,10 +25,6 @@ glib_wrapper! { } impl AsyncProgress { - /// - /// # Returns - /// - /// A new progress object pub fn new() -> AsyncProgress { unsafe { from_glib_full(ffi::ostree_async_progress_new()) @@ -46,32 +42,12 @@ impl Default for AsyncProgress { } } -/// Trait containing all `AsyncProgress` methods. -/// -/// # Implementors -/// -/// [`AsyncProgress`](struct.AsyncProgress.html) pub trait AsyncProgressExt { - /// Process any pending signals, ensuring the main context is cleared - /// of sources used by this object. Also ensures that no further - /// events will be queued. fn finish(&self); //#[cfg(any(feature = "v2017_6", feature = "dox"))] //fn get(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); - /// Get the human-readable status string from the `AsyncProgress`. This - /// operation is thread-safe. The retuned value may be `None` if no status is - /// set. - /// - /// This is a convenience function to get the well-known `status` key. - /// - /// Feature: `v2017_6` - /// - /// - /// # Returns - /// - /// the current status, or `None` if none is set #[cfg(any(feature = "v2017_6", feature = "dox"))] fn get_status(&self) -> Option; @@ -79,33 +55,12 @@ pub trait AsyncProgressExt { fn get_uint64(&self, key: &str) -> u64; - /// Look up a key in the `AsyncProgress` and return the `glib::Variant` associated - /// with it. The lookup is thread-safe. - /// - /// Feature: `v2017_6` - /// - /// ## `key` - /// a key to look up - /// - /// # Returns - /// - /// value for the given `key`, or `None` if - /// it was not set #[cfg(any(feature = "v2017_6", feature = "dox"))] fn get_variant(&self, key: &str) -> Option; //#[cfg(any(feature = "v2017_6", feature = "dox"))] //fn set(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); - /// Set the human-readable status string for the `AsyncProgress`. This - /// operation is thread-safe. `None` may be passed to clear the status. - /// - /// This is a convenience function to set the well-known `status` key. - /// - /// Feature: `v2017_6` - /// - /// ## `status` - /// new status string, or `None` to clear the status #[cfg(any(feature = "v2017_6", feature = "dox"))] fn set_status<'a, P: Into>>(&self, status: P); @@ -113,23 +68,9 @@ pub trait AsyncProgressExt { fn set_uint64(&self, key: &str, value: u64); - /// Assign a new `value` to the given `key`, replacing any existing value. The - /// operation is thread-safe. `value` may be a floating reference; - /// `glib::Variant::ref_sink` will be called on it. - /// - /// Any watchers of the `AsyncProgress` will be notified of the change if - /// `value` differs from the existing value for `key`. - /// - /// Feature: `v2017_6` - /// - /// ## `key` - /// a key to set - /// ## `value` - /// the value to assign to `key` #[cfg(any(feature = "v2017_6", feature = "dox"))] fn set_variant(&self, key: &str, value: &glib::Variant); - /// Emitted when `self_` has been changed. fn connect_changed(&self, f: F) -> SignalHandlerId; } diff --git a/rust-bindings/rust/libostree/src/auto/collection_ref.rs b/rust-bindings/rust/libostree/src/auto/collection_ref.rs index a9d5b917..c4dad645 100644 --- a/rust-bindings/rust/libostree/src/auto/collection_ref.rs +++ b/rust-bindings/rust/libostree/src/auto/collection_ref.rs @@ -22,21 +22,6 @@ glib_wrapper! { } impl CollectionRef { - /// Create a new `CollectionRef` containing (`collection_id`, `ref_name`). If - /// `collection_id` is `None`, this is equivalent to a plain ref name string (not a - /// refspec; no remote name is included), which can be used for non-P2P - /// operations. - /// - /// Feature: `v2018_6` - /// - /// ## `collection_id` - /// a collection ID, or `None` for a plain ref - /// ## `ref_name` - /// a ref name - /// - /// # Returns - /// - /// a new `CollectionRef` #[cfg(any(feature = "v2018_6", feature = "dox"))] pub fn new<'a, P: Into>>(collection_id: P, ref_name: &str) -> CollectionRef { let collection_id = collection_id.into(); @@ -46,14 +31,6 @@ impl CollectionRef { } } - /// Create a copy of the given `self`. - /// - /// Feature: `v2018_6` - /// - /// - /// # Returns - /// - /// a newly allocated copy of `self` #[cfg(any(feature = "v2018_6", feature = "dox"))] pub fn dup(&self) -> Option { unsafe { @@ -61,18 +38,6 @@ impl CollectionRef { } } - /// Copy an array of `OstreeCollectionRefs`, including deep copies of all its - /// elements. `refs` must be `None`-terminated; it may be empty, but must not be - /// `None`. - /// - /// Feature: `v2018_6` - /// - /// ## `refs` - /// `None`-terminated array of `OstreeCollectionRefs` - /// - /// # Returns - /// - /// a newly allocated copy of `refs` #[cfg(any(feature = "v2018_6", feature = "dox"))] pub fn dupv(refs: &[&CollectionRef]) -> Vec { unsafe { @@ -80,19 +45,6 @@ impl CollectionRef { } } - /// Compare `ref1` and `ref2` and return `true` if they have the same collection ID and - /// ref name, and `false` otherwise. Both `ref1` and `ref2` must be non-`None`. - /// - /// Feature: `v2018_6` - /// - /// ## `ref1` - /// an `CollectionRef` - /// ## `ref2` - /// another `CollectionRef` - /// - /// # Returns - /// - /// `true` if `ref1` and `ref2` are equal, `false` otherwise #[cfg(any(feature = "v2018_6", feature = "dox"))] fn equal<'a, P: Into>>(&self, ref2: P) -> bool { unsafe { @@ -100,13 +52,6 @@ impl CollectionRef { } } - /// Free the given array of `refs`, including freeing all its elements. `refs` - /// must be `None`-terminated; it may be empty, but must not be `None`. - /// - /// Feature: `v2018_6` - /// - /// ## `refs` - /// an array of `OstreeCollectionRefs` #[cfg(any(feature = "v2018_6", feature = "dox"))] pub fn freev(refs: &[&CollectionRef]) { unsafe { @@ -114,17 +59,6 @@ impl CollectionRef { } } - /// Hash the given `ref_`. This function is suitable for use with `glib::HashTable`. - /// `ref_` must be non-`None`. - /// - /// Feature: `v2018_6` - /// - /// ## `ref_` - /// an `CollectionRef` - /// - /// # Returns - /// - /// hash value for `ref_` #[cfg(any(feature = "v2018_6", feature = "dox"))] fn hash(&self) -> u32 { unsafe { diff --git a/rust-bindings/rust/libostree/src/auto/constants.rs b/rust-bindings/rust/libostree/src/auto/constants.rs new file mode 100644 index 00000000..2b91bf49 --- /dev/null +++ b/rust-bindings/rust/libostree/src/auto/constants.rs @@ -0,0 +1,61 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ c385982) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +use ffi; +use std::ffi::CStr; + +lazy_static! { + pub static ref COMMIT_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_GVARIANT_STRING).to_str().unwrap()}; +} +#[cfg(any(feature = "v2018_6", feature = "dox"))] +lazy_static! { + pub static ref COMMIT_META_KEY_COLLECTION_BINDING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_COLLECTION_BINDING).to_str().unwrap()}; +} +#[cfg(any(feature = "v2017_7", feature = "dox"))] +lazy_static! { + pub static ref COMMIT_META_KEY_ENDOFLIFE: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ENDOFLIFE).to_str().unwrap()}; +} +#[cfg(any(feature = "v2017_7", feature = "dox"))] +lazy_static! { + pub static ref COMMIT_META_KEY_ENDOFLIFE_REBASE: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE).to_str().unwrap()}; +} +#[cfg(any(feature = "v2017_9", feature = "dox"))] +lazy_static! { + pub static ref COMMIT_META_KEY_REF_BINDING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_REF_BINDING).to_str().unwrap()}; +} +#[cfg(any(feature = "v2017_13", feature = "dox"))] +lazy_static! { + pub static ref COMMIT_META_KEY_SOURCE_TITLE: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_SOURCE_TITLE).to_str().unwrap()}; +} +#[cfg(any(feature = "v2014_9", feature = "dox"))] +lazy_static! { + pub static ref COMMIT_META_KEY_VERSION: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_VERSION).to_str().unwrap()}; +} +lazy_static! { + pub static ref DIRMETA_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_DIRMETA_GVARIANT_STRING).to_str().unwrap()}; +} +lazy_static! { + pub static ref FILEMETA_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_FILEMETA_GVARIANT_STRING).to_str().unwrap()}; +} +#[cfg(any(feature = "v2018_3", feature = "dox"))] +lazy_static! { + pub static ref ORIGIN_TRANSIENT_GROUP: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_ORIGIN_TRANSIENT_GROUP).to_str().unwrap()}; +} +#[cfg(any(feature = "v2018_6", feature = "dox"))] +lazy_static! { + pub static ref REPO_METADATA_REF: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_REPO_METADATA_REF).to_str().unwrap()}; +} +lazy_static! { + pub static ref SUMMARY_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_SUMMARY_GVARIANT_STRING).to_str().unwrap()}; +} +lazy_static! { + pub static ref SUMMARY_SIG_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_SUMMARY_SIG_GVARIANT_STRING).to_str().unwrap()}; +} +lazy_static! { + pub static ref TREE_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_TREE_GVARIANT_STRING).to_str().unwrap()}; +} +#[cfg(any(feature = "v2017_4", feature = "dox"))] +lazy_static! { + pub static ref VERSION_S: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_VERSION_S).to_str().unwrap()}; +} diff --git a/rust-bindings/rust/libostree/src/auto/enums.rs b/rust-bindings/rust/libostree/src/auto/enums.rs index 521bc7e5..85260f12 100644 --- a/rust-bindings/rust/libostree/src/auto/enums.rs +++ b/rust-bindings/rust/libostree/src/auto/enums.rs @@ -5,9 +5,6 @@ use ffi; use glib::translate::*; -/// Formatting flags for `GpgVerifyResultExt::describe`. Currently -/// there's only one possible output format, but this enumeration allows -/// for future variations. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Clone, Copy)] pub enum GpgSignatureFormatFlags { @@ -38,8 +35,6 @@ impl FromGlib for GpgSignatureFormatFlags { } } -/// Enumeration for core object types; `ObjectType::File` is for -/// content, the other types are metadata. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Clone, Copy)] pub enum ObjectType { @@ -160,8 +155,6 @@ impl FromGlib for RepoCheckoutOverwriteMod } } -/// See the documentation of `Repo` for more information about the -/// possible modes. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Clone, Copy)] pub enum RepoMode { @@ -237,7 +230,6 @@ impl FromGlib for RepoPruneFlags { } } -/// The remote change operation. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Clone, Copy)] pub enum RepoRemoteChange { @@ -307,7 +299,6 @@ impl FromGlib for RepoResolveRevExtFlags { } } -/// Parameters controlling optimization of static deltas. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Clone, Copy)] pub enum StaticDeltaGenerateOpt { diff --git a/rust-bindings/rust/libostree/src/auto/functions.rs b/rust-bindings/rust/libostree/src/auto/functions.rs new file mode 100644 index 00000000..6c3461ac --- /dev/null +++ b/rust-bindings/rust/libostree/src/auto/functions.rs @@ -0,0 +1,376 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ c385982) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +use Error; +use ObjectType; +use ffi; +use gio; +use glib; +use glib::object::IsA; +use glib::translate::*; +use std::mem; +use std::ptr; + + +#[cfg(any(feature = "v2017_15", feature = "dox"))] +pub fn break_hardlink<'a, P: Into>>(dfd: i32, path: &str, skip_xattrs: bool, cancellable: P) -> Result<(), Error> { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_break_hardlink(dfd, path.to_glib_none().0, skip_xattrs.to_glib(), cancellable.0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn check_version(required_year: u32, required_release: u32) -> bool { + unsafe { + from_glib(ffi::ostree_check_version(required_year, required_release)) + } +} + +//pub fn checksum_b64_from_bytes(csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32) -> Option { +// unsafe { TODO: call ffi::ostree_checksum_b64_from_bytes() } +//} + +//pub fn checksum_b64_inplace_from_bytes(csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, buf: &str) { +// unsafe { TODO: call ffi::ostree_checksum_b64_inplace_from_bytes() } +//} + +//pub fn checksum_b64_inplace_to_bytes(checksum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 28 }; 32, buf: u8) { +// unsafe { TODO: call ffi::ostree_checksum_b64_inplace_to_bytes() } +//} + +//pub fn checksum_b64_to_bytes(checksum: &str) -> /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 { +// unsafe { TODO: call ffi::ostree_checksum_b64_to_bytes() } +//} + +//pub fn checksum_bytes_peek(bytes: &glib::Variant) -> /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 { +// unsafe { TODO: call ffi::ostree_checksum_bytes_peek() } +//} + +//pub fn checksum_bytes_peek_validate(bytes: &glib::Variant) -> Result { +// unsafe { TODO: call ffi::ostree_checksum_bytes_peek_validate() } +//} + +//pub fn checksum_file<'a, P: IsA, Q: Into>>(f: &P, objtype: ObjectType, out_csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: Q) -> Result<(), Error> { +// unsafe { TODO: call ffi::ostree_checksum_file() } +//} + +//pub fn checksum_file_async<'a, P: IsA, Q: Into>, R: /*Ignored*/gio::AsyncReadyCallback>(f: &P, objtype: ObjectType, io_priority: i32, cancellable: Q, callback: R) { +// unsafe { TODO: call ffi::ostree_checksum_file_async() } +//} + +//#[cfg(any(feature = "v2017_13", feature = "dox"))] +//pub fn checksum_file_at<'a, P: Into>, Q: Into>>(dfd: i32, path: &str, stbuf: P, objtype: ObjectType, flags: /*Ignored*/ChecksumFlags, out_checksum: &str, cancellable: Q) -> Result<(), Error> { +// unsafe { TODO: call ffi::ostree_checksum_file_at() } +//} + +//pub fn checksum_file_from_input<'a, 'b, 'c, P: Into>, Q: IsA + 'b, R: Into>, S: Into>>(file_info: &gio::FileInfo, xattrs: P, in_: R, objtype: ObjectType, out_csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: S) -> Result<(), Error> { +// unsafe { TODO: call ffi::ostree_checksum_file_from_input() } +//} + +//pub fn checksum_from_bytes(csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32) -> Option { +// unsafe { TODO: call ffi::ostree_checksum_from_bytes() } +//} + +pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> Option { + unsafe { + from_glib_full(ffi::ostree_checksum_from_bytes_v(csum_v.to_glib_none().0)) + } +} + +//pub fn checksum_inplace_from_bytes(csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, buf: &str) { +// unsafe { TODO: call ffi::ostree_checksum_inplace_from_bytes() } +//} + +//pub fn checksum_to_bytes(checksum: &str) -> /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 { +// unsafe { TODO: call ffi::ostree_checksum_to_bytes() } +//} + +pub fn checksum_to_bytes_v(checksum: &str) -> Option { + unsafe { + from_glib_full(ffi::ostree_checksum_to_bytes_v(checksum.to_glib_none().0)) + } +} + +//pub fn cmd__private__() -> /*Ignored*/Option { +// unsafe { TODO: call ffi::ostree_cmd__private__() } +//} + +pub fn commit_get_content_checksum(commit_variant: &glib::Variant) -> Option { + unsafe { + from_glib_full(ffi::ostree_commit_get_content_checksum(commit_variant.to_glib_none().0)) + } +} + +pub fn commit_get_parent(commit_variant: &glib::Variant) -> Option { + unsafe { + from_glib_full(ffi::ostree_commit_get_parent(commit_variant.to_glib_none().0)) + } +} + +pub fn commit_get_timestamp(commit_variant: &glib::Variant) -> u64 { + unsafe { + ffi::ostree_commit_get_timestamp(commit_variant.to_glib_none().0) + } +} + +pub fn content_file_parse<'a, P: IsA, Q: Into>>(compressed: bool, content_path: &P, trusted: bool, cancellable: Q) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), Error> { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + 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_content_file_parse(compressed.to_glib(), content_path.to_glib_none().0, trusted.to_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.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)) } + } +} + +pub fn content_file_parse_at<'a, P: Into>>(compressed: bool, parent_dfd: i32, path: &str, trusted: bool, cancellable: P) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), Error> { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + 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_content_file_parse_at(compressed.to_glib(), parent_dfd, path.to_glib_none().0, trusted.to_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.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)) } + } +} + +pub fn content_stream_parse<'a, P: IsA, Q: Into>>(compressed: bool, input: &P, input_length: u64, trusted: bool, cancellable: Q) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), Error> { + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + 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_content_stream_parse(compressed.to_glib(), input.to_glib_none().0, input_length, trusted.to_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.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)) } + } +} + +pub fn create_directory_metadata<'a, P: Into>>(dir_info: &gio::FileInfo, xattrs: P) -> Option { + let xattrs = xattrs.into(); + let xattrs = xattrs.to_glib_none(); + unsafe { + from_glib_full(ffi::ostree_create_directory_metadata(dir_info.to_glib_none().0, xattrs.0)) + } +} + +//pub fn diff_dirs<'a, P: IsA, Q: IsA, R: Into>>(flags: /*Ignored*/DiffFlags, a: &P, b: &Q, modified: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 24 }, removed: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 4, id: 15 }, added: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 4, id: 15 }, cancellable: R) -> Result<(), Error> { +// unsafe { TODO: call ffi::ostree_diff_dirs() } +//} + +//pub fn diff_dirs_with_options<'a, 'b, P: IsA, Q: IsA, R: Into>, S: Into>>(flags: /*Ignored*/DiffFlags, a: &P, b: &Q, modified: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 24 }, removed: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 4, id: 15 }, added: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 4, id: 15 }, options: R, cancellable: S) -> Result<(), Error> { +// unsafe { TODO: call ffi::ostree_diff_dirs_with_options() } +//} + +//pub fn diff_print, Q: IsA>(a: &P, b: &Q, modified: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 24 }, removed: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 4, id: 15 }, added: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 4, id: 15 }) { +// unsafe { TODO: call ffi::ostree_diff_print() } +//} + +//pub fn gpg_error_quark() -> /*Ignored*/glib::Quark { +// unsafe { TODO: call ffi::ostree_gpg_error_quark() } +//} + +//pub fn hash_object_name>>(a: P) -> u32 { +// unsafe { TODO: call ffi::ostree_hash_object_name() } +//} + +//pub fn metadata_variant_type(objtype: ObjectType) -> /*Ignored*/Option { +// unsafe { TODO: call ffi::ostree_metadata_variant_type() } +//} + +pub fn object_from_string(str: &str) -> (String, ObjectType) { + unsafe { + let mut out_checksum = ptr::null_mut(); + let mut out_objtype = mem::uninitialized(); + ffi::ostree_object_from_string(str.to_glib_none().0, &mut out_checksum, &mut out_objtype); + (from_glib_full(out_checksum), from_glib(out_objtype)) + } +} + +pub fn object_name_deserialize(variant: &glib::Variant) -> (String, ObjectType) { + unsafe { + let mut out_checksum = ptr::null(); + let mut out_objtype = mem::uninitialized(); + ffi::ostree_object_name_deserialize(variant.to_glib_none().0, &mut out_checksum, &mut out_objtype); + (from_glib_none(out_checksum), from_glib(out_objtype)) + } +} + +pub fn object_name_serialize(checksum: &str, objtype: ObjectType) -> Option { + unsafe { + from_glib_none(ffi::ostree_object_name_serialize(checksum.to_glib_none().0, objtype.to_glib())) + } +} + +pub fn object_to_string(checksum: &str, objtype: ObjectType) -> Option { + unsafe { + from_glib_full(ffi::ostree_object_to_string(checksum.to_glib_none().0, objtype.to_glib())) + } +} + +pub fn object_type_from_string(str: &str) -> ObjectType { + unsafe { + from_glib(ffi::ostree_object_type_from_string(str.to_glib_none().0)) + } +} + +pub fn object_type_to_string(objtype: ObjectType) -> Option { + unsafe { + from_glib_none(ffi::ostree_object_type_to_string(objtype.to_glib())) + } +} + +pub fn parse_refspec(refspec: &str) -> Result<(Option, String), Error> { + unsafe { + let mut out_remote = ptr::null_mut(); + let mut out_ref = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ffi::ostree_parse_refspec(refspec.to_glib_none().0, &mut out_remote, &mut out_ref, &mut error); + if error.is_null() { Ok((from_glib_full(out_remote), from_glib_full(out_ref))) } else { Err(from_glib_full(error)) } + } +} + +pub fn raw_file_to_archive_z2_stream<'a, 'b, P: IsA, Q: Into>, R: Into>>(input: &P, file_info: &gio::FileInfo, xattrs: Q, cancellable: R) -> Result { + let xattrs = xattrs.into(); + let xattrs = xattrs.to_glib_none(); + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + unsafe { + let mut out_input = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ffi::ostree_raw_file_to_archive_z2_stream(input.to_glib_none().0, file_info.to_glib_none().0, xattrs.0, &mut out_input, cancellable.0, &mut error); + if error.is_null() { Ok(from_glib_full(out_input)) } else { Err(from_glib_full(error)) } + } +} + +#[cfg(any(feature = "v2017_3", feature = "dox"))] +pub fn raw_file_to_archive_z2_stream_with_options<'a, 'b, 'c, P: IsA, Q: Into>, R: Into>, S: Into>>(input: &P, file_info: &gio::FileInfo, xattrs: Q, options: R, cancellable: S) -> Result { + let xattrs = xattrs.into(); + let xattrs = xattrs.to_glib_none(); + let options = options.into(); + let options = options.to_glib_none(); + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + unsafe { + let mut out_input = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ffi::ostree_raw_file_to_archive_z2_stream_with_options(input.to_glib_none().0, file_info.to_glib_none().0, xattrs.0, options.0, &mut out_input, cancellable.0, &mut error); + if error.is_null() { Ok(from_glib_full(out_input)) } else { Err(from_glib_full(error)) } + } +} + +pub fn raw_file_to_content_stream<'a, 'b, P: IsA, Q: Into>, R: Into>>(input: &P, file_info: &gio::FileInfo, xattrs: Q, cancellable: R) -> Result<(gio::InputStream, u64), Error> { + let xattrs = xattrs.into(); + let xattrs = xattrs.to_glib_none(); + let cancellable = cancellable.into(); + let cancellable = cancellable.to_glib_none(); + unsafe { + let mut out_input = ptr::null_mut(); + let mut out_length = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ffi::ostree_raw_file_to_content_stream(input.to_glib_none().0, file_info.to_glib_none().0, xattrs.0, &mut out_input, &mut out_length, cancellable.0, &mut error); + if error.is_null() { Ok((from_glib_full(out_input), out_length)) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_checksum_string(sha256: &str) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_checksum_string(sha256.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +#[cfg(any(feature = "v2018_6", feature = "dox"))] +pub fn validate_collection_id<'a, P: Into>>(collection_id: P) -> Result<(), Error> { + let collection_id = collection_id.into(); + let collection_id = collection_id.to_glib_none(); + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_collection_id(collection_id.0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +#[cfg(any(feature = "v2017_8", feature = "dox"))] +pub fn validate_remote_name(remote_name: &str) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_remote_name(remote_name.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_rev(rev: &str) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_rev(rev.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_structureof_checksum_string(checksum: &str) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_structureof_checksum_string(checksum.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_structureof_commit(commit: &glib::Variant) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_structureof_commit(commit.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_structureof_csum_v(checksum: &glib::Variant) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_structureof_csum_v(checksum.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_structureof_dirmeta(dirmeta: &glib::Variant) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_structureof_dirmeta(dirmeta.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_structureof_dirtree(dirtree: &glib::Variant) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_structureof_dirtree(dirtree.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_structureof_file_mode(mode: u32) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_structureof_file_mode(mode, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} + +pub fn validate_structureof_objtype(objtype: u8) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ffi::ostree_validate_structureof_objtype(objtype, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } +} diff --git a/rust-bindings/rust/libostree/src/auto/gpg_verify_result.rs b/rust-bindings/rust/libostree/src/auto/gpg_verify_result.rs index f312443f..c6f32955 100644 --- a/rust-bindings/rust/libostree/src/auto/gpg_verify_result.rs +++ b/rust-bindings/rust/libostree/src/auto/gpg_verify_result.rs @@ -22,20 +22,6 @@ glib_wrapper! { } impl GpgVerifyResult { - /// Similar to `GpgVerifyResultExt::describe` but takes a `glib::Variant` of - /// all attributes for a GPG signature instead of an `GpgVerifyResult` - /// and signature index. - /// - /// The `variant` ``MUST`` have been created by - /// `GpgVerifyResultExt::get_all`. - /// ## `variant` - /// a `glib::Variant` from `GpgVerifyResultExt::get_all` - /// ## `output_buffer` - /// a `glib::String` to hold the description - /// ## `line_prefix` - /// optional line prefix string - /// ## `flags` - /// flags to adjust the description format pub fn describe_variant<'a, P: Into>>(variant: &glib::Variant, output_buffer: &mut glib::String, line_prefix: P, flags: GpgSignatureFormatFlags) { let line_prefix = line_prefix.into(); let line_prefix = line_prefix.to_glib_none(); @@ -45,105 +31,19 @@ impl GpgVerifyResult { } } -/// Trait containing all `GpgVerifyResult` methods. -/// -/// # Implementors -/// -/// [`GpgVerifyResult`](struct.GpgVerifyResult.html) pub trait GpgVerifyResultExt { - /// Counts all the signatures in `self`. - /// - /// # Returns - /// - /// signature count fn count_all(&self) -> u32; - /// Counts only the valid signatures in `self`. - /// - /// # Returns - /// - /// valid signature count fn count_valid(&self) -> u32; - /// Appends a brief, human-readable description of the GPG signature at - /// `signature_index` in `self` to the `output_buffer`. The description - /// spans multiple lines. A `line_prefix` string, if given, will precede - /// each line of the description. - /// - /// The `flags` argument is reserved for future variations to the description - /// format. Currently must be 0. - /// - /// It is a programmer error to request an invalid `signature_index`. Use - /// `GpgVerifyResultExt::count_all` to find the number of signatures in - /// `self`. - /// ## `signature_index` - /// which signature to describe - /// ## `output_buffer` - /// a `glib::String` to hold the description - /// ## `line_prefix` - /// optional line prefix string - /// ## `flags` - /// flags to adjust the description format fn describe<'a, P: Into>>(&self, signature_index: u32, output_buffer: &mut glib::String, line_prefix: P, flags: GpgSignatureFormatFlags); //fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 26 }) -> Option; - /// Builds a `glib::Variant` tuple of all available attributes for the GPG signature - /// at `signature_index` in `self`. - /// - /// The child values in the returned `glib::Variant` tuple are ordered to match the - /// `GpgSignatureAttr` enumeration, which means the enum values can be - /// used as index values in functions like `glib::Variant::get_child`. See the - /// `GpgSignatureAttr` description for the `glib::VariantType` of each - /// available attribute. - /// - /// `` - /// `` - /// The `GpgSignatureAttr` enumeration may be extended in the future - /// with new attributes, which would affect the `glib::Variant` tuple returned by - /// this function. While the position and type of current child values in - /// the `glib::Variant` tuple will not change, to avoid backward-compatibility - /// issues ``please do not depend on the tuple's overall size or - /// type signature``. - /// `` - /// `` - /// - /// It is a programmer error to request an invalid `signature_index`. Use - /// `GpgVerifyResultExt::count_all` to find the number of signatures in - /// `self`. - /// ## `signature_index` - /// which signature to get attributes from - /// - /// # Returns - /// - /// a new, floating, `glib::Variant` tuple fn get_all(&self, signature_index: u32) -> Option; - /// Searches `self` for a signature signed by `key_id`. If a match is found, - /// the function returns `true` and sets `out_signature_index` so that further - /// signature details can be obtained through `GpgVerifyResultExt::get`. - /// If no match is found, the function returns `false` and leaves - /// `out_signature_index` unchanged. - /// ## `key_id` - /// a GPG key ID or fingerprint - /// ## `out_signature_index` - /// return location for the index of the signature - /// signed by `key_id`, or `None` - /// - /// # Returns - /// - /// `true` on success, `false` on failure fn lookup(&self, key_id: &str) -> Option; - /// Checks if the result contains at least one signature from the - /// trusted keyring. You can call this function immediately after - /// `RepoExt::verify_summary` or `RepoExt::verify_commit_ext` - - /// it will handle the `None` `self` and filled `error` too. - /// - /// # Returns - /// - /// `true` if `self` was not `None` and had at least one - /// signature from trusted keyring, otherwise `false` fn require_valid_signature(&self) -> Result<(), Error>; } diff --git a/rust-bindings/rust/libostree/src/auto/mod.rs b/rust-bindings/rust/libostree/src/auto/mod.rs index 97d3482e..2c701c56 100644 --- a/rust-bindings/rust/libostree/src/auto/mod.rs +++ b/rust-bindings/rust/libostree/src/auto/mod.rs @@ -62,6 +62,34 @@ pub use self::flags::RepoCommitState; pub use self::flags::RepoPullFlags; pub use self::flags::SePolicyRestoreconFlags; +pub mod functions; + +mod constants; +pub use self::constants::COMMIT_GVARIANT_STRING; +#[cfg(any(feature = "v2018_6", feature = "dox"))] +pub use self::constants::COMMIT_META_KEY_COLLECTION_BINDING; +#[cfg(any(feature = "v2017_7", feature = "dox"))] +pub use self::constants::COMMIT_META_KEY_ENDOFLIFE; +#[cfg(any(feature = "v2017_7", feature = "dox"))] +pub use self::constants::COMMIT_META_KEY_ENDOFLIFE_REBASE; +#[cfg(any(feature = "v2017_9", feature = "dox"))] +pub use self::constants::COMMIT_META_KEY_REF_BINDING; +#[cfg(any(feature = "v2017_13", feature = "dox"))] +pub use self::constants::COMMIT_META_KEY_SOURCE_TITLE; +#[cfg(any(feature = "v2014_9", feature = "dox"))] +pub use self::constants::COMMIT_META_KEY_VERSION; +pub use self::constants::DIRMETA_GVARIANT_STRING; +pub use self::constants::FILEMETA_GVARIANT_STRING; +#[cfg(any(feature = "v2018_3", feature = "dox"))] +pub use self::constants::ORIGIN_TRANSIENT_GROUP; +#[cfg(any(feature = "v2018_6", feature = "dox"))] +pub use self::constants::REPO_METADATA_REF; +pub use self::constants::SUMMARY_GVARIANT_STRING; +pub use self::constants::SUMMARY_SIG_GVARIANT_STRING; +pub use self::constants::TREE_GVARIANT_STRING; +#[cfg(any(feature = "v2017_4", feature = "dox"))] +pub use self::constants::VERSION_S; + #[doc(hidden)] pub mod traits { pub use super::AsyncProgressExt; diff --git a/rust-bindings/rust/libostree/src/auto/mutable_tree.rs b/rust-bindings/rust/libostree/src/auto/mutable_tree.rs index 8538a812..e4c368d1 100644 --- a/rust-bindings/rust/libostree/src/auto/mutable_tree.rs +++ b/rust-bindings/rust/libostree/src/auto/mutable_tree.rs @@ -21,28 +21,12 @@ glib_wrapper! { } impl MutableTree { - /// - /// # Returns - /// - /// A new tree pub fn new() -> MutableTree { unsafe { from_glib_full(ffi::ostree_mutable_tree_new()) } } - /// Creates a new OstreeMutableTree with the contents taken from the given repo - /// and checksums. The data will be loaded from the repo lazily as needed. - /// ## `repo` - /// The repo which contains the objects refered by the checksums. - /// ## `contents_checksum` - /// dirtree checksum - /// ## `metadata_checksum` - /// dirmeta checksum - /// - /// # Returns - /// - /// A new tree pub fn new_from_checksum(repo: &Repo, contents_checksum: &str, metadata_checksum: &str) -> MutableTree { unsafe { from_glib_full(ffi::ostree_mutable_tree_new_from_checksum(repo.to_glib_none().0, contents_checksum.to_glib_none().0, metadata_checksum.to_glib_none().0)) @@ -56,49 +40,14 @@ impl Default for MutableTree { } } -/// Trait containing all `MutableTree` methods. -/// -/// # Implementors -/// -/// [`MutableTree`](struct.MutableTree.html) pub trait MutableTreeExt { - /// In some cases, a tree may be in a "lazy" state that loads - /// data in the background; if an error occurred during a non-throwing - /// API call, it will have been cached. This function checks for a - /// cached error. The tree remains in error state. - /// - /// Feature: `v2018_7` - /// - /// - /// # Returns - /// - /// `TRUE` on success #[cfg(any(feature = "v2018_7", feature = "dox"))] fn check_error(&self) -> Result<(), Error>; - /// Returns the subdirectory of self with filename `name`, creating an empty one - /// it if it doesn't exist. - /// ## `name` - /// Name of subdirectory of self to retrieve/creates - /// ## `out_subdir` - /// the subdirectory fn ensure_dir(&self, name: &str) -> Result; //fn ensure_parent_dirs(&self, split_path: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 0, id: 28 }, metadata_checksum: &str) -> Result; - /// Merges `self` with the tree given by `contents_checksum` and - /// `metadata_checksum`, but only if it's possible without writing new objects to - /// the `repo`. We can do this if either `self` is empty, the tree given by - /// `contents_checksum` is empty or if both trees already have the same - /// `contents_checksum`. - /// - /// # Returns - /// - /// `true` if merge was successful, `false` if it was not possible. - /// - /// This function enables optimisations when composing trees. The provided - /// checksums are not loaded or checked when this function is called. Instead - /// the contents will be loaded only when needed. fn fill_empty_from_dirtree(&self, repo: &Repo, contents_checksum: &str, metadata_checksum: &str) -> bool; fn get_contents_checksum(&self) -> Option; diff --git a/rust-bindings/rust/libostree/src/auto/remote.rs b/rust-bindings/rust/libostree/src/auto/remote.rs index a13f42a4..51d6b49e 100644 --- a/rust-bindings/rust/libostree/src/auto/remote.rs +++ b/rust-bindings/rust/libostree/src/auto/remote.rs @@ -21,16 +21,6 @@ glib_wrapper! { } impl Remote { - /// Get the human-readable name of the remote. This is what the user configured, - /// if the remote was explicitly configured; and will otherwise be a stable, - /// arbitrary, string. - /// - /// Feature: `v2018_6` - /// - /// - /// # Returns - /// - /// remote’s name #[cfg(any(feature = "v2018_6", feature = "dox"))] pub fn get_name(&self) -> Option { unsafe { @@ -38,14 +28,6 @@ impl Remote { } } - /// Get the URL from the remote. - /// - /// Feature: `v2018_6` - /// - /// - /// # Returns - /// - /// the remote's URL #[cfg(any(feature = "v2018_6", feature = "dox"))] pub fn get_url(&self) -> Option { unsafe { diff --git a/rust-bindings/rust/libostree/src/auto/repo.rs b/rust-bindings/rust/libostree/src/auto/repo.rs index 124ddc88..fa58c00a 100644 --- a/rust-bindings/rust/libostree/src/auto/repo.rs +++ b/rust-bindings/rust/libostree/src/auto/repo.rs @@ -51,75 +51,24 @@ glib_wrapper! { } impl Repo { - /// ## `path` - /// Path to a repository - /// - /// # Returns - /// - /// An accessor object for an OSTree repository located at `path` pub fn new>(path: &P) -> Repo { unsafe { from_glib_full(ffi::ostree_repo_new(path.to_glib_none().0)) } } - /// If the current working directory appears to be an OSTree - /// repository, create a new `Repo` object for accessing it. - /// Otherwise use the path in the OSTREE_REPO environment variable - /// (if defined) or else the default system repository located at - /// /ostree/repo. - /// - /// # Returns - /// - /// An accessor object for an OSTree repository located at /ostree/repo pub fn new_default() -> Repo { unsafe { from_glib_full(ffi::ostree_repo_new_default()) } } - /// Creates a new `Repo` instance, taking the system root path explicitly - /// instead of assuming "/". - /// ## `repo_path` - /// Path to a repository - /// ## `sysroot_path` - /// Path to the system root - /// - /// # Returns - /// - /// An accessor object for the OSTree repository located at `repo_path`. pub fn new_for_sysroot_path, Q: IsA>(repo_path: &P, sysroot_path: &Q) -> Repo { unsafe { from_glib_full(ffi::ostree_repo_new_for_sysroot_path(repo_path.to_glib_none().0, sysroot_path.to_glib_none().0)) } } - /// This is a file-descriptor relative version of `RepoExt::create`. - /// Create the underlying structure on disk for the repository, and call - /// `Repo::open_at` on the result, preparing it for use. - /// - /// If a repository already exists at `dfd` + `path` (defined by an `objects/` - /// subdirectory existing), then this function will simply call - /// `Repo::open_at`. In other words, this function cannot be used to change - /// the mode or configuration (`repo/config`) of an existing repo. - /// - /// The `options` dict may contain: - /// - /// - collection-id: s: Set as collection ID in repo/config (Since 2017.9) - /// ## `dfd` - /// Directory fd - /// ## `path` - /// Path - /// ## `mode` - /// The mode to store the repository in - /// ## `options` - /// a{sv}: See below for accepted keys - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// A new OSTree repository reference pub fn create_at<'a, P: Into>>(dfd: i32, path: &str, mode: RepoMode, options: &glib::Variant, cancellable: P) -> Result { let cancellable = cancellable.into(); let cancellable = cancellable.to_glib_none(); @@ -130,17 +79,6 @@ impl Repo { } } - /// This combines `Repo::new` (but using fd-relative access) with - /// `RepoExt::open`. Use this when you know you should be operating on an - /// already extant repository. If you want to create one, use `Repo::create_at`. - /// ## `dfd` - /// Directory fd - /// ## `path` - /// Path - /// - /// # Returns - /// - /// An accessor object for an OSTree repository located at `dfd` + `path` pub fn open_at<'a, P: Into>>(dfd: i32, path: &str, cancellable: P) -> Result { let cancellable = cancellable.into(); let cancellable = cancellable.to_glib_none(); @@ -170,365 +108,73 @@ impl Repo { //} } -/// Trait containing all `Repo` methods. -/// -/// # Implementors -/// -/// [`Repo`](struct.Repo.html) pub trait RepoExt { - /// Abort the active transaction; any staged objects and ref changes will be - /// discarded. You *must* invoke this if you have chosen not to invoke - /// `RepoExt::commit_transaction`. Calling this function when not in a - /// transaction will do nothing and return successfully. - /// ## `cancellable` - /// Cancellable fn abort_transaction<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - /// Add a GPG signature to a summary file. - /// ## `key_id` - /// NULL-terminated array of GPG keys. - /// ## `homedir` - /// GPG home directory, or `None` - /// ## `cancellable` - /// A `gio::Cancellable` fn add_gpg_signature_summary<'a, 'b, P: Into>, Q: Into>>(&self, key_id: &[&str], homedir: P, cancellable: Q) -> Result<(), Error>; - /// Append a GPG signature to a commit. - /// ## `commit_checksum` - /// SHA256 of given commit to sign - /// ## `signature_bytes` - /// Signature data - /// ## `cancellable` - /// A `gio::Cancellable` fn append_gpg_signature<'a, P: Into>>(&self, commit_checksum: &str, signature_bytes: &glib::Bytes, cancellable: P) -> Result<(), Error>; //fn checkout_at<'a, 'b, P: Into>, Q: Into>>(&self, options: P, destination_dfd: i32, destination_path: &str, commit: &str, cancellable: Q) -> Result<(), Error>; - /// Call this after finishing a succession of checkout operations; it - /// will delete any currently-unused uncompressed objects from the - /// cache. - /// ## `cancellable` - /// Cancellable fn checkout_gc<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - /// Check out `source` into `destination`, which must live on the - /// physical filesystem. `source` may be any subdirectory of a given - /// commit. The `mode` and `overwrite_mode` allow control over how the - /// files are checked out. - /// ## `mode` - /// Options controlling all files - /// ## `overwrite_mode` - /// Whether or not to overwrite files - /// ## `destination` - /// Place tree here - /// ## `source` - /// Source tree - /// ## `source_info` - /// Source info - /// ## `cancellable` - /// Cancellable fn checkout_tree<'a, P: IsA, Q: Into>>(&self, mode: RepoCheckoutMode, overwrite_mode: RepoCheckoutOverwriteMode, destination: &P, source: &RepoFile, source_info: &gio::FileInfo, cancellable: Q) -> Result<(), Error>; //fn checkout_tree_at<'a, 'b, P: Into>, Q: Into>>(&self, options: P, destination_dfd: i32, destination_path: &str, commit: &str, cancellable: Q) -> Result<(), Error>; - /// Complete the transaction. Any refs set with - /// `RepoExt::transaction_set_ref` or - /// `RepoExt::transaction_set_refspec` will be written out. - /// - /// Note that if multiple threads are performing writes, all such threads must - /// have terminated before this function is invoked. - /// - /// Locking: Releases `shared` lock acquired by `ostree_repo_prepare_transaction()` - /// Multithreading: This function is *not* MT safe; only one transaction can be - /// active at a time. - /// ## `out_stats` - /// A set of statistics of things - /// that happened during this transaction. - /// ## `cancellable` - /// Cancellable fn commit_transaction<'a, P: Into>>(&self, cancellable: P) -> Result; - /// - /// # Returns - /// - /// A newly-allocated copy of the repository config fn copy_config(&self) -> Option; - /// Create the underlying structure on disk for the repository, and call - /// `RepoExt::open` on the result, preparing it for use. - /// - /// Since version 2016.8, this function will succeed on an existing - /// repository, and finish creating any necessary files in a partially - /// created repository. However, this function cannot change the mode - /// of an existing repository, and will silently ignore an attempt to - /// do so. - /// - /// Since 2017.9, "existing repository" is defined by the existence of an - /// `objects` subdirectory. - /// - /// This function predates `Repo::create_at`. It is an error to call - /// this function on a repository initialized via `Repo::open_at`. - /// ## `mode` - /// The mode to store the repository in - /// ## `cancellable` - /// Cancellable fn create<'a, P: Into>>(&self, mode: RepoMode, cancellable: P) -> Result<(), Error>; - /// Remove the object of type `objtype` with checksum `sha256` - /// from the repository. An error of type `gio::IOErrorEnum::NotFound` - /// is thrown if the object does not exist. - /// ## `objtype` - /// Object type - /// ## `sha256` - /// Checksum - /// ## `cancellable` - /// Cancellable fn delete_object<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result<(), Error>; - /// Check whether two opened repositories are the same on disk: if their root - /// directories are the same inode. If `self` or `b` are not open yet (due to - /// `RepoExt::open` not being called on them yet), `false` will be returned. - /// - /// Feature: `v2017_12` - /// - /// ## `b` - /// an `Repo` - /// - /// # Returns - /// - /// `true` if `self` and `b` are the same repository on disk, `false` otherwise #[cfg(any(feature = "v2017_12", feature = "dox"))] fn equal(&self, b: &Repo) -> bool; //fn export_tree_to_archive<'a, P: Into>, Q: Into>>(&self, opts: /*Ignored*/&mut RepoExportArchiveOptions, root: &RepoFile, archive: P, cancellable: Q) -> Result<(), Error>; - /// Verify consistency of the object; this performs checks only relevant to the - /// immediate object itself, such as checksumming. This API call will not itself - /// traverse metadata objects for example. - /// - /// Feature: `v2017_15` - /// - /// ## `objtype` - /// Object type - /// ## `sha256` - /// Checksum - /// ## `cancellable` - /// Cancellable #[cfg(any(feature = "v2017_15", feature = "dox"))] fn fsck_object<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result<(), Error>; - /// Get the collection ID of this repository. See [collection IDs][collection-ids]. - /// - /// Feature: `v2018_6` - /// - /// - /// # Returns - /// - /// collection ID for the repository #[cfg(any(feature = "v2018_6", feature = "dox"))] fn get_collection_id(&self) -> Option; - /// - /// # Returns - /// - /// The repository configuration; do not modify fn get_config(&self) -> Option; - /// In some cases it's useful for applications to access the repository - /// directly; for example, writing content into `repo/tmp` ensures it's - /// on the same filesystem. Another case is detecting the mtime on the - /// repository (to see whether a ref was written). - /// - /// # Returns - /// - /// File descriptor for repository root - owned by `self` fn get_dfd(&self) -> i32; - /// For more information see `RepoExt::set_disable_fsync`. - /// - /// # Returns - /// - /// Whether or not `fsync` is enabled for this repo. fn get_disable_fsync(&self) -> bool; fn get_mode(&self) -> RepoMode; - /// Before this function can be used, `ostree_repo_init` must have been - /// called. - /// - /// # Returns - /// - /// Parent repository, or `None` if none fn get_parent(&self) -> Option; - /// Note that since the introduction of `Repo::open_at`, this function may - /// return a process-specific path in `/proc` if the repository was created using - /// that API. In general, you should avoid use of this API. - /// - /// # Returns - /// - /// Path to repo fn get_path(&self) -> Option; - /// OSTree remotes are represented by keyfile groups, formatted like: - /// `[remote "remotename"]`. This function returns a value named `option_name` - /// underneath that group, and returns it as a boolean. - /// If the option is not set, `out_value` will be set to `default_value`. If an - /// error is returned, `out_value` will be set to `false`. - /// ## `remote_name` - /// Name - /// ## `option_name` - /// Option - /// ## `default_value` - /// Value returned if `option_name` is not present - /// ## `out_value` - /// location to store the result. - /// - /// # Returns - /// - /// `true` on success, otherwise `false` with `error` set fn get_remote_boolean_option(&self, remote_name: &str, option_name: &str, default_value: bool) -> Result; - /// OSTree remotes are represented by keyfile groups, formatted like: - /// `[remote "remotename"]`. This function returns a value named `option_name` - /// underneath that group, and returns it as a zero terminated array of strings. - /// If the option is not set, or if an error is returned, `out_value` will be set - /// to `None`. - /// ## `remote_name` - /// Name - /// ## `option_name` - /// Option - /// ## `out_value` - /// location to store the list - /// of strings. The list should be freed with - /// `g_strfreev`. - /// - /// # Returns - /// - /// `true` on success, otherwise `false` with `error` set fn get_remote_list_option(&self, remote_name: &str, option_name: &str) -> Result, Error>; - /// OSTree remotes are represented by keyfile groups, formatted like: - /// `[remote "remotename"]`. This function returns a value named `option_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 `None`. - /// ## `remote_name` - /// Name - /// ## `option_name` - /// Option - /// ## `default_value` - /// Value returned if `option_name` is not present - /// ## `out_value` - /// Return location for value - /// - /// # Returns - /// - /// `true` on success, otherwise `false` with `error` set fn get_remote_option<'a, P: Into>>(&self, remote_name: &str, option_name: &str, default_value: P) -> Result; - /// Verify `signatures` for `data` using GPG keys in the keyring for - /// `remote_name`, and return an `GpgVerifyResult`. - /// - /// The `remote_name` parameter can be `None`. In that case it will do - /// the verifications using GPG keys in the keyrings of all remotes. - /// ## `remote_name` - /// Name of remote - /// ## `data` - /// Data as a `glib::Bytes` - /// ## `signatures` - /// Signatures as a `glib::Bytes` - /// ## `keyringdir` - /// Path to directory GPG keyrings; overrides built-in default if given - /// ## `extra_keyring` - /// Path to additional keyring file (not a directory) - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// an `GpgVerifyResult`, or `None` on error fn gpg_verify_data<'a, 'b, 'c, 'd, P: Into>, Q: IsA + 'b, R: Into>, S: IsA + 'c, T: Into>, U: Into>>(&self, remote_name: P, data: &glib::Bytes, signatures: &glib::Bytes, keyringdir: R, extra_keyring: T, cancellable: U) -> Result; - /// Set `out_have_object` to `true` if `self` contains the given object; - /// `false` otherwise. - /// ## `objtype` - /// Object type - /// ## `checksum` - /// ASCII SHA256 checksum - /// ## `out_have_object` - /// `true` if repository contains object - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// `false` if an unexpected error occurred, `true` otherwise fn has_object<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, cancellable: P) -> Result; - /// Calculate a hash value for the given open repository, suitable for use when - /// putting it into a hash table. It is an error to call this on an `Repo` - /// which is not yet open, as a persistent hash value cannot be calculated until - /// the repository is open and the inode of its root directory has been loaded. - /// - /// This function does no I/O. - /// - /// Feature: `v2017_12` - /// - /// - /// # Returns - /// - /// hash value for the `Repo` #[cfg(any(feature = "v2017_12", feature = "dox"))] fn hash(&self) -> u32; //fn import_archive_to_mtree<'a, 'b, P: Into>, Q: Into>, R: Into>>(&self, opts: /*Ignored*/&mut RepoImportArchiveOptions, archive: P, mtree: &MutableTree, modifier: Q, cancellable: R) -> Result<(), Error>; - /// Copy object named by `objtype` and `checksum` into `self` from the - /// source repository `source`. If both repositories are of the same - /// type and on the same filesystem, this will simply be a fast Unix - /// hard link operation. - /// - /// Otherwise, a copy will be performed. - /// ## `source` - /// Source repo - /// ## `objtype` - /// Object type - /// ## `checksum` - /// checksum - /// ## `cancellable` - /// Cancellable fn import_object_from<'a, P: Into>>(&self, source: &Repo, objtype: ObjectType, checksum: &str, cancellable: P) -> Result<(), Error>; - /// Copy object named by `objtype` and `checksum` into `self` from the - /// source repository `source`. If both repositories are of the same - /// type and on the same filesystem, this will simply be a fast Unix - /// hard link operation. - /// - /// Otherwise, a copy will be performed. - /// ## `source` - /// Source repo - /// ## `objtype` - /// Object type - /// ## `checksum` - /// checksum - /// ## `trusted` - /// If `true`, assume the source repo is valid and trusted - /// ## `cancellable` - /// Cancellable fn import_object_from_with_trust<'a, P: Into>>(&self, source: &Repo, objtype: ObjectType, checksum: &str, trusted: bool, cancellable: P) -> Result<(), Error>; - /// - /// # Returns - /// - /// `true` if this repository is the root-owned system global repository fn is_system(&self) -> bool; - /// Returns whether the repository is writable by the current user. - /// If the repository is not writable, the `error` indicates why. - /// - /// # Returns - /// - /// `true` if this repository is writable fn is_writable(&self) -> Result<(), Error>; //#[cfg(any(feature = "v2018_6", feature = "dox"))] @@ -544,448 +190,62 @@ pub trait RepoExt { //fn list_static_delta_names<'a, P: Into>>(&self, out_deltas: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 0, id: 28 }, cancellable: P) -> Result<(), Error>; - /// A version of `RepoExt::load_variant` specialized to commits, - /// capable of returning extended state information. Currently - /// the only extended state is `RepoCommitState::Partial`, which - /// means that only a sub-path of the commit is available. - /// - /// Feature: `v2015_7` - /// - /// ## `checksum` - /// Commit checksum - /// ## `out_commit` - /// Commit - /// ## `out_state` - /// Commit state #[cfg(any(feature = "v2015_7", feature = "dox"))] fn load_commit(&self, checksum: &str) -> Result<(glib::Variant, RepoCommitState), Error>; - /// Load content object, decomposing it into three parts: the actual - /// content (for regular files), the metadata, and extended attributes. - /// ## `checksum` - /// ASCII SHA256 checksum - /// ## `out_input` - /// File content - /// ## `out_file_info` - /// File information - /// ## `out_xattrs` - /// Extended attributes - /// ## `cancellable` - /// Cancellable fn load_file<'a, P: Into>>(&self, checksum: &str, cancellable: P) -> Result<(Option, Option, Option), Error>; - /// Load object as a stream; useful when copying objects between - /// repositories. - /// ## `objtype` - /// Object type - /// ## `checksum` - /// ASCII SHA256 checksum - /// ## `out_input` - /// Stream for object - /// ## `out_size` - /// Length of `out_input` - /// ## `cancellable` - /// Cancellable fn load_object_stream<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, cancellable: P) -> Result<(gio::InputStream, u64), Error>; - /// Load the metadata object `sha256` of type `objtype`, storing the - /// result in `out_variant`. - /// ## `objtype` - /// Expected object type - /// ## `sha256` - /// Checksum string - /// ## `out_variant` - /// Metadata object fn load_variant(&self, objtype: ObjectType, sha256: &str) -> Result; - /// Attempt to load the metadata object `sha256` of type `objtype` if it - /// exists, storing the result in `out_variant`. If it doesn't exist, - /// `None` is returned. - /// ## `objtype` - /// Object type - /// ## `sha256` - /// ASCII checksum - /// ## `out_variant` - /// Metadata fn load_variant_if_exists(&self, objtype: ObjectType, sha256: &str) -> Result; - /// Commits in "partial" state do not have all their child objects written. This - /// occurs in various situations, such as during a pull, but also if a "subpath" - /// pull is used, as well as "commit only" pulls. - /// - /// This function is used by `RepoExt::pull_with_options`; you - /// should use this if you are implementing a different type of transport. - /// - /// Feature: `v2017_15` - /// - /// ## `checksum` - /// Commit SHA-256 - /// ## `is_partial` - /// Whether or not this commit is partial #[cfg(any(feature = "v2017_15", feature = "dox"))] fn mark_commit_partial(&self, checksum: &str, is_partial: bool) -> Result<(), Error>; fn open<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - /// Starts or resumes a transaction. In order to write to a repo, you - /// need to start a transaction. You can complete the transaction with - /// `RepoExt::commit_transaction`, or abort the transaction with - /// `RepoExt::abort_transaction`. - /// - /// Currently, transactions may result in partial commits or data in the target - /// repository if interrupted during `RepoExt::commit_transaction`, and - /// further writing refs is also not currently atomic. - /// - /// There can be at most one transaction active on a repo at a time per instance - /// of `OstreeRepo`; however, it is safe to have multiple threads writing objects - /// on a single `OstreeRepo` instance as long as their lifetime is bounded by the - /// transaction. - /// - /// Locking: Acquires a `shared` lock; release via commit or abort - /// Multithreading: This function is *not* MT safe; only one transaction can be - /// active at a time. - /// ## `out_transaction_resume` - /// Whether this transaction - /// is resuming from a previous one. This is a legacy state, now OSTree - /// pulls use per-commit `state/.commitpartial` files. - /// ## `cancellable` - /// Cancellable fn prepare_transaction<'a, P: Into>>(&self, cancellable: P) -> Result; - /// Delete content from the repository. By default, this function will - /// only delete "orphaned" objects not referred to by any commit. This - /// can happen during a local commit operation, when we have written - /// content objects but not saved the commit referencing them. - /// - /// However, if `RepoPruneFlags::RefsOnly` is provided, instead - /// of traversing all commits, only refs will be used. Particularly - /// when combined with `depth`, this is a convenient way to delete - /// history from the repository. - /// - /// Use the `RepoPruneFlags::NoPrune` to just determine - /// statistics on objects that would be deleted, without actually - /// deleting them. - /// - /// Locking: exclusive - /// ## `flags` - /// Options controlling prune process - /// ## `depth` - /// Stop traversal after this many iterations (-1 for unlimited) - /// ## `out_objects_total` - /// Number of objects found - /// ## `out_objects_pruned` - /// Number of objects deleted - /// ## `out_pruned_object_size_total` - /// Storage size in bytes of objects deleted - /// ## `cancellable` - /// Cancellable fn prune<'a, P: Into>>(&self, flags: RepoPruneFlags, depth: i32, cancellable: P) -> Result<(i32, i32, u64), Error>; //fn prune_from_reachable<'a, P: Into>>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: P) -> Result<(i32, i32, u64), Error>; - /// Prune static deltas, if COMMIT is specified then delete static delta files only - /// targeting that commit; otherwise any static delta of non existing commits are - /// deleted. - /// - /// Locking: exclusive - /// ## `commit` - /// ASCII SHA256 checksum for commit, or `None` for each - /// non existing commit - /// ## `cancellable` - /// Cancellable fn prune_static_deltas<'a, 'b, P: Into>, Q: Into>>(&self, commit: P, cancellable: Q) -> Result<(), Error>; - /// Connect to the remote repository, fetching the specified set of - /// refs `refs_to_fetch`. For each ref that is changed, download the - /// commit, all metadata, and all content objects, storing them safely - /// on disk in `self`. - /// - /// If `flags` contains `RepoPullFlags::Mirror`, and - /// the `refs_to_fetch` is `None`, and the remote repository contains a - /// summary file, then all refs will be fetched. - /// - /// If `flags` contains `RepoPullFlags::CommitOnly`, then only the - /// metadata for the commits in `refs_to_fetch` is pulled. - /// - /// Warning: This API will iterate the thread default main context, - /// which is a bug, but kept for compatibility reasons. If you want to - /// avoid this, use `glib::MainContext::push_thread_default` to push a new - /// one around this call. - /// ## `remote_name` - /// Name of remote - /// ## `refs_to_fetch` - /// Optional list of refs; if `None`, fetch all configured refs - /// ## `flags` - /// Options controlling fetch behavior - /// ## `progress` - /// Progress - /// ## `cancellable` - /// Cancellable fn pull<'a, 'b, P: Into>, Q: Into>>(&self, remote_name: &str, refs_to_fetch: &[&str], flags: RepoPullFlags, progress: P, cancellable: Q) -> Result<(), Error>; - /// This is similar to `RepoExt::pull`, but only fetches a single - /// subpath. - /// ## `remote_name` - /// Name of remote - /// ## `dir_to_pull` - /// Subdirectory path - /// ## `refs_to_fetch` - /// Optional list of refs; if `None`, fetch all configured refs - /// ## `flags` - /// Options controlling fetch behavior - /// ## `progress` - /// Progress - /// ## `cancellable` - /// Cancellable fn pull_one_dir<'a, 'b, P: Into>, Q: Into>>(&self, remote_name: &str, dir_to_pull: &str, refs_to_fetch: &[&str], flags: RepoPullFlags, progress: P, cancellable: Q) -> Result<(), Error>; - /// Like `RepoExt::pull`, but supports an extensible set of flags. - /// The following are currently defined: - /// - /// * refs (as): Array of string refs - /// * collection-refs (a(sss)): Array of (collection ID, ref name, checksum) tuples to pull; - /// mutually exclusive with `refs` and `override-commit-ids`. Checksums may be the empty - /// string to pull the latest commit for that ref - /// * flags (i): An instance of `RepoPullFlags` - /// * subdir (s): Pull just this subdirectory - /// * subdirs (as): Pull just these subdirectories - /// * override-remote-name (s): If local, add this remote to refspec - /// * gpg-verify (b): GPG verify commits - /// * gpg-verify-summary (b): GPG verify summary - /// * depth (i): How far in the history to traverse; default is 0, -1 means infinite - /// * disable-static-deltas (b): Do not use static deltas - /// * require-static-deltas (b): Require static deltas - /// * override-commit-ids (as): Array of specific commit IDs to fetch for refs - /// * timestamp-check (b): Verify commit timestamps are newer than current (when pulling via ref); Since: 2017.11 - /// * dry-run (b): Only print information on what will be downloaded (requires static deltas) - /// * override-url (s): Fetch objects from this URL if remote specifies no metalink in options - /// * inherit-transaction (b): Don't initiate, finish or abort a transaction, useful to do multiple pulls in one transaction. - /// * http-headers (a(ss)): Additional headers to add to all HTTP requests - /// * update-frequency (u): Frequency to call the async progress callback in milliseconds, if any; only values higher than 0 are valid - /// * localcache-repos (as): File paths for local repos to use as caches when doing remote fetches - /// * append-user-agent (s): Additional string to append to the user agent - /// * n-network-retries (u): Number of times to retry each download on receiving - /// a transient network error, such as a socket timeout; default is 5, 0 - /// means return errors without retrying - /// ## `remote_name_or_baseurl` - /// Name of remote or file:// url - /// ## `options` - /// A GVariant a{sv} with an extensible set of flags. - /// ## `progress` - /// Progress - /// ## `cancellable` - /// Cancellable fn pull_with_options<'a, 'b, P: Into>, Q: Into>>(&self, remote_name_or_baseurl: &str, options: &glib::Variant, progress: P, cancellable: Q) -> Result<(), Error>; - /// Return the size in bytes of object with checksum `sha256`, after any - /// compression has been applied. - /// ## `objtype` - /// Object type - /// ## `sha256` - /// Checksum - /// ## `out_size` - /// Size in bytes object occupies physically - /// ## `cancellable` - /// Cancellable fn query_object_storage_size<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result; - /// Load the content for `rev` into `out_root`. - /// ## `ref_` - /// Ref or ASCII checksum - /// ## `out_root` - /// An `RepoFile` corresponding to the root - /// ## `out_commit` - /// The resolved commit checksum - /// ## `cancellable` - /// Cancellable fn read_commit<'a, P: Into>>(&self, ref_: &str, cancellable: P) -> Result<(gio::File, String), Error>; - /// OSTree commits can have arbitrary metadata associated; this - /// function retrieves them. If none exists, `out_metadata` will be set - /// to `None`. - /// ## `checksum` - /// ASCII SHA256 commit checksum - /// ## `out_metadata` - /// Metadata associated with commit in with format "a{sv}", or `None` if none exists - /// ## `cancellable` - /// Cancellable fn read_commit_detached_metadata<'a, P: Into>>(&self, checksum: &str, cancellable: P) -> Result; - /// An OSTree repository can contain a high level "summary" file that - /// describes the available branches and other metadata. - /// - /// If the timetable for making commits and updating the summary file is fairly - /// regular, setting the `ostree.summary.expires` key in `additional_metadata` - /// will aid clients in working out when to check for updates. - /// - /// It is regenerated automatically after any ref is - /// added, removed, or updated if `core/auto-update-summary` is set. - /// - /// If the `core/collection-id` key is set in the configuration, it will be - /// included as `OSTREE_SUMMARY_COLLECTION_ID` in the summary file. Refs that - /// have associated collection IDs will be included in the generated summary - /// file, listed under the `OSTREE_SUMMARY_COLLECTION_MAP` key. Collection IDs - /// and refs in `OSTREE_SUMMARY_COLLECTION_MAP` are guaranteed to be in - /// lexicographic order. - /// - /// Locking: exclusive - /// ## `additional_metadata` - /// A GVariant of type a{sv}, or `None` - /// ## `cancellable` - /// Cancellable fn regenerate_summary<'a, 'b, P: Into>, Q: Into>>(&self, additional_metadata: P, cancellable: Q) -> Result<(), Error>; - /// By default, an `Repo` will cache the remote configuration and its - /// own repo/config data. This API can be used to reload it. - /// ## `cancellable` - /// cancellable fn reload_config<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - /// Create a new remote named `name` pointing to `url`. If `options` is - /// provided, then it will be mapped to `glib::KeyFile` entries, where the - /// GVariant dictionary key is an option string, and the value is - /// mapped as follows: - /// * s: `glib::KeyFile::set_string` - /// * b: `glib::KeyFile::set_boolean` - /// * as: `glib::KeyFile::set_string_list` - /// ## `name` - /// Name of remote - /// ## `url` - /// URL for remote (if URL begins with metalink=, it will be used as such) - /// ## `options` - /// GVariant of type a{sv} - /// ## `cancellable` - /// Cancellable fn remote_add<'a, 'b, P: Into>, Q: Into>>(&self, name: &str, url: &str, options: P, cancellable: Q) -> Result<(), Error>; - /// A combined function handling the equivalent of - /// `RepoExt::remote_add`, `RepoExt::remote_delete`, with more - /// options. - /// ## `sysroot` - /// System root - /// ## `changeop` - /// Operation to perform - /// ## `name` - /// Name of remote - /// ## `url` - /// URL for remote (if URL begins with metalink=, it will be used as such) - /// ## `options` - /// GVariant of type a{sv} - /// ## `cancellable` - /// Cancellable fn remote_change<'a, 'b, 'c, P: IsA + 'a, Q: Into>, R: Into>, S: Into>>(&self, sysroot: Q, changeop: RepoRemoteChange, name: &str, url: &str, options: R, cancellable: S) -> Result<(), Error>; - /// Delete the remote named `name`. It is an error if the provided - /// remote does not exist. - /// ## `name` - /// Name of remote - /// ## `cancellable` - /// Cancellable fn remote_delete<'a, P: Into>>(&self, name: &str, cancellable: P) -> Result<(), Error>; - /// Tries to fetch the summary file and any GPG signatures on the summary file - /// over HTTP, and returns the binary data in `out_summary` and `out_signatures` - /// respectively. - /// - /// If no summary file exists on the remote server, `out_summary` is set to - /// `None`. Likewise if the summary file is not signed, `out_signatures` is - /// set to `None`. In either case the function still returns `true`. - /// - /// This method does not verify the signature of the downloaded summary file. - /// Use `RepoExt::verify_summary` for that. - /// - /// Parse the summary data into a `glib::Variant` using `glib::Variant::new_from_bytes` - /// with `OSTREE_SUMMARY_GVARIANT_FORMAT` as the format string. - /// ## `name` - /// name of a remote - /// ## `out_summary` - /// return location for raw summary data, or - /// `None` - /// ## `out_signatures` - /// return location for raw summary - /// signature data, or `None` - /// ## `cancellable` - /// a `gio::Cancellable` - /// - /// # Returns - /// - /// `true` on success, `false` on failure fn remote_fetch_summary<'a, P: Into>>(&self, name: &str, cancellable: P) -> Result<(glib::Bytes, glib::Bytes), Error>; - /// Like `RepoExt::remote_fetch_summary`, but supports an extensible set of flags. - /// The following are currently defined: - /// - /// - override-url (s): Fetch summary from this URL if remote specifies no metalink in options - /// - http-headers (a(ss)): Additional headers to add to all HTTP requests - /// - append-user-agent (s): Additional string to append to the user agent - /// - n-network-retries (u): Number of times to retry each download on receiving - /// a transient network error, such as a socket timeout; default is 5, 0 - /// means return errors without retrying - /// ## `name` - /// name of a remote - /// ## `options` - /// A GVariant a{sv} with an extensible set of flags - /// ## `out_summary` - /// return location for raw summary data, or - /// `None` - /// ## `out_signatures` - /// return location for raw summary - /// signature data, or `None` - /// ## `cancellable` - /// a `gio::Cancellable` - /// - /// # Returns - /// - /// `true` on success, `false` on failure fn remote_fetch_summary_with_options<'a, 'b, P: Into>, Q: Into>>(&self, name: &str, options: P, cancellable: Q) -> Result<(glib::Bytes, glib::Bytes), Error>; - /// Return whether GPG verification is enabled for the remote named `name` - /// through `out_gpg_verify`. It is an error if the provided remote does - /// not exist. - /// ## `name` - /// Name of remote - /// ## `out_gpg_verify` - /// Remote's GPG option - /// - /// # Returns - /// - /// `true` on success, `false` on failure fn remote_get_gpg_verify(&self, name: &str) -> Result; - /// Return whether GPG verification of the summary is enabled for the remote - /// named `name` through `out_gpg_verify_summary`. It is an error if the provided - /// remote does not exist. - /// ## `name` - /// Name of remote - /// ## `out_gpg_verify_summary` - /// Remote's GPG option - /// - /// # Returns - /// - /// `true` on success, `false` on failure fn remote_get_gpg_verify_summary(&self, name: &str) -> Result; - /// Return the URL of the remote named `name` through `out_url`. It is an - /// error if the provided remote does not exist. - /// ## `name` - /// Name of remote - /// ## `out_url` - /// Remote's URL - /// - /// # Returns - /// - /// `true` on success, `false` on failure fn remote_get_url(&self, name: &str) -> Result; - /// List available remote names in an `Repo`. Remote names are sorted - /// alphabetically. If no remotes are available the function returns `None`. - /// ## `out_n_remotes` - /// Number of remotes available - /// - /// # Returns - /// - /// a `None`-terminated - /// array of remote names fn remote_list(&self) -> Vec; //#[cfg(any(feature = "v2018_6", feature = "dox"))] @@ -993,316 +253,45 @@ pub trait RepoExt { //fn remote_list_refs<'a, P: Into>>(&self, remote_name: &str, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: P) -> Result<(), Error>; - /// Look up the checksum for the given collection–ref, returning it in `out_rev`. - /// This will search through the mirrors and remote refs. - /// - /// If `allow_noent` is `true` and the given `ref_` cannot be found, `true` will be - /// returned and `out_rev` will be set to `None`. If `allow_noent` is `false` and - /// the given `ref_` cannot be found, a `gio::IOErrorEnum::NotFound` error will be - /// returned. - /// - /// There are currently no `flags` which affect the behaviour of this function. - /// - /// Feature: `v2018_6` - /// - /// ## `ref_` - /// a collection–ref to resolve - /// ## `allow_noent` - /// `true` to not throw an error if `ref_` doesn’t exist - /// ## `flags` - /// options controlling behaviour - /// ## `out_rev` - /// return location for - /// the checksum corresponding to `ref_`, or `None` if `allow_noent` is `true` and - /// the `ref_` could not be found - /// ## `cancellable` - /// a `gio::Cancellable`, or `None` - /// - /// # Returns - /// - /// `true` on success, `false` on failure #[cfg(any(feature = "v2018_6", feature = "dox"))] fn resolve_collection_ref<'a, P: Into>>(&self, ref_: &CollectionRef, allow_noent: bool, flags: RepoResolveRevExtFlags, cancellable: P) -> Result, Error>; - /// Find the GPG keyring for the given `collection_id`, using the local - /// configuration from the given `Repo`. This will search the configured - /// remotes for ones whose `collection-id` key matches `collection_id`, and will - /// return the first matching remote. - /// - /// If multiple remotes match and have different keyrings, a debug message will - /// be emitted, and the first result will be returned. It is expected that the - /// keyrings should match. - /// - /// If no match can be found, a `gio::IOErrorEnum::NotFound` error will be returned. - /// - /// Feature: `v2018_6` - /// - /// ## `collection_id` - /// the collection ID to look up a keyring for - /// ## `cancellable` - /// a `gio::Cancellable`, or `None` - /// - /// # Returns - /// - /// `Remote` containing the GPG keyring for - /// `collection_id` #[cfg(any(feature = "v2018_6", feature = "dox"))] fn resolve_keyring_for_collection<'a, P: Into>>(&self, collection_id: &str, cancellable: P) -> Result; - /// Look up the given refspec, returning the checksum it references in - /// the parameter `out_rev`. Will fall back on remote directory if cannot - /// find the given refspec in local. - /// ## `refspec` - /// A refspec - /// ## `allow_noent` - /// Do not throw an error if refspec does not exist - /// ## `out_rev` - /// A checksum,or `None` if `allow_noent` is true and it does not exist fn resolve_rev(&self, refspec: &str, allow_noent: bool) -> Result; - /// Look up the given refspec, returning the checksum it references in - /// the parameter `out_rev`. Differently from `RepoExt::resolve_rev`, - /// this will not fall back to searching through remote repos if a - /// local ref is specified but not found. - /// ## `refspec` - /// A refspec - /// ## `allow_noent` - /// Do not throw an error if refspec does not exist - /// ## `flags` - /// Options controlling behavior - /// ## `out_rev` - /// A checksum,or `None` if `allow_noent` is true and it does not exist fn resolve_rev_ext(&self, refspec: &str, allow_noent: bool, flags: RepoResolveRevExtFlags) -> Result; - /// This function is deprecated in favor of using `RepoDevInoCache::new`, - /// which allows a precise mapping to be built up between hardlink checkout files - /// and their checksums between `ostree_repo_checkout_at()` and - /// `ostree_repo_write_directory_to_mtree()`. - /// - /// When invoking `RepoExt::write_directory_to_mtree`, it has to compute the - /// checksum of all files. If your commit contains hardlinks from a checkout, - /// this functions builds a mapping of device numbers and inodes to their - /// checksum. - /// - /// There is an upfront cost to creating this mapping, as this will scan the - /// entire objects directory. If your commit is composed of mostly hardlinks to - /// existing ostree objects, then this will speed up considerably, so call it - /// before you call `RepoExt::write_directory_to_mtree` or similar. However, - /// `RepoDevInoCache::new` is better as it avoids scanning all objects. - /// - /// Multithreading: This function is *not* MT safe. - /// ## `cancellable` - /// Cancellable fn scan_hardlinks<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - /// Like `RepoExt::set_ref_immediate`, but creates an alias. - /// ## `remote` - /// A remote for the ref - /// ## `ref_` - /// The ref to write - /// ## `target` - /// The ref target to point it to, or `None` to unset - /// ## `cancellable` - /// GCancellable fn set_alias_ref_immediate<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, remote: P, ref_: &str, target: Q, cancellable: R) -> Result<(), Error>; - /// Set a custom location for the cache directory used for e.g. - /// per-remote summary caches. Setting this manually is useful when - /// doing operations on a system repo as a user because you don't have - /// write permissions in the repo, where the cache is normally stored. - /// ## `dfd` - /// directory fd - /// ## `path` - /// subpath in `dfd` - /// ## `cancellable` - /// a `gio::Cancellable` fn set_cache_dir<'a, P: Into>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error>; - /// Set or clear the collection ID of this repository. See [collection IDs][collection-ids]. - /// The update will be made in memory, but must be written out to the repository - /// configuration on disk using `RepoExt::write_config`. - /// - /// Feature: `v2018_6` - /// - /// ## `collection_id` - /// new collection ID, or `None` to unset it - /// - /// # Returns - /// - /// `true` on success, `false` otherwise #[cfg(any(feature = "v2018_6", feature = "dox"))] fn set_collection_id<'a, P: Into>>(&self, collection_id: P) -> Result<(), Error>; - /// This is like `RepoExt::transaction_set_collection_ref`, except it may be - /// invoked outside of a transaction. This is presently safe for the - /// case where we're creating or overwriting an existing ref. - /// - /// Feature: `v2018_6` - /// - /// ## `ref_` - /// The collection–ref to write - /// ## `checksum` - /// The checksum to point it to, or `None` to unset - /// ## `cancellable` - /// GCancellable - /// - /// # Returns - /// - /// `true` on success, `false` otherwise #[cfg(any(feature = "v2018_6", feature = "dox"))] fn set_collection_ref_immediate<'a, 'b, P: Into>, Q: Into>>(&self, ref_: &CollectionRef, checksum: P, cancellable: Q) -> Result<(), Error>; - /// Disable requests to `fsync` to stable storage during commits. This - /// option should only be used by build system tools which are creating - /// disposable virtual machines, or have higher level mechanisms for - /// ensuring data consistency. - /// ## `disable_fsync` - /// If `true`, do not fsync fn set_disable_fsync(&self, disable_fsync: bool); - /// This is like `RepoExt::transaction_set_ref`, except it may be - /// invoked outside of a transaction. This is presently safe for the - /// case where we're creating or overwriting an existing ref. - /// - /// Multithreading: This function is MT safe. - /// ## `remote` - /// A remote for the ref - /// ## `ref_` - /// The ref to write - /// ## `checksum` - /// The checksum to point it to, or `None` to unset - /// ## `cancellable` - /// GCancellable fn set_ref_immediate<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, remote: P, ref_: &str, checksum: Q, cancellable: R) -> Result<(), Error>; - /// Add a GPG signature to a commit. - /// ## `commit_checksum` - /// SHA256 of given commit to sign - /// ## `key_id` - /// Use this GPG key id - /// ## `homedir` - /// GPG home directory, or `None` - /// ## `cancellable` - /// A `gio::Cancellable` fn sign_commit<'a, 'b, P: Into>, Q: Into>>(&self, commit_checksum: &str, key_id: &str, homedir: P, cancellable: Q) -> Result<(), Error>; - /// This function is deprecated, sign the summary file instead. - /// Add a GPG signature to a static delta. - /// ## `from_commit` - /// From commit - /// ## `to_commit` - /// To commit - /// ## `key_id` - /// key id - /// ## `homedir` - /// homedir - /// ## `cancellable` - /// cancellable fn sign_delta<'a, P: Into>>(&self, from_commit: &str, to_commit: &str, key_id: &str, homedir: &str, cancellable: P) -> Result<(), Error>; - /// Given a directory representing an already-downloaded static delta - /// on disk, apply it, generating a new commit. The directory must be - /// named with the form "FROM-TO", where both are checksums, and it - /// must contain a file named "superblock", along with at least one part. - /// ## `dir_or_file` - /// Path to a directory containing static delta data, or directly to the superblock - /// ## `skip_validation` - /// If `true`, assume data integrity - /// ## `cancellable` - /// Cancellable fn static_delta_execute_offline<'a, P: IsA, Q: Into>>(&self, dir_or_file: &P, skip_validation: bool, cancellable: Q) -> Result<(), Error>; - /// Generate a lookaside "static delta" from `from` (`None` means - /// from-empty) which can generate the objects in `to`. This delta is - /// an optimization over fetching individual objects, and can be - /// conveniently stored and applied offline. - /// - /// The `params` argument should be an a{sv}. The following attributes - /// are known: - /// - min-fallback-size: u: Minimum uncompressed size in megabytes to use fallback, 0 to disable fallbacks - /// - max-chunk-size: u: Maximum size in megabytes of a delta part - /// - max-bsdiff-size: u: Maximum size in megabytes to consider bsdiff compression - /// for input files - /// - compression: y: Compression type: 0=none, x=lzma, g=gzip - /// - bsdiff-enabled: b: Enable bsdiff compression. Default TRUE. - /// - inline-parts: b: Put part data in header, to get a single file delta. Default FALSE. - /// - verbose: b: Print diagnostic messages. Default FALSE. - /// - endianness: b: Deltas use host byte order by default; this option allows choosing (G_BIG_ENDIAN or G_LITTLE_ENDIAN) - /// - filename: ay: Save delta superblock to this filename, and parts in the same directory. Default saves to repository. - /// ## `opt` - /// High level optimization choice - /// ## `from` - /// ASCII SHA256 checksum of origin, or `None` - /// ## `to` - /// ASCII SHA256 checksum of target - /// ## `metadata` - /// Optional metadata - /// ## `params` - /// Parameters, see below - /// ## `cancellable` - /// Cancellable fn static_delta_generate<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, opt: StaticDeltaGenerateOpt, from: &str, to: &str, metadata: P, params: Q, cancellable: R) -> Result<(), Error>; - /// If `checksum` is not `None`, then record it as the target of local ref named - /// `ref_`. - /// - /// Otherwise, if `checksum` is `None`, then record that the ref should - /// be deleted. - /// - /// The change will not be written out immediately, but when the transaction - /// is completed with `RepoExt::commit_transaction`. If the transaction - /// is instead aborted with `RepoExt::abort_transaction`, no changes will - /// be made to the repository. - /// - /// Multithreading: Since v2017.15 this function is MT safe. - /// - /// Feature: `v2018_6` - /// - /// ## `ref_` - /// The collection–ref to write - /// ## `checksum` - /// The checksum to point it to #[cfg(any(feature = "v2018_6", feature = "dox"))] fn transaction_set_collection_ref<'a, P: Into>>(&self, ref_: &CollectionRef, checksum: P); - /// If `checksum` is not `None`, then record it as the target of ref named - /// `ref_`; if `remote` is provided, the ref will appear to originate from that - /// remote. - /// - /// Otherwise, if `checksum` is `None`, then record that the ref should - /// be deleted. - /// - /// The change will be written when the transaction is completed with - /// `RepoExt::commit_transaction`; that function takes care of writing all of - /// the objects (such as the commit referred to by `checksum`) before updating the - /// refs. If the transaction is instead aborted with - /// `RepoExt::abort_transaction`, no changes to the ref will be made to the - /// repository. - /// - /// Note however that currently writing *multiple* refs is not truly atomic; if - /// the process or system is terminated during - /// `RepoExt::commit_transaction`, it is possible that just some of the refs - /// will have been updated. Your application should take care to handle this - /// case. - /// - /// Multithreading: Since v2017.15 this function is MT safe. - /// ## `remote` - /// A remote for the ref - /// ## `ref_` - /// The ref to write - /// ## `checksum` - /// The checksum to point it to fn transaction_set_ref<'a, 'b, P: Into>, Q: Into>>(&self, remote: P, ref_: &str, checksum: Q); - /// Like `RepoExt::transaction_set_ref`, but takes concatenated - /// `refspec` format as input instead of separate remote and name - /// arguments. - /// - /// Multithreading: Since v2017.15 this function is MT safe. - /// ## `refspec` - /// The refspec to write - /// ## `checksum` - /// The checksum to point it to fn transaction_set_refspec<'a, P: Into>>(&self, refspec: &str, checksum: P); //fn traverse_commit<'a, P: Into>>(&self, commit_checksum: &str, maxdepth: i32, out_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 181 }/TypeId { ns_id: 2, id: 181 }, cancellable: P) -> Result<(), Error>; @@ -1315,235 +304,44 @@ pub trait RepoExt { //#[cfg(any(feature = "v2018_6", feature = "dox"))] //fn traverse_reachable_refs<'a, P: Into>>(&self, depth: u32, reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 181 }/TypeId { ns_id: 2, id: 181 }, cancellable: P) -> Result<(), Error>; - /// Check for a valid GPG signature on commit named by the ASCII - /// checksum `commit_checksum`. - /// ## `commit_checksum` - /// ASCII SHA256 checksum - /// ## `keyringdir` - /// Path to directory GPG keyrings; overrides built-in default if given - /// ## `extra_keyring` - /// Path to additional keyring file (not a directory) - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// `true` if there was a GPG signature from a trusted keyring, otherwise `false` fn verify_commit<'a, 'b, 'c, P: IsA + 'a, Q: Into>, R: IsA + 'b, S: Into>, T: Into>>(&self, commit_checksum: &str, keyringdir: Q, extra_keyring: S, cancellable: T) -> Result<(), Error>; - /// Read GPG signature(s) on the commit named by the ASCII checksum - /// `commit_checksum` and return detailed results. - /// ## `commit_checksum` - /// ASCII SHA256 checksum - /// ## `keyringdir` - /// Path to directory GPG keyrings; overrides built-in default if given - /// ## `extra_keyring` - /// Path to additional keyring file (not a directory) - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// an `GpgVerifyResult`, or `None` on error fn verify_commit_ext<'a, 'b, 'c, P: IsA + 'a, Q: Into>, R: IsA + 'b, S: Into>, T: Into>>(&self, commit_checksum: &str, keyringdir: Q, extra_keyring: S, cancellable: T) -> Result; - /// Read GPG signature(s) on the commit named by the ASCII checksum - /// `commit_checksum` and return detailed results, based on the keyring - /// configured for `remote`. - /// ## `commit_checksum` - /// ASCII SHA256 checksum - /// ## `remote_name` - /// OSTree remote to use for configuration - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// an `GpgVerifyResult`, or `None` on error fn verify_commit_for_remote<'a, P: Into>>(&self, commit_checksum: &str, remote_name: &str, cancellable: P) -> Result; - /// Verify `signatures` for `summary` data using GPG keys in the keyring for - /// `remote_name`, and return an `GpgVerifyResult`. - /// ## `remote_name` - /// Name of remote - /// ## `summary` - /// Summary data as a `glib::Bytes` - /// ## `signatures` - /// Summary signatures as a `glib::Bytes` - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// an `GpgVerifyResult`, or `None` on error fn verify_summary<'a, P: Into>>(&self, remote_name: &str, summary: &glib::Bytes, signatures: &glib::Bytes, cancellable: P) -> Result; - /// Import an archive file `archive` into the repository, and write its - /// file structure to `mtree`. - /// ## `archive` - /// A path to an archive file - /// ## `mtree` - /// The `MutableTree` to write to - /// ## `modifier` - /// Optional commit modifier - /// ## `autocreate_parents` - /// Autocreate parent directories - /// ## `cancellable` - /// Cancellable fn write_archive_to_mtree<'a, 'b, P: IsA, Q: Into>, R: Into>>(&self, archive: &P, mtree: &MutableTree, modifier: Q, autocreate_parents: bool, cancellable: R) -> Result<(), Error>; - /// Write a commit metadata object, referencing `root_contents_checksum` - /// and `root_metadata_checksum`. - /// ## `parent` - /// ASCII SHA256 checksum for parent, or `None` for none - /// ## `subject` - /// Subject - /// ## `body` - /// Body - /// ## `metadata` - /// GVariant of type a{sv}, or `None` for none - /// ## `root` - /// The tree to point the commit to - /// ## `out_commit` - /// Resulting ASCII SHA256 checksum for commit - /// ## `cancellable` - /// Cancellable fn write_commit<'a, 'b, 'c, 'd, 'e, P: Into>, Q: Into>, R: Into>, S: Into>, T: Into>>(&self, parent: P, subject: Q, body: R, metadata: S, root: &RepoFile, cancellable: T) -> Result; - /// Replace any existing metadata associated with commit referred to by - /// `checksum` with `metadata`. If `metadata` is `None`, then existing - /// data will be deleted. - /// ## `checksum` - /// ASCII SHA256 commit checksum - /// ## `metadata` - /// Metadata to associate with commit in with format "a{sv}", or `None` to delete - /// ## `cancellable` - /// Cancellable fn write_commit_detached_metadata<'a, 'b, P: Into>, Q: Into>>(&self, checksum: &str, metadata: P, cancellable: Q) -> Result<(), Error>; - /// Write a commit metadata object, referencing `root_contents_checksum` - /// and `root_metadata_checksum`. - /// ## `parent` - /// ASCII SHA256 checksum for parent, or `None` for none - /// ## `subject` - /// Subject - /// ## `body` - /// Body - /// ## `metadata` - /// GVariant of type a{sv}, or `None` for none - /// ## `root` - /// The tree to point the commit to - /// ## `time` - /// The time to use to stamp the commit - /// ## `out_commit` - /// Resulting ASCII SHA256 checksum for commit - /// ## `cancellable` - /// Cancellable fn write_commit_with_time<'a, 'b, 'c, 'd, 'e, P: Into>, Q: Into>, R: Into>, S: Into>, T: Into>>(&self, parent: P, subject: Q, body: R, metadata: S, root: &RepoFile, time: u64, cancellable: T) -> Result; - /// Save `new_config` in place of this repository's config file. - /// ## `new_config` - /// Overwrite the config file with this data fn write_config(&self, new_config: &glib::KeyFile) -> Result<(), Error>; //fn write_content<'a, 'b, P: Into>, Q: IsA, R: Into>>(&self, expected_checksum: P, object_input: &Q, length: u64, out_csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: R) -> Result<(), Error>; - /// Store the content object streamed as `object_input`, with total - /// length `length`. The given `checksum` will be treated as trusted. - /// - /// This function should be used when importing file objects from local - /// disk, for example. - /// ## `checksum` - /// Store content using this ASCII SHA256 checksum - /// ## `object_input` - /// Content stream - /// ## `length` - /// Length of `object_input` - /// ## `cancellable` - /// Cancellable fn write_content_trusted<'a, P: IsA, Q: Into>>(&self, checksum: &str, object_input: &P, length: u64, cancellable: Q) -> Result<(), Error>; - /// Store as objects all contents of the directory referred to by `dfd` - /// and `path` all children into the repository `self`, overlaying the - /// resulting filesystem hierarchy into `mtree`. - /// ## `dfd` - /// Directory file descriptor - /// ## `path` - /// Path - /// ## `mtree` - /// Overlay directory contents into this tree - /// ## `modifier` - /// Optional modifier - /// ## `cancellable` - /// Cancellable fn write_dfd_to_mtree<'a, 'b, P: Into>, Q: Into>>(&self, dfd: i32, path: &str, mtree: &MutableTree, modifier: P, cancellable: Q) -> Result<(), Error>; - /// Store objects for `dir` and all children into the repository `self`, - /// overlaying the resulting filesystem hierarchy into `mtree`. - /// ## `dir` - /// Path to a directory - /// ## `mtree` - /// Overlay directory contents into this tree - /// ## `modifier` - /// Optional modifier - /// ## `cancellable` - /// Cancellable fn write_directory_to_mtree<'a, 'b, P: IsA, Q: Into>, R: Into>>(&self, dir: &P, mtree: &MutableTree, modifier: Q, cancellable: R) -> Result<(), Error>; //fn write_metadata<'a, 'b, P: Into>, Q: Into>>(&self, objtype: ObjectType, expected_checksum: P, object: &glib::Variant, out_csum: /*Unknown conversion*//*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: Q) -> Result<(), Error>; - /// Store the metadata object `variant`; the provided `checksum` is - /// trusted. - /// ## `objtype` - /// Object type - /// ## `checksum` - /// Store object with this ASCII SHA256 checksum - /// ## `object_input` - /// Metadata object stream - /// ## `length` - /// Length, may be 0 for unknown - /// ## `cancellable` - /// Cancellable fn write_metadata_stream_trusted<'a, P: IsA, Q: Into>>(&self, objtype: ObjectType, checksum: &str, object_input: &P, length: u64, cancellable: Q) -> Result<(), Error>; - /// Store the metadata object `variant`; the provided `checksum` is - /// trusted. - /// ## `objtype` - /// Object type - /// ## `checksum` - /// Store object with this ASCII SHA256 checksum - /// ## `variant` - /// Metadata object - /// ## `cancellable` - /// Cancellable fn write_metadata_trusted<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, variant: &glib::Variant, cancellable: P) -> Result<(), Error>; - /// Write all metadata objects for `mtree` to repo; the resulting - /// `out_file` points to the `ObjectType::DirTree` object that - /// the `mtree` represented. - /// ## `mtree` - /// Mutable tree - /// ## `out_file` - /// An `RepoFile` representing `mtree`'s root. - /// ## `cancellable` - /// Cancellable fn write_mtree<'a, P: Into>>(&self, mtree: &MutableTree, cancellable: P) -> Result; fn get_property_remotes_config_dir(&self) -> Option; fn get_property_sysroot_path(&self) -> Option; - /// Emitted during a pull operation upon GPG verification (if enabled). - /// Applications can connect to this signal to output the verification - /// results if desired. - /// - /// The signal will be emitted from whichever `glib::MainContext` is the - /// thread-default at the point when `RepoExt::pull_with_options` - /// is called. - /// ## `checksum` - /// checksum of the signed object - /// ## `result` - /// an `GpgVerifyResult` fn connect_gpg_verify_result(&self, f: F) -> SignalHandlerId; } diff --git a/rust-bindings/rust/libostree/src/auto/repo_commit_modifier.rs b/rust-bindings/rust/libostree/src/auto/repo_commit_modifier.rs index e79e6876..5e492fac 100644 --- a/rust-bindings/rust/libostree/src/auto/repo_commit_modifier.rs +++ b/rust-bindings/rust/libostree/src/auto/repo_commit_modifier.rs @@ -28,21 +28,6 @@ impl RepoCommitModifier { // unsafe { TODO: call ffi::ostree_repo_commit_modifier_new() } //} - /// See the documentation for - /// `ostree_repo_devino_cache_new()`. This function can - /// then be used for later calls to - /// `ostree_repo_write_directory_to_mtree()` to optimize commits. - /// - /// Note if your process has multiple writers, you should use separate - /// `OSTreeRepo` instances if you want to also use this API. - /// - /// This function will add a reference to `cache` without copying - you - /// should avoid further mutation of the cache. - /// - /// Feature: `v2017_13` - /// - /// ## `cache` - /// A hash table caching device,inode to checksums #[cfg(any(feature = "v2017_13", feature = "dox"))] pub fn set_devino_cache(&self, cache: &RepoDevInoCache) { unsafe { @@ -50,16 +35,6 @@ impl RepoCommitModifier { } } - /// If `policy` is non-`None`, use it to look up labels to use for - /// "security.selinux" extended attributes. - /// - /// Note that any policy specified this way operates in addition to any - /// extended attributes provided via - /// `RepoCommitModifier::set_xattr_callback`. However if both - /// specify a value for "security.selinux", then the one from the - /// policy wins. - /// ## `sepolicy` - /// Policy to use for labeling pub fn set_sepolicy<'a, P: Into>>(&self, sepolicy: P) { let sepolicy = sepolicy.into(); let sepolicy = sepolicy.to_glib_none(); diff --git a/rust-bindings/rust/libostree/src/auto/repo_dev_ino_cache.rs b/rust-bindings/rust/libostree/src/auto/repo_dev_ino_cache.rs index 8d00c174..7ffd9f0c 100644 --- a/rust-bindings/rust/libostree/src/auto/repo_dev_ino_cache.rs +++ b/rust-bindings/rust/libostree/src/auto/repo_dev_ino_cache.rs @@ -21,17 +21,6 @@ glib_wrapper! { } impl RepoDevInoCache { - /// OSTree has support for pairing `RepoExt::checkout_tree_at` using - /// hardlinks in combination with a later - /// `RepoExt::write_directory_to_mtree` using a (normally modified) - /// directory. In order for OSTree to optimally detect just the new - /// files, use this function and fill in the `devino_to_csum_cache` - /// member of `OstreeRepoCheckoutAtOptions`, then call - /// `ostree_repo_commit_set_devino_cache`. - /// - /// # Returns - /// - /// Newly allocated cache pub fn new() -> RepoDevInoCache { unsafe { from_glib_full(ffi::ostree_repo_devino_cache_new()) diff --git a/rust-bindings/rust/libostree/src/auto/repo_file.rs b/rust-bindings/rust/libostree/src/auto/repo_file.rs index eed32005..17b06596 100644 --- a/rust-bindings/rust/libostree/src/auto/repo_file.rs +++ b/rust-bindings/rust/libostree/src/auto/repo_file.rs @@ -25,26 +25,13 @@ glib_wrapper! { } } -/// Trait containing all `RepoFile` methods. -/// -/// # Implementors -/// -/// [`RepoFile`](struct.RepoFile.html) pub trait RepoFileExt { fn ensure_resolved(&self) -> Result<(), Error>; fn get_checksum(&self) -> Option; - /// - /// # Returns - /// - /// Repository fn get_repo(&self) -> Option; - /// - /// # Returns - /// - /// The root directory for the commit referenced by this file fn get_root(&self) -> Option; fn tree_get_contents(&self) -> Option; diff --git a/rust-bindings/rust/libostree/src/auto/se_policy.rs b/rust-bindings/rust/libostree/src/auto/se_policy.rs index fa46f462..fe17535f 100644 --- a/rust-bindings/rust/libostree/src/auto/se_policy.rs +++ b/rust-bindings/rust/libostree/src/auto/se_policy.rs @@ -25,14 +25,6 @@ glib_wrapper! { } impl SePolicy { - /// ## `path` - /// Path to a root directory - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// An accessor object for SELinux policy in root located at `path` pub fn new<'a, P: IsA, Q: Into>>(path: &P, cancellable: Q) -> Result { let cancellable = cancellable.into(); let cancellable = cancellable.to_glib_none(); @@ -43,14 +35,6 @@ impl SePolicy { } } - /// ## `rootfs_dfd` - /// Directory fd for rootfs (will not be cloned) - /// ## `cancellable` - /// Cancellable - /// - /// # Returns - /// - /// An accessor object for SELinux policy in root located at `rootfs_dfd` pub fn new_at<'a, P: Into>>(rootfs_dfd: i32, cancellable: P) -> Result { let cancellable = cancellable.into(); let cancellable = cancellable.to_glib_none(); @@ -66,62 +50,17 @@ impl SePolicy { //} } -/// Trait containing all `SePolicy` methods. -/// -/// # Implementors -/// -/// [`SePolicy`](struct.SePolicy.html) pub trait SePolicyExt { - /// - /// # Returns - /// - /// Checksum of current policy fn get_csum(&self) -> Option; - /// Store in `out_label` the security context for the given `relpath` and - /// mode `unix_mode`. If the policy does not specify a label, `None` - /// will be returned. - /// ## `relpath` - /// Path - /// ## `unix_mode` - /// Unix mode - /// ## `out_label` - /// Return location for security context - /// ## `cancellable` - /// Cancellable fn get_label<'a, P: Into>>(&self, relpath: &str, unix_mode: u32, cancellable: P) -> Result; - /// - /// # Returns - /// - /// Type of current policy fn get_name(&self) -> Option; - /// - /// # Returns - /// - /// Path to rootfs fn get_path(&self) -> Option; - /// Reset the security context of `target` based on the SELinux policy. - /// ## `path` - /// Path string to use for policy lookup - /// ## `info` - /// File attributes - /// ## `target` - /// Physical path to target file - /// ## `flags` - /// Flags controlling behavior - /// ## `out_new_label` - /// New label, or `None` if unchanged - /// ## `cancellable` - /// Cancellable fn restorecon<'a, 'b, P: Into>, Q: IsA, R: Into>>(&self, path: &str, info: P, target: &Q, flags: SePolicyRestoreconFlags, cancellable: R) -> Result; - /// ## `path` - /// Use this path to determine a label - /// ## `mode` - /// Used along with `path` fn setfscreatecon(&self, path: &str, mode: u32) -> Result<(), Error>; fn get_property_rootfs_dfd(&self) -> i32; diff --git a/rust-bindings/rust/libostree/src/lib.rs b/rust-bindings/rust/libostree/src/lib.rs index 9294d947..c61cacf9 100644 --- a/rust-bindings/rust/libostree/src/lib.rs +++ b/rust-bindings/rust/libostree/src/lib.rs @@ -8,6 +8,8 @@ extern crate gio; extern crate libc; #[macro_use] extern crate bitflags; +#[macro_use] +extern crate lazy_static; use glib::Error; diff --git a/rust-bindings/rust/sample/Cargo.lock b/rust-bindings/rust/sample/Cargo.lock index c43f4cf6..fa6d26eb 100644 --- a/rust-bindings/rust/sample/Cargo.lock +++ b/rust-bindings/rust/sample/Cargo.lock @@ -88,6 +88,7 @@ dependencies = [ "glib 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "glib-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "gobject-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "libostree-sys 0.2.0", ]