diff --git a/rust-bindings/rust/Cargo.toml b/rust-bindings/rust/Cargo.toml index 48f3edad..d8fbc959 100644 --- a/rust-bindings/rust/Cargo.toml +++ b/rust-bindings/rust/Cargo.toml @@ -31,12 +31,12 @@ name = "ostree" libc = "0.2" bitflags = "1" lazy_static = "1.1" -glib = "0.6" -gio = "0.5" -glib-sys = "0.7" -gobject-sys = "0.7" -gio-sys = "0.7" -ostree-sys = { version = "0.3", path = "sys" } +glib = "0.7.1" +gio = "0.6.0" +glib-sys = "0.8.0" +gobject-sys = "0.8.0" +gio-sys = "0.8.0" +ostree-sys = { version = "0.3.0", path = "sys" } [dev-dependencies] tempfile = "3" diff --git a/rust-bindings/rust/conf/ostree.toml b/rust-bindings/rust/conf/ostree.toml index b531bcfa..514f4870 100644 --- a/rust-bindings/rust/conf/ostree.toml +++ b/rust-bindings/rust/conf/ostree.toml @@ -61,6 +61,9 @@ manual = [ "GLib.Variant", ] +[crate_name_overrides] +os_tree = "ostree" + [[object]] name = "OSTree.CollectionRef" status = "manual" diff --git a/rust-bindings/rust/src/auto/async_progress.rs b/rust-bindings/rust/src/auto/async_progress.rs index ea95a329..e8c666d8 100644 --- a/rust-bindings/rust/src/auto/async_progress.rs +++ b/rust-bindings/rust/src/auto/async_progress.rs @@ -2,37 +2,38 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; +#[cfg(any(feature = "v2017_6", feature = "dox"))] use glib; -use glib::object::Downcast; +#[cfg(any(feature = "v2017_6", feature = "dox"))] +use glib::GString; +use glib::object::Cast; use glib::object::IsA; use glib::signal::SignalHandlerId; -use glib::signal::connect; +use glib::signal::connect_raw; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib_sys; +use ostree_sys; use std::boxed::Box as Box_; -use std::mem; +use std::fmt; use std::mem::transmute; -use std::ptr; glib_wrapper! { - pub struct AsyncProgress(Object); + pub struct AsyncProgress(Object); match fn { - get_type => || ffi::ostree_async_progress_get_type(), + get_type => || ostree_sys::ostree_async_progress_get_type(), } } impl AsyncProgress { pub fn new() -> AsyncProgress { unsafe { - from_glib_full(ffi::ostree_async_progress_new()) + from_glib_full(ostree_sys::ostree_async_progress_new()) } } - //pub fn new_and_connect>, Q: Into>>(changed: P, user_data: Q) -> AsyncProgress { - // unsafe { TODO: call ffi::ostree_async_progress_new_and_connect() } + //pub fn new_and_connect(changed: /*Unimplemented*/Option, user_data: /*Unimplemented*/Option) -> AsyncProgress { + // unsafe { TODO: call ostree_sys:ostree_async_progress_new_and_connect() } //} } @@ -42,14 +43,16 @@ impl Default for AsyncProgress { } } -pub trait AsyncProgressExt { +pub const NONE_ASYNC_PROGRESS: Option<&AsyncProgress> = None; + +pub trait AsyncProgressExt: 'static { fn finish(&self); //#[cfg(any(feature = "v2017_6", feature = "dox"))] //fn get(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); #[cfg(any(feature = "v2017_6", feature = "dox"))] - fn get_status(&self) -> Option; + fn get_status(&self) -> Option; fn get_uint(&self, key: &str) -> u32; @@ -62,7 +65,7 @@ pub trait AsyncProgressExt { //fn set(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); #[cfg(any(feature = "v2017_6", feature = "dox"))] - fn set_status<'a, P: Into>>(&self, status: P); + fn set_status(&self, status: Option<&str>); fn set_uint(&self, key: &str, value: u32); @@ -74,88 +77,92 @@ pub trait AsyncProgressExt { fn connect_changed(&self, f: F) -> SignalHandlerId; } -impl + IsA> AsyncProgressExt for O { +impl> AsyncProgressExt for O { fn finish(&self) { unsafe { - ffi::ostree_async_progress_finish(self.to_glib_none().0); + ostree_sys::ostree_async_progress_finish(self.as_ref().to_glib_none().0); } } //#[cfg(any(feature = "v2017_6", feature = "dox"))] //fn get(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { - // unsafe { TODO: call ffi::ostree_async_progress_get() } + // unsafe { TODO: call ostree_sys:ostree_async_progress_get() } //} #[cfg(any(feature = "v2017_6", feature = "dox"))] - fn get_status(&self) -> Option { + fn get_status(&self) -> Option { unsafe { - from_glib_full(ffi::ostree_async_progress_get_status(self.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_async_progress_get_status(self.as_ref().to_glib_none().0)) } } fn get_uint(&self, key: &str) -> u32 { unsafe { - ffi::ostree_async_progress_get_uint(self.to_glib_none().0, key.to_glib_none().0) + ostree_sys::ostree_async_progress_get_uint(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn get_uint64(&self, key: &str) -> u64 { unsafe { - ffi::ostree_async_progress_get_uint64(self.to_glib_none().0, key.to_glib_none().0) + ostree_sys::ostree_async_progress_get_uint64(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[cfg(any(feature = "v2017_6", feature = "dox"))] fn get_variant(&self, key: &str) -> Option { unsafe { - from_glib_full(ffi::ostree_async_progress_get_variant(self.to_glib_none().0, key.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_async_progress_get_variant(self.as_ref().to_glib_none().0, key.to_glib_none().0)) } } //#[cfg(any(feature = "v2017_6", feature = "dox"))] //fn set(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { - // unsafe { TODO: call ffi::ostree_async_progress_set() } + // unsafe { TODO: call ostree_sys:ostree_async_progress_set() } //} #[cfg(any(feature = "v2017_6", feature = "dox"))] - fn set_status<'a, P: Into>>(&self, status: P) { - let status = status.into(); - let status = status.to_glib_none(); + fn set_status(&self, status: Option<&str>) { unsafe { - ffi::ostree_async_progress_set_status(self.to_glib_none().0, status.0); + ostree_sys::ostree_async_progress_set_status(self.as_ref().to_glib_none().0, status.to_glib_none().0); } } fn set_uint(&self, key: &str, value: u32) { unsafe { - ffi::ostree_async_progress_set_uint(self.to_glib_none().0, key.to_glib_none().0, value); + ostree_sys::ostree_async_progress_set_uint(self.as_ref().to_glib_none().0, key.to_glib_none().0, value); } } fn set_uint64(&self, key: &str, value: u64) { unsafe { - ffi::ostree_async_progress_set_uint64(self.to_glib_none().0, key.to_glib_none().0, value); + ostree_sys::ostree_async_progress_set_uint64(self.as_ref().to_glib_none().0, key.to_glib_none().0, value); } } #[cfg(any(feature = "v2017_6", feature = "dox"))] fn set_variant(&self, key: &str, value: &glib::Variant) { unsafe { - ffi::ostree_async_progress_set_variant(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0); + ostree_sys::ostree_async_progress_set_variant(self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0); } } fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "changed", - transmute(changed_trampoline:: as usize), Box_::into_raw(f) as *mut _) + let f: Box_ = Box_::new(f); + connect_raw(self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, + Some(transmute(changed_trampoline:: as usize)), Box_::into_raw(f)) } } } -unsafe extern "C" fn changed_trampoline

(this: *mut ffi::OstreeAsyncProgress, f: glib_ffi::gpointer) +unsafe extern "C" fn changed_trampoline(this: *mut ostree_sys::OstreeAsyncProgress, f: glib_sys::gpointer) where P: IsA { - let f: &&(Fn(&P) + 'static) = transmute(f); - f(&AsyncProgress::from_glib_borrow(this).downcast_unchecked()) + let f: &F = &*(f as *const F); + f(&AsyncProgress::from_glib_borrow(this).unsafe_cast()) +} + +impl fmt::Display for AsyncProgress { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AsyncProgress") + } } diff --git a/rust-bindings/rust/src/auto/bootconfig_parser.rs b/rust-bindings/rust/src/auto/bootconfig_parser.rs index 6b2507ee..8bbfd2f7 100644 --- a/rust-bindings/rust/src/auto/bootconfig_parser.rs +++ b/rust-bindings/rust/src/auto/bootconfig_parser.rs @@ -3,27 +3,76 @@ // DO NOT EDIT use Error; -use ffi; use gio; +use glib::GString; use glib::object::IsA; use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; +use ostree_sys; +use std::fmt; use std::ptr; glib_wrapper! { - pub struct BootconfigParser(Object); + pub struct BootconfigParser(Object); match fn { - get_type => || ffi::ostree_bootconfig_parser_get_type(), + get_type => || ostree_sys::ostree_bootconfig_parser_get_type(), } } impl BootconfigParser { pub fn new() -> BootconfigParser { unsafe { - from_glib_full(ffi::ostree_bootconfig_parser_new()) + from_glib_full(ostree_sys::ostree_bootconfig_parser_new()) + } + } + + pub fn clone(&self) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_bootconfig_parser_clone(self.to_glib_none().0)) + } + } + + pub fn get(&self, key: &str) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_bootconfig_parser_get(self.to_glib_none().0, key.to_glib_none().0)) + } + } + + pub fn parse, Q: IsA>(&self, path: &P, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_bootconfig_parser_parse(self.to_glib_none().0, path.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn parse_at>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_bootconfig_parser_parse_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn set(&self, key: &str, value: &str) { + unsafe { + ostree_sys::ostree_bootconfig_parser_set(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0); + } + } + + pub fn write, Q: IsA>(&self, output: &P, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_bootconfig_parser_write(self.to_glib_none().0, output.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_at>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_bootconfig_parser_write_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } @@ -34,78 +83,8 @@ impl Default for BootconfigParser { } } -pub trait BootconfigParserExt { - fn clone(&self) -> Option; - - fn get(&self, key: &str) -> Option; - - fn parse<'a, P: IsA, Q: Into>>(&self, path: &P, cancellable: Q) -> Result<(), Error>; - - fn parse_at<'a, P: Into>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error>; - - fn set(&self, key: &str, value: &str); - - fn write<'a, P: IsA, Q: Into>>(&self, output: &P, cancellable: Q) -> Result<(), Error>; - - fn write_at<'a, P: Into>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error>; -} - -impl> BootconfigParserExt for O { - fn clone(&self) -> Option { - unsafe { - from_glib_full(ffi::ostree_bootconfig_parser_clone(self.to_glib_none().0)) - } - } - - fn get(&self, key: &str) -> Option { - unsafe { - from_glib_none(ffi::ostree_bootconfig_parser_get(self.to_glib_none().0, key.to_glib_none().0)) - } - } - - fn parse<'a, P: IsA, Q: Into>>(&self, path: &P, cancellable: Q) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_bootconfig_parser_parse(self.to_glib_none().0, path.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn parse_at<'a, P: Into>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_bootconfig_parser_parse_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn set(&self, key: &str, value: &str) { - unsafe { - ffi::ostree_bootconfig_parser_set(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0); - } - } - - fn write<'a, P: IsA, Q: Into>>(&self, output: &P, cancellable: Q) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_bootconfig_parser_write(self.to_glib_none().0, output.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn write_at<'a, P: Into>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_bootconfig_parser_write_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } +impl fmt::Display for BootconfigParser { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "BootconfigParser") } } diff --git a/rust-bindings/rust/src/auto/constants.rs b/rust-bindings/rust/src/auto/constants.rs index f5707eab..7d6833ff 100644 --- a/rust-bindings/rust/src/auto/constants.rs +++ b/rust-bindings/rust/src/auto/constants.rs @@ -2,60 +2,60 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; +use ostree_sys; 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()}; + pub static ref COMMIT_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref COMMIT_META_KEY_COLLECTION_BINDING: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref COMMIT_META_KEY_ENDOFLIFE: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref COMMIT_META_KEY_ENDOFLIFE_REBASE: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref COMMIT_META_KEY_REF_BINDING: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref COMMIT_META_KEY_SOURCE_TITLE: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref COMMIT_META_KEY_VERSION: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref DIRMETA_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref FILEMETA_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ostree_sys::OSTREE_FILEMETA_GVARIANT_STRING).to_str().unwrap()}; } #[cfg(any(feature = "v2018_9", feature = "dox"))] lazy_static! { - pub static ref META_KEY_DEPLOY_COLLECTION_ID: &'static str = unsafe{CStr::from_ptr(ffi::OSTREE_META_KEY_DEPLOY_COLLECTION_ID).to_str().unwrap()}; + pub static ref META_KEY_DEPLOY_COLLECTION_ID: &'static str = unsafe{CStr::from_ptr(ostree_sys::OSTREE_META_KEY_DEPLOY_COLLECTION_ID).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()}; + pub static ref ORIGIN_TRANSIENT_GROUP: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref REPO_METADATA_REF: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref SUMMARY_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref SUMMARY_SIG_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ostree_sys::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()}; + pub static ref TREE_GVARIANT_STRING: &'static str = unsafe{CStr::from_ptr(ostree_sys::OSTREE_TREE_GVARIANT_STRING).to_str().unwrap()}; } diff --git a/rust-bindings/rust/src/auto/deployment.rs b/rust-bindings/rust/src/auto/deployment.rs index 2c7ec27e..e2ed855a 100644 --- a/rust-bindings/rust/src/auto/deployment.rs +++ b/rust-bindings/rust/src/auto/deployment.rs @@ -5,201 +5,162 @@ use BootconfigParser; #[cfg(any(feature = "v2016_4", feature = "dox"))] use DeploymentUnlockedState; -use ffi; use glib; -use glib::object::IsA; +use glib::GString; use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::ptr; +use glib_sys; +use ostree_sys; +use std::fmt; glib_wrapper! { - pub struct Deployment(Object); + pub struct Deployment(Object); match fn { - get_type => || ffi::ostree_deployment_get_type(), + get_type => || ostree_sys::ostree_deployment_get_type(), } } impl Deployment { pub fn new(index: i32, osname: &str, csum: &str, deployserial: i32, bootcsum: &str, bootserial: i32) -> Deployment { unsafe { - from_glib_full(ffi::ostree_deployment_new(index, osname.to_glib_none().0, csum.to_glib_none().0, deployserial, bootcsum.to_glib_none().0, bootserial)) + from_glib_full(ostree_sys::ostree_deployment_new(index, osname.to_glib_none().0, csum.to_glib_none().0, deployserial, bootcsum.to_glib_none().0, bootserial)) + } + } + + pub fn clone(&self) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_deployment_clone(self.to_glib_none().0)) + } + } + + pub fn equal(&self, bp: &Deployment) -> bool { + unsafe { + from_glib(ostree_sys::ostree_deployment_equal(ToGlibPtr::<*mut ostree_sys::OstreeDeployment>::to_glib_none(self).0 as glib_sys::gconstpointer, ToGlibPtr::<*mut ostree_sys::OstreeDeployment>::to_glib_none(bp).0 as glib_sys::gconstpointer)) + } + } + + pub fn get_bootconfig(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_deployment_get_bootconfig(self.to_glib_none().0)) + } + } + + pub fn get_bootcsum(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_deployment_get_bootcsum(self.to_glib_none().0)) + } + } + + pub fn get_bootserial(&self) -> i32 { + unsafe { + ostree_sys::ostree_deployment_get_bootserial(self.to_glib_none().0) + } + } + + pub fn get_csum(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_deployment_get_csum(self.to_glib_none().0)) + } + } + + pub fn get_deployserial(&self) -> i32 { + unsafe { + ostree_sys::ostree_deployment_get_deployserial(self.to_glib_none().0) + } + } + + pub fn get_index(&self) -> i32 { + unsafe { + ostree_sys::ostree_deployment_get_index(self.to_glib_none().0) + } + } + + pub fn get_origin(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_deployment_get_origin(self.to_glib_none().0)) + } + } + + pub fn get_origin_relpath(&self) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_deployment_get_origin_relpath(self.to_glib_none().0)) + } + } + + pub fn get_osname(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_deployment_get_osname(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2016_4", feature = "dox"))] + pub fn get_unlocked(&self) -> DeploymentUnlockedState { + unsafe { + from_glib(ostree_sys::ostree_deployment_get_unlocked(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2018_3", feature = "dox"))] + pub fn is_pinned(&self) -> bool { + unsafe { + from_glib(ostree_sys::ostree_deployment_is_pinned(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2018_3", feature = "dox"))] + pub fn is_staged(&self) -> bool { + unsafe { + from_glib(ostree_sys::ostree_deployment_is_staged(self.to_glib_none().0)) + } + } + + pub fn set_bootconfig(&self, bootconfig: &BootconfigParser) { + unsafe { + ostree_sys::ostree_deployment_set_bootconfig(self.to_glib_none().0, bootconfig.to_glib_none().0); + } + } + + pub fn set_bootserial(&self, index: i32) { + unsafe { + ostree_sys::ostree_deployment_set_bootserial(self.to_glib_none().0, index); + } + } + + pub fn set_index(&self, index: i32) { + unsafe { + ostree_sys::ostree_deployment_set_index(self.to_glib_none().0, index); + } + } + + pub fn set_origin(&self, origin: &glib::KeyFile) { + unsafe { + ostree_sys::ostree_deployment_set_origin(self.to_glib_none().0, origin.to_glib_none().0); } } pub fn hash(&self) -> u32 { unsafe { - ffi::ostree_deployment_hash(ToGlibPtr::<*mut ffi::OstreeDeployment>::to_glib_none(self).0 as glib_ffi::gconstpointer) + ostree_sys::ostree_deployment_hash(ToGlibPtr::<*mut ostree_sys::OstreeDeployment>::to_glib_none(self).0 as glib_sys::gconstpointer) } } #[cfg(any(feature = "v2018_3", feature = "dox"))] pub fn origin_remove_transient_state(origin: &glib::KeyFile) { unsafe { - ffi::ostree_deployment_origin_remove_transient_state(origin.to_glib_none().0); + ostree_sys::ostree_deployment_origin_remove_transient_state(origin.to_glib_none().0); } } #[cfg(any(feature = "v2016_4", feature = "dox"))] - pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> Option { + pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> Option { unsafe { - from_glib_none(ffi::ostree_deployment_unlocked_state_to_string(state.to_glib())) + from_glib_none(ostree_sys::ostree_deployment_unlocked_state_to_string(state.to_glib())) } } } -pub trait DeploymentExt { - fn clone(&self) -> Option; - - fn equal(&self, bp: &Deployment) -> bool; - - fn get_bootconfig(&self) -> Option; - - fn get_bootcsum(&self) -> Option; - - fn get_bootserial(&self) -> i32; - - fn get_csum(&self) -> Option; - - fn get_deployserial(&self) -> i32; - - fn get_index(&self) -> i32; - - fn get_origin(&self) -> Option; - - fn get_origin_relpath(&self) -> Option; - - fn get_osname(&self) -> Option; - - #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn get_unlocked(&self) -> DeploymentUnlockedState; - - #[cfg(any(feature = "v2018_3", feature = "dox"))] - fn is_pinned(&self) -> bool; - - #[cfg(any(feature = "v2018_3", feature = "dox"))] - fn is_staged(&self) -> bool; - - fn set_bootconfig(&self, bootconfig: &BootconfigParser); - - fn set_bootserial(&self, index: i32); - - fn set_index(&self, index: i32); - - fn set_origin(&self, origin: &glib::KeyFile); -} - -impl> DeploymentExt for O { - fn clone(&self) -> Option { - unsafe { - from_glib_full(ffi::ostree_deployment_clone(self.to_glib_none().0)) - } - } - - fn equal(&self, bp: &Deployment) -> bool { - unsafe { - from_glib(ffi::ostree_deployment_equal(ToGlibPtr::<*mut ffi::OstreeDeployment>::to_glib_none(self).0 as glib_ffi::gconstpointer, ToGlibPtr::<*mut ffi::OstreeDeployment>::to_glib_none(bp).0 as glib_ffi::gconstpointer)) - } - } - - fn get_bootconfig(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_deployment_get_bootconfig(self.to_glib_none().0)) - } - } - - fn get_bootcsum(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_deployment_get_bootcsum(self.to_glib_none().0)) - } - } - - fn get_bootserial(&self) -> i32 { - unsafe { - ffi::ostree_deployment_get_bootserial(self.to_glib_none().0) - } - } - - fn get_csum(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_deployment_get_csum(self.to_glib_none().0)) - } - } - - fn get_deployserial(&self) -> i32 { - unsafe { - ffi::ostree_deployment_get_deployserial(self.to_glib_none().0) - } - } - - fn get_index(&self) -> i32 { - unsafe { - ffi::ostree_deployment_get_index(self.to_glib_none().0) - } - } - - fn get_origin(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_deployment_get_origin(self.to_glib_none().0)) - } - } - - fn get_origin_relpath(&self) -> Option { - unsafe { - from_glib_full(ffi::ostree_deployment_get_origin_relpath(self.to_glib_none().0)) - } - } - - fn get_osname(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_deployment_get_osname(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn get_unlocked(&self) -> DeploymentUnlockedState { - unsafe { - from_glib(ffi::ostree_deployment_get_unlocked(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2018_3", feature = "dox"))] - fn is_pinned(&self) -> bool { - unsafe { - from_glib(ffi::ostree_deployment_is_pinned(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2018_3", feature = "dox"))] - fn is_staged(&self) -> bool { - unsafe { - from_glib(ffi::ostree_deployment_is_staged(self.to_glib_none().0)) - } - } - - fn set_bootconfig(&self, bootconfig: &BootconfigParser) { - unsafe { - ffi::ostree_deployment_set_bootconfig(self.to_glib_none().0, bootconfig.to_glib_none().0); - } - } - - fn set_bootserial(&self, index: i32) { - unsafe { - ffi::ostree_deployment_set_bootserial(self.to_glib_none().0, index); - } - } - - fn set_index(&self, index: i32) { - unsafe { - ffi::ostree_deployment_set_index(self.to_glib_none().0, index); - } - } - - fn set_origin(&self, origin: &glib::KeyFile) { - unsafe { - ffi::ostree_deployment_set_origin(self.to_glib_none().0, origin.to_glib_none().0); - } +impl fmt::Display for Deployment { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Deployment") } } diff --git a/rust-bindings/rust/src/auto/enums.rs b/rust-bindings/rust/src/auto/enums.rs index c016888a..b62f254a 100644 --- a/rust-bindings/rust/src/auto/enums.rs +++ b/rust-bindings/rust/src/auto/enums.rs @@ -2,8 +2,9 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; use glib::translate::*; +use ostree_sys; +use std::fmt; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Clone, Copy)] @@ -15,23 +16,34 @@ pub enum DeploymentUnlockedState { __Unknown(i32), } +impl fmt::Display for DeploymentUnlockedState { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "DeploymentUnlockedState::{}", match *self { + DeploymentUnlockedState::None => "None", + DeploymentUnlockedState::Development => "Development", + DeploymentUnlockedState::Hotfix => "Hotfix", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for DeploymentUnlockedState { - type GlibType = ffi::OstreeDeploymentUnlockedState; + type GlibType = ostree_sys::OstreeDeploymentUnlockedState; - fn to_glib(&self) -> ffi::OstreeDeploymentUnlockedState { + fn to_glib(&self) -> ostree_sys::OstreeDeploymentUnlockedState { match *self { - DeploymentUnlockedState::None => ffi::OSTREE_DEPLOYMENT_UNLOCKED_NONE, - DeploymentUnlockedState::Development => ffi::OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT, - DeploymentUnlockedState::Hotfix => ffi::OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX, + DeploymentUnlockedState::None => ostree_sys::OSTREE_DEPLOYMENT_UNLOCKED_NONE, + DeploymentUnlockedState::Development => ostree_sys::OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT, + DeploymentUnlockedState::Hotfix => ostree_sys::OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX, DeploymentUnlockedState::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for DeploymentUnlockedState { - fn from_glib(value: ffi::OstreeDeploymentUnlockedState) -> Self { +impl FromGlib for DeploymentUnlockedState { + fn from_glib(value: ostree_sys::OstreeDeploymentUnlockedState) -> Self { match value { 0 => DeploymentUnlockedState::None, 1 => DeploymentUnlockedState::Development, @@ -49,21 +61,30 @@ pub enum GpgSignatureFormatFlags { __Unknown(i32), } +impl fmt::Display for GpgSignatureFormatFlags { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "GpgSignatureFormatFlags::{}", match *self { + GpgSignatureFormatFlags::GpgSignatureFormatDefault => "GpgSignatureFormatDefault", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for GpgSignatureFormatFlags { - type GlibType = ffi::OstreeGpgSignatureFormatFlags; + type GlibType = ostree_sys::OstreeGpgSignatureFormatFlags; - fn to_glib(&self) -> ffi::OstreeGpgSignatureFormatFlags { + fn to_glib(&self) -> ostree_sys::OstreeGpgSignatureFormatFlags { match *self { - GpgSignatureFormatFlags::GpgSignatureFormatDefault => ffi::OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT, + GpgSignatureFormatFlags::GpgSignatureFormatDefault => ostree_sys::OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT, GpgSignatureFormatFlags::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for GpgSignatureFormatFlags { - fn from_glib(value: ffi::OstreeGpgSignatureFormatFlags) -> Self { +impl FromGlib for GpgSignatureFormatFlags { + fn from_glib(value: ostree_sys::OstreeGpgSignatureFormatFlags) -> Self { match value { 0 => GpgSignatureFormatFlags::GpgSignatureFormatDefault, value => GpgSignatureFormatFlags::__Unknown(value), @@ -85,27 +106,42 @@ pub enum ObjectType { __Unknown(i32), } +impl fmt::Display for ObjectType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ObjectType::{}", match *self { + ObjectType::File => "File", + ObjectType::DirTree => "DirTree", + ObjectType::DirMeta => "DirMeta", + ObjectType::Commit => "Commit", + ObjectType::TombstoneCommit => "TombstoneCommit", + ObjectType::CommitMeta => "CommitMeta", + ObjectType::PayloadLink => "PayloadLink", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for ObjectType { - type GlibType = ffi::OstreeObjectType; + type GlibType = ostree_sys::OstreeObjectType; - fn to_glib(&self) -> ffi::OstreeObjectType { + fn to_glib(&self) -> ostree_sys::OstreeObjectType { match *self { - ObjectType::File => ffi::OSTREE_OBJECT_TYPE_FILE, - ObjectType::DirTree => ffi::OSTREE_OBJECT_TYPE_DIR_TREE, - ObjectType::DirMeta => ffi::OSTREE_OBJECT_TYPE_DIR_META, - ObjectType::Commit => ffi::OSTREE_OBJECT_TYPE_COMMIT, - ObjectType::TombstoneCommit => ffi::OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT, - ObjectType::CommitMeta => ffi::OSTREE_OBJECT_TYPE_COMMIT_META, - ObjectType::PayloadLink => ffi::OSTREE_OBJECT_TYPE_PAYLOAD_LINK, + ObjectType::File => ostree_sys::OSTREE_OBJECT_TYPE_FILE, + ObjectType::DirTree => ostree_sys::OSTREE_OBJECT_TYPE_DIR_TREE, + ObjectType::DirMeta => ostree_sys::OSTREE_OBJECT_TYPE_DIR_META, + ObjectType::Commit => ostree_sys::OSTREE_OBJECT_TYPE_COMMIT, + ObjectType::TombstoneCommit => ostree_sys::OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT, + ObjectType::CommitMeta => ostree_sys::OSTREE_OBJECT_TYPE_COMMIT_META, + ObjectType::PayloadLink => ostree_sys::OSTREE_OBJECT_TYPE_PAYLOAD_LINK, ObjectType::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for ObjectType { - fn from_glib(value: ffi::OstreeObjectType) -> Self { +impl FromGlib for ObjectType { + fn from_glib(value: ostree_sys::OstreeObjectType) -> Self { match value { 1 => ObjectType::File, 2 => ObjectType::DirTree, @@ -128,22 +164,32 @@ pub enum RepoCheckoutMode { __Unknown(i32), } +impl fmt::Display for RepoCheckoutMode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RepoCheckoutMode::{}", match *self { + RepoCheckoutMode::None => "None", + RepoCheckoutMode::User => "User", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for RepoCheckoutMode { - type GlibType = ffi::OstreeRepoCheckoutMode; + type GlibType = ostree_sys::OstreeRepoCheckoutMode; - fn to_glib(&self) -> ffi::OstreeRepoCheckoutMode { + fn to_glib(&self) -> ostree_sys::OstreeRepoCheckoutMode { match *self { - RepoCheckoutMode::None => ffi::OSTREE_REPO_CHECKOUT_MODE_NONE, - RepoCheckoutMode::User => ffi::OSTREE_REPO_CHECKOUT_MODE_USER, + RepoCheckoutMode::None => ostree_sys::OSTREE_REPO_CHECKOUT_MODE_NONE, + RepoCheckoutMode::User => ostree_sys::OSTREE_REPO_CHECKOUT_MODE_USER, RepoCheckoutMode::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for RepoCheckoutMode { - fn from_glib(value: ffi::OstreeRepoCheckoutMode) -> Self { +impl FromGlib for RepoCheckoutMode { + fn from_glib(value: ostree_sys::OstreeRepoCheckoutMode) -> Self { match value { 0 => RepoCheckoutMode::None, 1 => RepoCheckoutMode::User, @@ -163,24 +209,36 @@ pub enum RepoCheckoutOverwriteMode { __Unknown(i32), } +impl fmt::Display for RepoCheckoutOverwriteMode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RepoCheckoutOverwriteMode::{}", match *self { + RepoCheckoutOverwriteMode::None => "None", + RepoCheckoutOverwriteMode::UnionFiles => "UnionFiles", + RepoCheckoutOverwriteMode::AddFiles => "AddFiles", + RepoCheckoutOverwriteMode::UnionIdentical => "UnionIdentical", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for RepoCheckoutOverwriteMode { - type GlibType = ffi::OstreeRepoCheckoutOverwriteMode; + type GlibType = ostree_sys::OstreeRepoCheckoutOverwriteMode; - fn to_glib(&self) -> ffi::OstreeRepoCheckoutOverwriteMode { + fn to_glib(&self) -> ostree_sys::OstreeRepoCheckoutOverwriteMode { match *self { - RepoCheckoutOverwriteMode::None => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE, - RepoCheckoutOverwriteMode::UnionFiles => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES, - RepoCheckoutOverwriteMode::AddFiles => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES, - RepoCheckoutOverwriteMode::UnionIdentical => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL, + RepoCheckoutOverwriteMode::None => ostree_sys::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE, + RepoCheckoutOverwriteMode::UnionFiles => ostree_sys::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES, + RepoCheckoutOverwriteMode::AddFiles => ostree_sys::OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES, + RepoCheckoutOverwriteMode::UnionIdentical => ostree_sys::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL, RepoCheckoutOverwriteMode::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for RepoCheckoutOverwriteMode { - fn from_glib(value: ffi::OstreeRepoCheckoutOverwriteMode) -> Self { +impl FromGlib for RepoCheckoutOverwriteMode { + fn from_glib(value: ostree_sys::OstreeRepoCheckoutOverwriteMode) -> Self { match value { 0 => RepoCheckoutOverwriteMode::None, 1 => RepoCheckoutOverwriteMode::UnionFiles, @@ -202,24 +260,36 @@ pub enum RepoMode { __Unknown(i32), } +impl fmt::Display for RepoMode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RepoMode::{}", match *self { + RepoMode::Bare => "Bare", + RepoMode::Archive => "Archive", + RepoMode::BareUser => "BareUser", + RepoMode::BareUserOnly => "BareUserOnly", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for RepoMode { - type GlibType = ffi::OstreeRepoMode; + type GlibType = ostree_sys::OstreeRepoMode; - fn to_glib(&self) -> ffi::OstreeRepoMode { + fn to_glib(&self) -> ostree_sys::OstreeRepoMode { match *self { - RepoMode::Bare => ffi::OSTREE_REPO_MODE_BARE, - RepoMode::Archive => ffi::OSTREE_REPO_MODE_ARCHIVE, - RepoMode::BareUser => ffi::OSTREE_REPO_MODE_BARE_USER, - RepoMode::BareUserOnly => ffi::OSTREE_REPO_MODE_BARE_USER_ONLY, + RepoMode::Bare => ostree_sys::OSTREE_REPO_MODE_BARE, + RepoMode::Archive => ostree_sys::OSTREE_REPO_MODE_ARCHIVE, + RepoMode::BareUser => ostree_sys::OSTREE_REPO_MODE_BARE_USER, + RepoMode::BareUserOnly => ostree_sys::OSTREE_REPO_MODE_BARE_USER_ONLY, RepoMode::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for RepoMode { - fn from_glib(value: ffi::OstreeRepoMode) -> Self { +impl FromGlib for RepoMode { + fn from_glib(value: ostree_sys::OstreeRepoMode) -> Self { match value { 0 => RepoMode::Bare, 1 => RepoMode::Archive, @@ -240,23 +310,34 @@ pub enum RepoPruneFlags { __Unknown(i32), } +impl fmt::Display for RepoPruneFlags { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RepoPruneFlags::{}", match *self { + RepoPruneFlags::None => "None", + RepoPruneFlags::NoPrune => "NoPrune", + RepoPruneFlags::RefsOnly => "RefsOnly", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for RepoPruneFlags { - type GlibType = ffi::OstreeRepoPruneFlags; + type GlibType = ostree_sys::OstreeRepoPruneFlags; - fn to_glib(&self) -> ffi::OstreeRepoPruneFlags { + fn to_glib(&self) -> ostree_sys::OstreeRepoPruneFlags { match *self { - RepoPruneFlags::None => ffi::OSTREE_REPO_PRUNE_FLAGS_NONE, - RepoPruneFlags::NoPrune => ffi::OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE, - RepoPruneFlags::RefsOnly => ffi::OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY, + RepoPruneFlags::None => ostree_sys::OSTREE_REPO_PRUNE_FLAGS_NONE, + RepoPruneFlags::NoPrune => ostree_sys::OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE, + RepoPruneFlags::RefsOnly => ostree_sys::OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY, RepoPruneFlags::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for RepoPruneFlags { - fn from_glib(value: ffi::OstreeRepoPruneFlags) -> Self { +impl FromGlib for RepoPruneFlags { + fn from_glib(value: ostree_sys::OstreeRepoPruneFlags) -> Self { match value { 0 => RepoPruneFlags::None, 1 => RepoPruneFlags::NoPrune, @@ -278,25 +359,38 @@ pub enum RepoRemoteChange { __Unknown(i32), } +impl fmt::Display for RepoRemoteChange { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RepoRemoteChange::{}", match *self { + RepoRemoteChange::Add => "Add", + RepoRemoteChange::AddIfNotExists => "AddIfNotExists", + RepoRemoteChange::Delete => "Delete", + RepoRemoteChange::DeleteIfExists => "DeleteIfExists", + RepoRemoteChange::Replace => "Replace", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for RepoRemoteChange { - type GlibType = ffi::OstreeRepoRemoteChange; + type GlibType = ostree_sys::OstreeRepoRemoteChange; - fn to_glib(&self) -> ffi::OstreeRepoRemoteChange { + fn to_glib(&self) -> ostree_sys::OstreeRepoRemoteChange { match *self { - RepoRemoteChange::Add => ffi::OSTREE_REPO_REMOTE_CHANGE_ADD, - RepoRemoteChange::AddIfNotExists => ffi::OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS, - RepoRemoteChange::Delete => ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE, - RepoRemoteChange::DeleteIfExists => ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS, - RepoRemoteChange::Replace => ffi::OSTREE_REPO_REMOTE_CHANGE_REPLACE, + RepoRemoteChange::Add => ostree_sys::OSTREE_REPO_REMOTE_CHANGE_ADD, + RepoRemoteChange::AddIfNotExists => ostree_sys::OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS, + RepoRemoteChange::Delete => ostree_sys::OSTREE_REPO_REMOTE_CHANGE_DELETE, + RepoRemoteChange::DeleteIfExists => ostree_sys::OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS, + RepoRemoteChange::Replace => ostree_sys::OSTREE_REPO_REMOTE_CHANGE_REPLACE, RepoRemoteChange::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for RepoRemoteChange { - fn from_glib(value: ffi::OstreeRepoRemoteChange) -> Self { +impl FromGlib for RepoRemoteChange { + fn from_glib(value: ostree_sys::OstreeRepoRemoteChange) -> Self { match value { 0 => RepoRemoteChange::Add, 1 => RepoRemoteChange::AddIfNotExists, @@ -317,22 +411,32 @@ pub enum StaticDeltaGenerateOpt { __Unknown(i32), } +impl fmt::Display for StaticDeltaGenerateOpt { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "StaticDeltaGenerateOpt::{}", match *self { + StaticDeltaGenerateOpt::Lowlatency => "Lowlatency", + StaticDeltaGenerateOpt::Major => "Major", + _ => "Unknown", + }) + } +} + #[doc(hidden)] impl ToGlib for StaticDeltaGenerateOpt { - type GlibType = ffi::OstreeStaticDeltaGenerateOpt; + type GlibType = ostree_sys::OstreeStaticDeltaGenerateOpt; - fn to_glib(&self) -> ffi::OstreeStaticDeltaGenerateOpt { + fn to_glib(&self) -> ostree_sys::OstreeStaticDeltaGenerateOpt { match *self { - StaticDeltaGenerateOpt::Lowlatency => ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY, - StaticDeltaGenerateOpt::Major => ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR, + StaticDeltaGenerateOpt::Lowlatency => ostree_sys::OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY, + StaticDeltaGenerateOpt::Major => ostree_sys::OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR, StaticDeltaGenerateOpt::__Unknown(value) => value } } } #[doc(hidden)] -impl FromGlib for StaticDeltaGenerateOpt { - fn from_glib(value: ffi::OstreeStaticDeltaGenerateOpt) -> Self { +impl FromGlib for StaticDeltaGenerateOpt { + fn from_glib(value: ostree_sys::OstreeStaticDeltaGenerateOpt) -> Self { match value { 0 => StaticDeltaGenerateOpt::Lowlatency, 1 => StaticDeltaGenerateOpt::Major, diff --git a/rust-bindings/rust/src/auto/flags.rs b/rust-bindings/rust/src/auto/flags.rs index ea60ba83..74541aa8 100644 --- a/rust-bindings/rust/src/auto/flags.rs +++ b/rust-bindings/rust/src/auto/flags.rs @@ -2,7 +2,6 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; use glib::StaticType; use glib::Type; use glib::translate::*; @@ -10,7 +9,8 @@ use glib::value::FromValue; use glib::value::FromValueOptional; use glib::value::SetValue; use glib::value::Value; -use gobject_ffi; +use gobject_sys; +use ostree_sys; #[cfg(any(feature = "v2015_7", feature = "dox"))] bitflags! { @@ -23,17 +23,17 @@ bitflags! { #[cfg(any(feature = "v2015_7", feature = "dox"))] #[doc(hidden)] impl ToGlib for RepoCommitState { - type GlibType = ffi::OstreeRepoCommitState; + type GlibType = ostree_sys::OstreeRepoCommitState; - fn to_glib(&self) -> ffi::OstreeRepoCommitState { + fn to_glib(&self) -> ostree_sys::OstreeRepoCommitState { self.bits() } } #[cfg(any(feature = "v2015_7", feature = "dox"))] #[doc(hidden)] -impl FromGlib for RepoCommitState { - fn from_glib(value: ffi::OstreeRepoCommitState) -> RepoCommitState { +impl FromGlib for RepoCommitState { + fn from_glib(value: ostree_sys::OstreeRepoCommitState) -> RepoCommitState { RepoCommitState::from_bits_truncate(value) } } @@ -49,16 +49,16 @@ bitflags! { #[doc(hidden)] impl ToGlib for RepoListRefsExtFlags { - type GlibType = ffi::OstreeRepoListRefsExtFlags; + type GlibType = ostree_sys::OstreeRepoListRefsExtFlags; - fn to_glib(&self) -> ffi::OstreeRepoListRefsExtFlags { + fn to_glib(&self) -> ostree_sys::OstreeRepoListRefsExtFlags { self.bits() } } #[doc(hidden)] -impl FromGlib for RepoListRefsExtFlags { - fn from_glib(value: ffi::OstreeRepoListRefsExtFlags) -> RepoListRefsExtFlags { +impl FromGlib for RepoListRefsExtFlags { + fn from_glib(value: ostree_sys::OstreeRepoListRefsExtFlags) -> RepoListRefsExtFlags { RepoListRefsExtFlags::from_bits_truncate(value) } } @@ -76,16 +76,16 @@ bitflags! { #[doc(hidden)] impl ToGlib for RepoPullFlags { - type GlibType = ffi::OstreeRepoPullFlags; + type GlibType = ostree_sys::OstreeRepoPullFlags; - fn to_glib(&self) -> ffi::OstreeRepoPullFlags { + fn to_glib(&self) -> ostree_sys::OstreeRepoPullFlags { self.bits() } } #[doc(hidden)] -impl FromGlib for RepoPullFlags { - fn from_glib(value: ffi::OstreeRepoPullFlags) -> RepoPullFlags { +impl FromGlib for RepoPullFlags { + fn from_glib(value: ostree_sys::OstreeRepoPullFlags) -> RepoPullFlags { RepoPullFlags::from_bits_truncate(value) } } @@ -99,16 +99,16 @@ bitflags! { #[doc(hidden)] impl ToGlib for RepoResolveRevExtFlags { - type GlibType = ffi::OstreeRepoResolveRevExtFlags; + type GlibType = ostree_sys::OstreeRepoResolveRevExtFlags; - fn to_glib(&self) -> ffi::OstreeRepoResolveRevExtFlags { + fn to_glib(&self) -> ostree_sys::OstreeRepoResolveRevExtFlags { self.bits() } } #[doc(hidden)] -impl FromGlib for RepoResolveRevExtFlags { - fn from_glib(value: ffi::OstreeRepoResolveRevExtFlags) -> RepoResolveRevExtFlags { +impl FromGlib for RepoResolveRevExtFlags { + fn from_glib(value: ostree_sys::OstreeRepoResolveRevExtFlags) -> RepoResolveRevExtFlags { RepoResolveRevExtFlags::from_bits_truncate(value) } } @@ -123,16 +123,16 @@ bitflags! { #[doc(hidden)] impl ToGlib for SePolicyRestoreconFlags { - type GlibType = ffi::OstreeSePolicyRestoreconFlags; + type GlibType = ostree_sys::OstreeSePolicyRestoreconFlags; - fn to_glib(&self) -> ffi::OstreeSePolicyRestoreconFlags { + fn to_glib(&self) -> ostree_sys::OstreeSePolicyRestoreconFlags { self.bits() } } #[doc(hidden)] -impl FromGlib for SePolicyRestoreconFlags { - fn from_glib(value: ffi::OstreeSePolicyRestoreconFlags) -> SePolicyRestoreconFlags { +impl FromGlib for SePolicyRestoreconFlags { + fn from_glib(value: ostree_sys::OstreeSePolicyRestoreconFlags) -> SePolicyRestoreconFlags { SePolicyRestoreconFlags::from_bits_truncate(value) } } @@ -150,16 +150,16 @@ bitflags! { #[doc(hidden)] impl ToGlib for SysrootSimpleWriteDeploymentFlags { - type GlibType = ffi::OstreeSysrootSimpleWriteDeploymentFlags; + type GlibType = ostree_sys::OstreeSysrootSimpleWriteDeploymentFlags; - fn to_glib(&self) -> ffi::OstreeSysrootSimpleWriteDeploymentFlags { + fn to_glib(&self) -> ostree_sys::OstreeSysrootSimpleWriteDeploymentFlags { self.bits() } } #[doc(hidden)] -impl FromGlib for SysrootSimpleWriteDeploymentFlags { - fn from_glib(value: ffi::OstreeSysrootSimpleWriteDeploymentFlags) -> SysrootSimpleWriteDeploymentFlags { +impl FromGlib for SysrootSimpleWriteDeploymentFlags { + fn from_glib(value: ostree_sys::OstreeSysrootSimpleWriteDeploymentFlags) -> SysrootSimpleWriteDeploymentFlags { SysrootSimpleWriteDeploymentFlags::from_bits_truncate(value) } } @@ -172,23 +172,23 @@ bitflags! { #[doc(hidden)] impl ToGlib for SysrootUpgraderFlags { - type GlibType = ffi::OstreeSysrootUpgraderFlags; + type GlibType = ostree_sys::OstreeSysrootUpgraderFlags; - fn to_glib(&self) -> ffi::OstreeSysrootUpgraderFlags { + fn to_glib(&self) -> ostree_sys::OstreeSysrootUpgraderFlags { self.bits() } } #[doc(hidden)] -impl FromGlib for SysrootUpgraderFlags { - fn from_glib(value: ffi::OstreeSysrootUpgraderFlags) -> SysrootUpgraderFlags { +impl FromGlib for SysrootUpgraderFlags { + fn from_glib(value: ostree_sys::OstreeSysrootUpgraderFlags) -> SysrootUpgraderFlags { SysrootUpgraderFlags::from_bits_truncate(value) } } impl StaticType for SysrootUpgraderFlags { fn static_type() -> Type { - unsafe { from_glib(ffi::ostree_sysroot_upgrader_flags_get_type()) } + unsafe { from_glib(ostree_sys::ostree_sysroot_upgrader_flags_get_type()) } } } @@ -200,13 +200,13 @@ impl<'a> FromValueOptional<'a> for SysrootUpgraderFlags { impl<'a> FromValue<'a> for SysrootUpgraderFlags { unsafe fn from_value(value: &Value) -> Self { - from_glib(gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0)) } } impl SetValue for SysrootUpgraderFlags { unsafe fn set_value(value: &mut Value, this: &Self) { - gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) + gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib()) } } @@ -220,16 +220,16 @@ bitflags! { #[doc(hidden)] impl ToGlib for SysrootUpgraderPullFlags { - type GlibType = ffi::OstreeSysrootUpgraderPullFlags; + type GlibType = ostree_sys::OstreeSysrootUpgraderPullFlags; - fn to_glib(&self) -> ffi::OstreeSysrootUpgraderPullFlags { + fn to_glib(&self) -> ostree_sys::OstreeSysrootUpgraderPullFlags { self.bits() } } #[doc(hidden)] -impl FromGlib for SysrootUpgraderPullFlags { - fn from_glib(value: ffi::OstreeSysrootUpgraderPullFlags) -> SysrootUpgraderPullFlags { +impl FromGlib for SysrootUpgraderPullFlags { + fn from_glib(value: ostree_sys::OstreeSysrootUpgraderPullFlags) -> SysrootUpgraderPullFlags { SysrootUpgraderPullFlags::from_bits_truncate(value) } } diff --git a/rust-bindings/rust/src/auto/functions.rs b/rust-bindings/rust/src/auto/functions.rs index b197a355..968131a2 100644 --- a/rust-bindings/rust/src/auto/functions.rs +++ b/rust-bindings/rust/src/auto/functions.rs @@ -4,22 +4,21 @@ use Error; use ObjectType; -use ffi; use gio; use glib; +use glib::GString; use glib::object::IsA; use glib::translate::*; +use ostree_sys; 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(); +pub fn break_hardlink>(dfd: i32, path: &str, skip_xattrs: bool, cancellable: Option<&P>) -> Result<(), Error> { 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); + let _ = ostree_sys::ostree_break_hardlink(dfd, path.to_glib_none().0, skip_xattrs.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -27,265 +26,243 @@ pub fn break_hardlink<'a, P: Into>>(dfd: i32, path: #[cfg(any(feature = "v2017_4", feature = "dox"))] pub fn check_version(required_year: u32, required_release: u32) -> bool { unsafe { - from_glib(ffi::ostree_check_version(required_year, required_release)) + from_glib(ostree_sys::ostree_check_version(required_year, required_release)) } } //#[cfg(any(feature = "v2016_8", feature = "dox"))] -//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_from_bytes(csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32) -> Option { +// unsafe { TODO: call ostree_sys: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_from_bytes(csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, buf: &str) { +// unsafe { TODO: call ostree_sys: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_inplace_to_bytes(checksum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 28 }; 32, buf: u8) { +// unsafe { TODO: call ostree_sys:ostree_checksum_b64_inplace_to_bytes() } //} //#[cfg(any(feature = "v2016_8", feature = "dox"))] -//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_b64_to_bytes(checksum: &str) -> /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 { +// unsafe { TODO: call ostree_sys: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(bytes: &glib::Variant) -> /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 { +// unsafe { TODO: call ostree_sys: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_bytes_peek_validate(bytes: &glib::Variant) -> Result { +// unsafe { TODO: call ostree_sys: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, Q: IsA>(f: &P, objtype: ObjectType, out_csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: Option<&Q>) -> Result<(), Error> { +// unsafe { TODO: call ostree_sys: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() } +//pub fn checksum_file_async, Q: IsA, R: FnOnce(Result<(), Error>) + 'static>(f: &P, objtype: ObjectType, io_priority: i32, cancellable: Option<&Q>, callback: R) { +// unsafe { TODO: call ostree_sys: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_at>(dfd: i32, path: &str, stbuf: /*Unimplemented*/Option, objtype: ObjectType, flags: /*Ignored*/ChecksumFlags, out_checksum: &str, cancellable: Option<&P>) -> Result<(), Error> { +// unsafe { TODO: call ostree_sys: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_file_from_input, Q: IsA>(file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, in_: Option<&P>, objtype: ObjectType, out_csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: Option<&Q>) -> Result<(), Error> { +// unsafe { TODO: call ostree_sys: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(csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32) -> Option { +// unsafe { TODO: call ostree_sys:ostree_checksum_from_bytes() } //} -pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> Option { +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)) + from_glib_full(ostree_sys::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_inplace_from_bytes(csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, buf: &str) { +// unsafe { TODO: call ostree_sys: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(checksum: &str) -> /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 { +// unsafe { TODO: call ostree_sys: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)) + from_glib_full(ostree_sys::ostree_checksum_to_bytes_v(checksum.to_glib_none().0)) } } //pub fn cmd__private__() -> /*Ignored*/Option { -// unsafe { TODO: call ffi::ostree_cmd__private__() } +// unsafe { TODO: call ostree_sys:ostree_cmd__private__() } //} #[cfg(any(feature = "v2018_2", feature = "dox"))] -pub fn commit_get_content_checksum(commit_variant: &glib::Variant) -> Option { +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)) + from_glib_full(ostree_sys::ostree_commit_get_content_checksum(commit_variant.to_glib_none().0)) } } -pub fn commit_get_parent(commit_variant: &glib::Variant) -> Option { +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)) + from_glib_full(ostree_sys::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) + ostree_sys::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(); +pub fn content_file_parse, Q: IsA>(compressed: bool, content_path: &P, trusted: bool, cancellable: Option<&Q>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), Error> { unsafe { let mut out_input = ptr::null_mut(); let mut out_file_info = ptr::null_mut(); let mut out_xattrs = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_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); + let _ = ostree_sys::ostree_content_file_parse(compressed.to_glib(), content_path.as_ref().to_glib_none().0, trusted.to_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) } } } -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(); +pub fn content_file_parse_at>(compressed: bool, parent_dfd: i32, path: &str, trusted: bool, cancellable: Option<&P>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), Error> { unsafe { let mut out_input = ptr::null_mut(); let mut out_file_info = ptr::null_mut(); let mut out_xattrs = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_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); + let _ = ostree_sys::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.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) } } } -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(); +pub fn content_stream_parse, Q: IsA>(compressed: bool, input: &P, input_length: u64, trusted: bool, cancellable: Option<&Q>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), Error> { unsafe { let mut out_input = ptr::null_mut(); let mut out_file_info = ptr::null_mut(); let mut out_xattrs = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_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); + let _ = ostree_sys::ostree_content_stream_parse(compressed.to_glib(), input.as_ref().to_glib_none().0, input_length, trusted.to_glib(), &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) } } } -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(); +pub fn create_directory_metadata(dir_info: &gio::FileInfo, xattrs: Option<&glib::Variant>) -> Option { unsafe { - from_glib_full(ffi::ostree_create_directory_metadata(dir_info.to_glib_none().0, xattrs.0)) + from_glib_full(ostree_sys::ostree_create_directory_metadata(dir_info.to_glib_none().0, xattrs.to_glib_none().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, Q: IsA, R: IsA>(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: Option<&R>) -> Result<(), Error> { +// unsafe { TODO: call ostree_sys:ostree_diff_dirs() } //} //#[cfg(any(feature = "v2017_4", feature = "dox"))] -//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_dirs_with_options, Q: IsA, R: IsA>(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: /*Ignored*/Option<&mut DiffDirsOptions>, cancellable: Option<&R>) -> Result<(), Error> { +// unsafe { TODO: call ostree_sys: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() } +// unsafe { TODO: call ostree_sys:ostree_diff_print() } //} //#[cfg(any(feature = "v2017_10", feature = "dox"))] //pub fn gpg_error_quark() -> /*Ignored*/glib::Quark { -// unsafe { TODO: call ffi::ostree_gpg_error_quark() } +// unsafe { TODO: call ostree_sys:ostree_gpg_error_quark() } //} -//pub fn hash_object_name>>(a: P) -> u32 { -// unsafe { TODO: call ffi::ostree_hash_object_name() } +//pub fn hash_object_name(a: /*Unimplemented*/Option) -> u32 { +// unsafe { TODO: call ostree_sys:ostree_hash_object_name() } //} //pub fn metadata_variant_type(objtype: ObjectType) -> /*Ignored*/Option { -// unsafe { TODO: call ffi::ostree_metadata_variant_type() } +// unsafe { TODO: call ostree_sys:ostree_metadata_variant_type() } //} -pub fn object_from_string(str: &str) -> (String, ObjectType) { +pub fn object_from_string(str: &str) -> (GString, 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); + ostree_sys::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) { +pub fn object_name_deserialize(variant: &glib::Variant) -> (GString, 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); + ostree_sys::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())) + from_glib_none(ostree_sys::ostree_object_name_serialize(checksum.to_glib_none().0, objtype.to_glib())) } } -pub fn object_to_string(checksum: &str, objtype: ObjectType) -> Option { +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())) + from_glib_full(ostree_sys::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)) + from_glib(ostree_sys::ostree_object_type_from_string(str.to_glib_none().0)) } } -pub fn object_type_to_string(objtype: ObjectType) -> Option { +pub fn object_type_to_string(objtype: ObjectType) -> Option { unsafe { - from_glib_none(ffi::ostree_object_type_to_string(objtype.to_glib())) + from_glib_none(ostree_sys::ostree_object_type_to_string(objtype.to_glib())) } } -pub fn parse_refspec(refspec: &str) -> Result<(Option, String), Error> { +pub fn parse_refspec(refspec: &str) -> Result<(Option, GString), 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); + let _ = ostree_sys::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)) } } } #[cfg(any(feature = "v2016_6", feature = "dox"))] -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(); +pub fn raw_file_to_archive_z2_stream, Q: IsA>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result { 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); + let _ = ostree_sys::ostree_raw_file_to_archive_z2_stream(input.as_ref().to_glib_none().0, file_info.to_glib_none().0, xattrs.to_glib_none().0, &mut out_input, cancellable.map(|p| p.as_ref()).to_glib_none().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(); +pub fn raw_file_to_archive_z2_stream_with_options, Q: IsA>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, options: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result { 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); + let _ = ostree_sys::ostree_raw_file_to_archive_z2_stream_with_options(input.as_ref().to_glib_none().0, file_info.to_glib_none().0, xattrs.to_glib_none().0, options.to_glib_none().0, &mut out_input, cancellable.map(|p| p.as_ref()).to_glib_none().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(); +pub fn raw_file_to_content_stream, Q: IsA>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<(gio::InputStream, u64), Error> { 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); + let _ = ostree_sys::ostree_raw_file_to_content_stream(input.as_ref().to_glib_none().0, file_info.to_glib_none().0, xattrs.to_glib_none().0, &mut out_input, &mut out_length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok((from_glib_full(out_input), out_length)) } else { Err(from_glib_full(error)) } } } @@ -293,18 +270,16 @@ pub fn raw_file_to_content_stream<'a, 'b, P: IsA, Q: Into Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_validate_checksum_string(sha256.to_glib_none().0, &mut error); + let _ = ostree_sys::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(); +pub fn validate_collection_id(collection_id: Option<&str>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_validate_collection_id(collection_id.0, &mut error); + let _ = ostree_sys::ostree_validate_collection_id(collection_id.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -313,7 +288,7 @@ pub fn validate_collection_id<'a, P: Into>>(collection_id: P) -> 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); + let _ = ostree_sys::ostree_validate_remote_name(remote_name.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -321,7 +296,7 @@ pub fn validate_remote_name(remote_name: &str) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_rev(rev.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -329,7 +304,7 @@ pub fn validate_rev(rev: &str) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_structureof_checksum_string(checksum.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -337,7 +312,7 @@ pub fn validate_structureof_checksum_string(checksum: &str) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_structureof_commit(commit.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -345,7 +320,7 @@ pub fn validate_structureof_commit(commit: &glib::Variant) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_structureof_csum_v(checksum.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -353,7 +328,7 @@ pub fn validate_structureof_csum_v(checksum: &glib::Variant) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_structureof_dirmeta(dirmeta.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -361,7 +336,7 @@ pub fn validate_structureof_dirmeta(dirmeta: &glib::Variant) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_structureof_dirtree(dirtree.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -369,7 +344,7 @@ pub fn validate_structureof_dirtree(dirtree: &glib::Variant) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_structureof_file_mode(mode, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -377,7 +352,7 @@ pub fn validate_structureof_file_mode(mode: u32) -> Result<(), 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); + let _ = ostree_sys::ostree_validate_structureof_objtype(objtype, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } diff --git a/rust-bindings/rust/src/auto/gpg_verify_result.rs b/rust-bindings/rust/src/auto/gpg_verify_result.rs index 0f29e26d..515f74dc 100644 --- a/rust-bindings/rust/src/auto/gpg_verify_result.rs +++ b/rust-bindings/rust/src/auto/gpg_verify_result.rs @@ -5,95 +5,77 @@ #[cfg(any(feature = "v2016_6", feature = "dox"))] use Error; use GpgSignatureFormatFlags; -use ffi; use glib; -use glib::object::IsA; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use ostree_sys; +use std::fmt; use std::mem; +#[cfg(any(feature = "v2016_6", feature = "dox"))] use std::ptr; glib_wrapper! { - pub struct GpgVerifyResult(Object); + pub struct GpgVerifyResult(Object); match fn { - get_type => || ffi::ostree_gpg_verify_result_get_type(), + get_type => || ostree_sys::ostree_gpg_verify_result_get_type(), } } impl GpgVerifyResult { - 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(); + pub fn count_all(&self) -> u32 { unsafe { - ffi::ostree_gpg_verify_result_describe_variant(variant.to_glib_none().0, output_buffer.to_glib_none_mut().0, line_prefix.0, flags.to_glib()); - } - } -} - -pub trait GpgVerifyResultExt { - fn count_all(&self) -> u32; - - fn count_valid(&self) -> u32; - - 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; - - fn get_all(&self, signature_index: u32) -> Option; - - fn lookup(&self, key_id: &str) -> Option; - - #[cfg(any(feature = "v2016_6", feature = "dox"))] - fn require_valid_signature(&self) -> Result<(), Error>; -} - -impl> GpgVerifyResultExt for O { - fn count_all(&self) -> u32 { - unsafe { - ffi::ostree_gpg_verify_result_count_all(self.to_glib_none().0) + ostree_sys::ostree_gpg_verify_result_count_all(self.to_glib_none().0) } } - fn count_valid(&self) -> u32 { + pub fn count_valid(&self) -> u32 { unsafe { - ffi::ostree_gpg_verify_result_count_valid(self.to_glib_none().0) + ostree_sys::ostree_gpg_verify_result_count_valid(self.to_glib_none().0) } } - fn describe<'a, P: Into>>(&self, signature_index: u32, output_buffer: &mut glib::String, line_prefix: P, flags: GpgSignatureFormatFlags) { - let line_prefix = line_prefix.into(); - let line_prefix = line_prefix.to_glib_none(); + pub fn describe(&self, signature_index: u32, output_buffer: &mut glib::String, line_prefix: Option<&str>, flags: GpgSignatureFormatFlags) { unsafe { - ffi::ostree_gpg_verify_result_describe(self.to_glib_none().0, signature_index, output_buffer.to_glib_none_mut().0, line_prefix.0, flags.to_glib()); + ostree_sys::ostree_gpg_verify_result_describe(self.to_glib_none().0, signature_index, output_buffer.to_glib_none_mut().0, line_prefix.to_glib_none().0, flags.to_glib()); } } - //fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 26 }) -> Option { - // unsafe { TODO: call ffi::ostree_gpg_verify_result_get() } + //pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 26 }) -> Option { + // unsafe { TODO: call ostree_sys:ostree_gpg_verify_result_get() } //} - fn get_all(&self, signature_index: u32) -> Option { + pub fn get_all(&self, signature_index: u32) -> Option { unsafe { - from_glib_full(ffi::ostree_gpg_verify_result_get_all(self.to_glib_none().0, signature_index)) + from_glib_full(ostree_sys::ostree_gpg_verify_result_get_all(self.to_glib_none().0, signature_index)) } } - fn lookup(&self, key_id: &str) -> Option { + pub fn lookup(&self, key_id: &str) -> Option { unsafe { let mut out_signature_index = mem::uninitialized(); - let ret = from_glib(ffi::ostree_gpg_verify_result_lookup(self.to_glib_none().0, key_id.to_glib_none().0, &mut out_signature_index)); + let ret = from_glib(ostree_sys::ostree_gpg_verify_result_lookup(self.to_glib_none().0, key_id.to_glib_none().0, &mut out_signature_index)); if ret { Some(out_signature_index) } else { None } } } #[cfg(any(feature = "v2016_6", feature = "dox"))] - fn require_valid_signature(&self) -> Result<(), Error> { + pub fn require_valid_signature(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_gpg_verify_result_require_valid_signature(self.to_glib_none().0, &mut error); + let _ = ostree_sys::ostree_gpg_verify_result_require_valid_signature(self.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } + + pub fn describe_variant(variant: &glib::Variant, output_buffer: &mut glib::String, line_prefix: Option<&str>, flags: GpgSignatureFormatFlags) { + unsafe { + ostree_sys::ostree_gpg_verify_result_describe_variant(variant.to_glib_none().0, output_buffer.to_glib_none_mut().0, line_prefix.to_glib_none().0, flags.to_glib()); + } + } +} + +impl fmt::Display for GpgVerifyResult { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "GpgVerifyResult") + } } diff --git a/rust-bindings/rust/src/auto/mod.rs b/rust-bindings/rust/src/auto/mod.rs index f6d31a39..9afc9d78 100644 --- a/rust-bindings/rust/src/auto/mod.rs +++ b/rust-bindings/rust/src/auto/mod.rs @@ -3,44 +3,37 @@ // DO NOT EDIT mod async_progress; -pub use self::async_progress::AsyncProgress; +pub use self::async_progress::{AsyncProgress, AsyncProgressClass, NONE_ASYNC_PROGRESS}; pub use self::async_progress::AsyncProgressExt; mod bootconfig_parser; -pub use self::bootconfig_parser::BootconfigParser; -pub use self::bootconfig_parser::BootconfigParserExt; +pub use self::bootconfig_parser::{BootconfigParser, BootconfigParserClass}; mod deployment; -pub use self::deployment::Deployment; -pub use self::deployment::DeploymentExt; +pub use self::deployment::{Deployment, DeploymentClass}; mod gpg_verify_result; -pub use self::gpg_verify_result::GpgVerifyResult; -pub use self::gpg_verify_result::GpgVerifyResultExt; +pub use self::gpg_verify_result::{GpgVerifyResult, GpgVerifyResultClass}; mod mutable_tree; -pub use self::mutable_tree::MutableTree; +pub use self::mutable_tree::{MutableTree, MutableTreeClass, NONE_MUTABLE_TREE}; pub use self::mutable_tree::MutableTreeExt; mod repo; -pub use self::repo::Repo; -pub use self::repo::RepoExt; +pub use self::repo::{Repo, RepoClass}; mod repo_file; -pub use self::repo_file::RepoFile; +pub use self::repo_file::{RepoFile, RepoFileClass, NONE_REPO_FILE}; pub use self::repo_file::RepoFileExt; mod se_policy; -pub use self::se_policy::SePolicy; -pub use self::se_policy::SePolicyExt; +pub use self::se_policy::{SePolicy, SePolicyClass}; mod sysroot; -pub use self::sysroot::Sysroot; -pub use self::sysroot::SysrootExt; +pub use self::sysroot::{Sysroot, SysrootClass}; mod sysroot_upgrader; -pub use self::sysroot_upgrader::SysrootUpgrader; -pub use self::sysroot_upgrader::SysrootUpgraderExt; +pub use self::sysroot_upgrader::{SysrootUpgrader, SysrootUpgraderClass}; #[cfg(any(feature = "v2018_6", feature = "dox"))] mod remote; @@ -109,13 +102,6 @@ pub use self::constants::TREE_GVARIANT_STRING; #[doc(hidden)] pub mod traits { pub use super::AsyncProgressExt; - pub use super::BootconfigParserExt; - pub use super::DeploymentExt; - pub use super::GpgVerifyResultExt; pub use super::MutableTreeExt; - pub use super::RepoExt; pub use super::RepoFileExt; - pub use super::SePolicyExt; - pub use super::SysrootExt; - pub use super::SysrootUpgraderExt; } diff --git a/rust-bindings/rust/src/auto/mutable_tree.rs b/rust-bindings/rust/src/auto/mutable_tree.rs index 0844fc81..57acdbae 100644 --- a/rust-bindings/rust/src/auto/mutable_tree.rs +++ b/rust-bindings/rust/src/auto/mutable_tree.rs @@ -5,33 +5,32 @@ use Error; #[cfg(any(feature = "v2018_7", feature = "dox"))] use Repo; -use ffi; +use glib::GString; use glib::object::IsA; use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; +use ostree_sys; +use std::fmt; use std::ptr; glib_wrapper! { - pub struct MutableTree(Object); + pub struct MutableTree(Object); match fn { - get_type => || ffi::ostree_mutable_tree_get_type(), + get_type => || ostree_sys::ostree_mutable_tree_get_type(), } } impl MutableTree { pub fn new() -> MutableTree { unsafe { - from_glib_full(ffi::ostree_mutable_tree_new()) + from_glib_full(ostree_sys::ostree_mutable_tree_new()) } } #[cfg(any(feature = "v2018_7", feature = "dox"))] 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)) + from_glib_full(ostree_sys::ostree_mutable_tree_new_from_checksum(repo.to_glib_none().0, contents_checksum.to_glib_none().0, metadata_checksum.to_glib_none().0)) } } } @@ -42,7 +41,9 @@ impl Default for MutableTree { } } -pub trait MutableTreeExt { +pub const NONE_MUTABLE_TREE: Option<&MutableTree> = None; + +pub trait MutableTreeExt: 'static { #[cfg(any(feature = "v2018_7", feature = "dox"))] fn check_error(&self) -> Result<(), Error>; @@ -53,15 +54,15 @@ pub trait MutableTreeExt { #[cfg(any(feature = "v2018_7", feature = "dox"))] fn fill_empty_from_dirtree(&self, repo: &Repo, contents_checksum: &str, metadata_checksum: &str) -> bool; - fn get_contents_checksum(&self) -> Option; + fn get_contents_checksum(&self) -> Option; //fn get_files(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }; - fn get_metadata_checksum(&self) -> Option; + fn get_metadata_checksum(&self) -> Option; //fn get_subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 37 }; - fn lookup(&self, name: &str) -> Result<(String, MutableTree), Error>; + fn lookup(&self, name: &str) -> Result<(GString, MutableTree), Error>; #[cfg(any(feature = "v2018_9", feature = "dox"))] fn remove(&self, name: &str, allow_noent: bool) -> Result<(), Error>; @@ -80,7 +81,7 @@ impl> MutableTreeExt for O { fn check_error(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_mutable_tree_check_error(self.to_glib_none().0, &mut error); + let _ = ostree_sys::ostree_mutable_tree_check_error(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -89,48 +90,48 @@ impl> MutableTreeExt for O { unsafe { let mut out_subdir = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_mutable_tree_ensure_dir(self.to_glib_none().0, name.to_glib_none().0, &mut out_subdir, &mut error); + let _ = ostree_sys::ostree_mutable_tree_ensure_dir(self.as_ref().to_glib_none().0, name.to_glib_none().0, &mut out_subdir, &mut error); if error.is_null() { Ok(from_glib_full(out_subdir)) } else { Err(from_glib_full(error)) } } } //fn ensure_parent_dirs(&self, split_path: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 0, id: 28 }, metadata_checksum: &str) -> Result { - // unsafe { TODO: call ffi::ostree_mutable_tree_ensure_parent_dirs() } + // unsafe { TODO: call ostree_sys:ostree_mutable_tree_ensure_parent_dirs() } //} #[cfg(any(feature = "v2018_7", feature = "dox"))] fn fill_empty_from_dirtree(&self, repo: &Repo, contents_checksum: &str, metadata_checksum: &str) -> bool { unsafe { - from_glib(ffi::ostree_mutable_tree_fill_empty_from_dirtree(self.to_glib_none().0, repo.to_glib_none().0, contents_checksum.to_glib_none().0, metadata_checksum.to_glib_none().0)) + from_glib(ostree_sys::ostree_mutable_tree_fill_empty_from_dirtree(self.as_ref().to_glib_none().0, repo.to_glib_none().0, contents_checksum.to_glib_none().0, metadata_checksum.to_glib_none().0)) } } - fn get_contents_checksum(&self) -> Option { + fn get_contents_checksum(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_mutable_tree_get_contents_checksum(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_mutable_tree_get_contents_checksum(self.as_ref().to_glib_none().0)) } } //fn get_files(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 } { - // unsafe { TODO: call ffi::ostree_mutable_tree_get_files() } + // unsafe { TODO: call ostree_sys:ostree_mutable_tree_get_files() } //} - fn get_metadata_checksum(&self) -> Option { + fn get_metadata_checksum(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_mutable_tree_get_metadata_checksum(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_mutable_tree_get_metadata_checksum(self.as_ref().to_glib_none().0)) } } //fn get_subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 37 } { - // unsafe { TODO: call ffi::ostree_mutable_tree_get_subdirs() } + // unsafe { TODO: call ostree_sys:ostree_mutable_tree_get_subdirs() } //} - fn lookup(&self, name: &str) -> Result<(String, MutableTree), Error> { + fn lookup(&self, name: &str) -> Result<(GString, MutableTree), Error> { unsafe { let mut out_file_checksum = ptr::null_mut(); let mut out_subdir = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_mutable_tree_lookup(self.to_glib_none().0, name.to_glib_none().0, &mut out_file_checksum, &mut out_subdir, &mut error); + let _ = ostree_sys::ostree_mutable_tree_lookup(self.as_ref().to_glib_none().0, name.to_glib_none().0, &mut out_file_checksum, &mut out_subdir, &mut error); if error.is_null() { Ok((from_glib_full(out_file_checksum), from_glib_full(out_subdir))) } else { Err(from_glib_full(error)) } } } @@ -139,7 +140,7 @@ impl> MutableTreeExt for O { fn remove(&self, name: &str, allow_noent: bool) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_mutable_tree_remove(self.to_glib_none().0, name.to_glib_none().0, allow_noent.to_glib(), &mut error); + let _ = ostree_sys::ostree_mutable_tree_remove(self.as_ref().to_glib_none().0, name.to_glib_none().0, allow_noent.to_glib(), &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } @@ -147,24 +148,30 @@ impl> MutableTreeExt for O { fn replace_file(&self, name: &str, checksum: &str) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_mutable_tree_replace_file(self.to_glib_none().0, name.to_glib_none().0, checksum.to_glib_none().0, &mut error); + let _ = ostree_sys::ostree_mutable_tree_replace_file(self.as_ref().to_glib_none().0, name.to_glib_none().0, checksum.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_contents_checksum(&self, checksum: &str) { unsafe { - ffi::ostree_mutable_tree_set_contents_checksum(self.to_glib_none().0, checksum.to_glib_none().0); + ostree_sys::ostree_mutable_tree_set_contents_checksum(self.as_ref().to_glib_none().0, checksum.to_glib_none().0); } } fn set_metadata_checksum(&self, checksum: &str) { unsafe { - ffi::ostree_mutable_tree_set_metadata_checksum(self.to_glib_none().0, checksum.to_glib_none().0); + ostree_sys::ostree_mutable_tree_set_metadata_checksum(self.as_ref().to_glib_none().0, checksum.to_glib_none().0); } } //fn walk(&self, split_path: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 0, id: 28 }, start: u32) -> Result { - // unsafe { TODO: call ffi::ostree_mutable_tree_walk() } + // unsafe { TODO: call ostree_sys:ostree_mutable_tree_walk() } //} } + +impl fmt::Display for MutableTree { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "MutableTree") + } +} diff --git a/rust-bindings/rust/src/auto/remote.rs b/rust-bindings/rust/src/auto/remote.rs index c887c456..3933985f 100644 --- a/rust-bindings/rust/src/auto/remote.rs +++ b/rust-bindings/rust/src/auto/remote.rs @@ -2,36 +2,35 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; +#[cfg(any(feature = "v2018_6", feature = "dox"))] +use glib::GString; +#[cfg(any(feature = "v2018_6", feature = "dox"))] use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::ptr; +use ostree_sys; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct Remote(Shared); + pub struct Remote(Shared); match fn { - ref => |ptr| ffi::ostree_remote_ref(ptr), - unref => |ptr| ffi::ostree_remote_unref(ptr), - get_type => || ffi::ostree_remote_get_type(), + ref => |ptr| ostree_sys::ostree_remote_ref(ptr), + unref => |ptr| ostree_sys::ostree_remote_unref(ptr), + get_type => || ostree_sys::ostree_remote_get_type(), } } impl Remote { #[cfg(any(feature = "v2018_6", feature = "dox"))] - pub fn get_name(&self) -> Option { + pub fn get_name(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_remote_get_name(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_remote_get_name(self.to_glib_none().0)) } } #[cfg(any(feature = "v2018_6", feature = "dox"))] - pub fn get_url(&self) -> Option { + pub fn get_url(&self) -> Option { unsafe { - from_glib_full(ffi::ostree_remote_get_url(self.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_remote_get_url(self.to_glib_none().0)) } } } diff --git a/rust-bindings/rust/src/auto/repo.rs b/rust-bindings/rust/src/auto/repo.rs index aa743049..57531243 100644 --- a/rust-bindings/rust/src/auto/repo.rs +++ b/rust-bindings/rust/src/auto/repo.rs @@ -25,58 +25,922 @@ use RepoRemoteChange; use RepoResolveRevExtFlags; use RepoTransactionStats; use StaticDeltaGenerateOpt; -use ffi; use gio; use glib; +use glib::GString; use glib::StaticType; use glib::Value; -use glib::object::Downcast; use glib::object::IsA; +use glib::object::ObjectType as _; use glib::signal::SignalHandlerId; -use glib::signal::connect; +use glib::signal::connect_raw; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib_sys; +use gobject_sys; use libc; +use ostree_sys; use std::boxed::Box as Box_; +use std::fmt; use std::mem; use std::mem::transmute; use std::ptr; glib_wrapper! { - pub struct Repo(Object); + pub struct Repo(Object); match fn { - get_type => || ffi::ostree_repo_get_type(), + get_type => || ostree_sys::ostree_repo_get_type(), } } impl Repo { pub fn new>(path: &P) -> Repo { unsafe { - from_glib_full(ffi::ostree_repo_new(path.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_repo_new(path.as_ref().to_glib_none().0)) } } pub fn new_default() -> Repo { unsafe { - from_glib_full(ffi::ostree_repo_new_default()) + from_glib_full(ostree_sys::ostree_repo_new_default()) } } 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)) + from_glib_full(ostree_sys::ostree_repo_new_for_sysroot_path(repo_path.as_ref().to_glib_none().0, sysroot_path.as_ref().to_glib_none().0)) + } + } + + pub fn abort_transaction>(&self, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_abort_transaction(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn add_gpg_signature_summary>(&self, key_id: &[&str], homedir: Option<&str>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_add_gpg_signature_summary(self.to_glib_none().0, key_id.to_glib_none().0, homedir.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn append_gpg_signature>(&self, commit_checksum: &str, signature_bytes: &glib::Bytes, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_append_gpg_signature(self.to_glib_none().0, commit_checksum.to_glib_none().0, signature_bytes.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + //#[cfg(any(feature = "v2016_8", feature = "dox"))] + //pub fn checkout_at>(&self, options: /*Ignored*/Option<&mut RepoCheckoutAtOptions>, destination_dfd: i32, destination_path: &str, commit: &str, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_checkout_at() } + //} + + pub fn checkout_gc>(&self, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_checkout_gc(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn checkout_tree, Q: IsA, R: IsA>(&self, mode: RepoCheckoutMode, overwrite_mode: RepoCheckoutOverwriteMode, destination: &P, source: &Q, source_info: &gio::FileInfo, cancellable: Option<&R>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_checkout_tree(self.to_glib_none().0, mode.to_glib(), overwrite_mode.to_glib(), destination.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, source_info.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + //pub fn checkout_tree_at>(&self, options: /*Ignored*/Option<&mut RepoCheckoutOptions>, destination_dfd: i32, destination_path: &str, commit: &str, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_checkout_tree_at() } + //} + + pub fn commit_transaction>(&self, cancellable: Option<&P>) -> Result { + unsafe { + let mut out_stats = RepoTransactionStats::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_commit_transaction(self.to_glib_none().0, out_stats.to_glib_none_mut().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(out_stats) } else { Err(from_glib_full(error)) } + } + } + + pub fn copy_config(&self) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_repo_copy_config(self.to_glib_none().0)) + } + } + + pub fn create>(&self, mode: RepoMode, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_create(self.to_glib_none().0, mode.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn delete_object>(&self, objtype: ObjectType, sha256: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_delete_object(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2017_12", feature = "dox"))] + pub fn equal(&self, b: &Repo) -> bool { + unsafe { + from_glib(ostree_sys::ostree_repo_equal(self.to_glib_none().0, b.to_glib_none().0)) + } + } + + //pub fn export_tree_to_archive, Q: IsA>(&self, opts: /*Ignored*/&mut RepoExportArchiveOptions, root: &P, archive: /*Unimplemented*/Option, cancellable: Option<&Q>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_export_tree_to_archive() } + //} + + #[cfg(any(feature = "v2017_15", feature = "dox"))] + pub fn fsck_object>(&self, objtype: ObjectType, sha256: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_fsck_object(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2019_2", feature = "dox"))] + pub fn get_bootloader(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_repo_get_bootloader(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2018_6", feature = "dox"))] + pub fn get_collection_id(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_repo_get_collection_id(self.to_glib_none().0)) + } + } + + pub fn get_config(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_repo_get_config(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2018_9", feature = "dox"))] + pub fn get_default_repo_finders(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(ostree_sys::ostree_repo_get_default_repo_finders(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2016_4", feature = "dox"))] + pub fn get_dfd(&self) -> i32 { + unsafe { + ostree_sys::ostree_repo_get_dfd(self.to_glib_none().0) + } + } + + pub fn get_disable_fsync(&self) -> bool { + unsafe { + from_glib(ostree_sys::ostree_repo_get_disable_fsync(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2018_9", feature = "dox"))] + pub fn get_min_free_space_bytes(&self) -> Result { + unsafe { + let mut out_reserved_bytes = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_get_min_free_space_bytes(self.to_glib_none().0, &mut out_reserved_bytes, &mut error); + if error.is_null() { Ok(out_reserved_bytes) } else { Err(from_glib_full(error)) } + } + } + + pub fn get_mode(&self) -> RepoMode { + unsafe { + from_glib(ostree_sys::ostree_repo_get_mode(self.to_glib_none().0)) + } + } + + pub fn get_parent(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_repo_get_parent(self.to_glib_none().0)) + } + } + + pub fn get_path(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_repo_get_path(self.to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2016_5", feature = "dox"))] + pub fn get_remote_boolean_option(&self, remote_name: &str, option_name: &str, default_value: bool) -> Result { + unsafe { + let mut out_value = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_get_remote_boolean_option(self.to_glib_none().0, remote_name.to_glib_none().0, option_name.to_glib_none().0, default_value.to_glib(), &mut out_value, &mut error); + if error.is_null() { Ok(from_glib(out_value)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_5", feature = "dox"))] + pub fn get_remote_list_option(&self, remote_name: &str, option_name: &str) -> Result, Error> { + unsafe { + let mut out_value = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_get_remote_list_option(self.to_glib_none().0, remote_name.to_glib_none().0, option_name.to_glib_none().0, &mut out_value, &mut error); + if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(out_value)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_5", feature = "dox"))] + pub fn get_remote_option(&self, remote_name: &str, option_name: &str, default_value: Option<&str>) -> Result { + unsafe { + let mut out_value = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_get_remote_option(self.to_glib_none().0, remote_name.to_glib_none().0, option_name.to_glib_none().0, default_value.to_glib_none().0, &mut out_value, &mut error); + if error.is_null() { Ok(from_glib_full(out_value)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_6", feature = "dox"))] + pub fn gpg_verify_data, Q: IsA, R: IsA>(&self, remote_name: Option<&str>, data: &glib::Bytes, signatures: &glib::Bytes, keyringdir: Option<&P>, extra_keyring: Option<&Q>, cancellable: Option<&R>) -> Result { + unsafe { + let mut error = ptr::null_mut(); + let ret = ostree_sys::ostree_repo_gpg_verify_data(self.to_glib_none().0, remote_name.to_glib_none().0, data.to_glib_none().0, signatures.to_glib_none().0, keyringdir.map(|p| p.as_ref()).to_glib_none().0, extra_keyring.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + } + } + + pub fn has_object>(&self, objtype: ObjectType, checksum: &str, cancellable: Option<&P>) -> Result { + unsafe { + let mut out_have_object = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_has_object(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, &mut out_have_object, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib(out_have_object)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2017_12", feature = "dox"))] + pub fn hash(&self) -> u32 { + unsafe { + ostree_sys::ostree_repo_hash(self.to_glib_none().0) + } + } + + //pub fn import_archive_to_mtree, Q: IsA>(&self, opts: /*Ignored*/&mut RepoImportArchiveOptions, archive: /*Unimplemented*/Option, mtree: &P, modifier: Option<&RepoCommitModifier>, cancellable: Option<&Q>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_import_archive_to_mtree() } + //} + + pub fn import_object_from>(&self, source: &Repo, objtype: ObjectType, checksum: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_import_object_from(self.to_glib_none().0, source.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_5", feature = "dox"))] + pub fn import_object_from_with_trust>(&self, source: &Repo, objtype: ObjectType, checksum: &str, trusted: bool, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_import_object_from_with_trust(self.to_glib_none().0, source.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, trusted.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn is_system(&self) -> bool { + unsafe { + from_glib(ostree_sys::ostree_repo_is_system(self.to_glib_none().0)) + } + } + + pub fn is_writable(&self) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_is_writable(self.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 list_collection_refs>(&self, match_collection_id: Option<&str>, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, flags: RepoListRefsExtFlags, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_list_collection_refs() } + //} + + //pub fn list_commit_objects_starting_with>(&self, start: &str, out_commits: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_list_commit_objects_starting_with() } + //} + + //pub fn list_objects>(&self, flags: /*Ignored*/RepoListObjectsFlags, out_objects: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_list_objects() } + //} + + //pub fn list_refs>(&self, refspec_prefix: Option<&str>, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_list_refs() } + //} + + //#[cfg(any(feature = "v2016_4", feature = "dox"))] + //pub fn list_refs_ext>(&self, refspec_prefix: Option<&str>, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, flags: RepoListRefsExtFlags, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_list_refs_ext() } + //} + + //pub fn list_static_delta_names>(&self, out_deltas: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 0, id: 28 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_list_static_delta_names() } + //} + + #[cfg(any(feature = "v2015_7", feature = "dox"))] + pub fn load_commit(&self, checksum: &str) -> Result<(glib::Variant, RepoCommitState), Error> { + unsafe { + let mut out_commit = ptr::null_mut(); + let mut out_state = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_load_commit(self.to_glib_none().0, checksum.to_glib_none().0, &mut out_commit, &mut out_state, &mut error); + if error.is_null() { Ok((from_glib_full(out_commit), from_glib(out_state))) } else { Err(from_glib_full(error)) } + } + } + + pub fn load_file>(&self, checksum: &str, cancellable: Option<&P>) -> Result<(Option, Option, Option), Error> { + unsafe { + let mut out_input = ptr::null_mut(); + let mut out_file_info = ptr::null_mut(); + let mut out_xattrs = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_load_file(self.to_glib_none().0, checksum.to_glib_none().0, &mut out_input, &mut out_file_info, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok((from_glib_full(out_input), from_glib_full(out_file_info), from_glib_full(out_xattrs))) } else { Err(from_glib_full(error)) } + } + } + + pub fn load_object_stream>(&self, objtype: ObjectType, checksum: &str, cancellable: Option<&P>) -> Result<(gio::InputStream, u64), Error> { + unsafe { + let mut out_input = ptr::null_mut(); + let mut out_size = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_load_object_stream(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, &mut out_input, &mut out_size, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok((from_glib_full(out_input), out_size)) } else { Err(from_glib_full(error)) } + } + } + + pub fn load_variant(&self, objtype: ObjectType, sha256: &str) -> Result { + unsafe { + let mut out_variant = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_load_variant(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, &mut out_variant, &mut error); + if error.is_null() { Ok(from_glib_full(out_variant)) } else { Err(from_glib_full(error)) } + } + } + + pub fn load_variant_if_exists(&self, objtype: ObjectType, sha256: &str) -> Result { + unsafe { + let mut out_variant = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_load_variant_if_exists(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, &mut out_variant, &mut error); + if error.is_null() { Ok(from_glib_full(out_variant)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2017_15", feature = "dox"))] + pub fn mark_commit_partial(&self, checksum: &str, is_partial: bool) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_mark_commit_partial(self.to_glib_none().0, checksum.to_glib_none().0, is_partial.to_glib(), &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn open>(&self, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_open(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn prepare_transaction>(&self, cancellable: Option<&P>) -> Result { + unsafe { + let mut out_transaction_resume = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_prepare_transaction(self.to_glib_none().0, &mut out_transaction_resume, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib(out_transaction_resume)) } else { Err(from_glib_full(error)) } + } + } + + pub fn prune>(&self, flags: RepoPruneFlags, depth: i32, cancellable: Option<&P>) -> Result<(i32, i32, u64), Error> { + unsafe { + let mut out_objects_total = mem::uninitialized(); + let mut out_objects_pruned = mem::uninitialized(); + let mut out_pruned_object_size_total = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_prune(self.to_glib_none().0, flags.to_glib(), depth, &mut out_objects_total, &mut out_objects_pruned, &mut out_pruned_object_size_total, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok((out_objects_total, out_objects_pruned, out_pruned_object_size_total)) } else { Err(from_glib_full(error)) } + } + } + + //#[cfg(any(feature = "v2017_1", feature = "dox"))] + //pub fn prune_from_reachable>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: Option<&P>) -> Result<(i32, i32, u64), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_prune_from_reachable() } + //} + + pub fn prune_static_deltas>(&self, commit: Option<&str>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_prune_static_deltas(self.to_glib_none().0, commit.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn pull, Q: IsA>(&self, remote_name: &str, refs_to_fetch: &[&str], flags: RepoPullFlags, progress: Option<&P>, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_pull(self.to_glib_none().0, remote_name.to_glib_none().0, refs_to_fetch.to_glib_none().0, flags.to_glib(), progress.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn pull_one_dir, Q: IsA>(&self, remote_name: &str, dir_to_pull: &str, refs_to_fetch: &[&str], flags: RepoPullFlags, progress: Option<&P>, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_pull_one_dir(self.to_glib_none().0, remote_name.to_glib_none().0, dir_to_pull.to_glib_none().0, refs_to_fetch.to_glib_none().0, flags.to_glib(), progress.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn pull_with_options, Q: IsA>(&self, remote_name_or_baseurl: &str, options: &glib::Variant, progress: Option<&P>, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_pull_with_options(self.to_glib_none().0, remote_name_or_baseurl.to_glib_none().0, options.to_glib_none().0, progress.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn query_object_storage_size>(&self, objtype: ObjectType, sha256: &str, cancellable: Option<&P>) -> Result { + unsafe { + let mut out_size = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_query_object_storage_size(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, &mut out_size, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(out_size) } else { Err(from_glib_full(error)) } + } + } + + pub fn read_commit>(&self, ref_: &str, cancellable: Option<&P>) -> Result<(gio::File, GString), Error> { + unsafe { + let mut out_root = ptr::null_mut(); + let mut out_commit = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_read_commit(self.to_glib_none().0, ref_.to_glib_none().0, &mut out_root, &mut out_commit, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok((from_glib_full(out_root), from_glib_full(out_commit))) } else { Err(from_glib_full(error)) } + } + } + + pub fn read_commit_detached_metadata>(&self, checksum: &str, cancellable: Option<&P>) -> Result { + unsafe { + let mut out_metadata = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_read_commit_detached_metadata(self.to_glib_none().0, checksum.to_glib_none().0, &mut out_metadata, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(out_metadata)) } else { Err(from_glib_full(error)) } + } + } + + pub fn regenerate_summary>(&self, additional_metadata: Option<&glib::Variant>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_regenerate_summary(self.to_glib_none().0, additional_metadata.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2017_2", feature = "dox"))] + pub fn reload_config>(&self, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_reload_config(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_add>(&self, name: &str, url: &str, options: Option<&glib::Variant>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_add(self.to_glib_none().0, name.to_glib_none().0, url.to_glib_none().0, options.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_change, Q: IsA>(&self, sysroot: Option<&P>, changeop: RepoRemoteChange, name: &str, url: &str, options: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_change(self.to_glib_none().0, sysroot.map(|p| p.as_ref()).to_glib_none().0, changeop.to_glib(), name.to_glib_none().0, url.to_glib_none().0, options.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_delete>(&self, name: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_delete(self.to_glib_none().0, name.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_fetch_summary>(&self, name: &str, cancellable: Option<&P>) -> Result<(glib::Bytes, glib::Bytes), Error> { + unsafe { + let mut out_summary = ptr::null_mut(); + let mut out_signatures = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_fetch_summary(self.to_glib_none().0, name.to_glib_none().0, &mut out_summary, &mut out_signatures, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok((from_glib_full(out_summary), from_glib_full(out_signatures))) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_6", feature = "dox"))] + pub fn remote_fetch_summary_with_options>(&self, name: &str, options: Option<&glib::Variant>, cancellable: Option<&P>) -> Result<(glib::Bytes, glib::Bytes), Error> { + unsafe { + let mut out_summary = ptr::null_mut(); + let mut out_signatures = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_fetch_summary_with_options(self.to_glib_none().0, name.to_glib_none().0, options.to_glib_none().0, &mut out_summary, &mut out_signatures, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok((from_glib_full(out_summary), from_glib_full(out_signatures))) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_get_gpg_verify(&self, name: &str) -> Result { + unsafe { + let mut out_gpg_verify = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_get_gpg_verify(self.to_glib_none().0, name.to_glib_none().0, &mut out_gpg_verify, &mut error); + if error.is_null() { Ok(from_glib(out_gpg_verify)) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_get_gpg_verify_summary(&self, name: &str) -> Result { + unsafe { + let mut out_gpg_verify_summary = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_get_gpg_verify_summary(self.to_glib_none().0, name.to_glib_none().0, &mut out_gpg_verify_summary, &mut error); + if error.is_null() { Ok(from_glib(out_gpg_verify_summary)) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_get_url(&self, name: &str) -> Result { + unsafe { + let mut out_url = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_get_url(self.to_glib_none().0, name.to_glib_none().0, &mut out_url, &mut error); + if error.is_null() { Ok(from_glib_full(out_url)) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_gpg_import, Q: IsA>(&self, name: &str, source_stream: Option<&P>, key_ids: &[&str], cancellable: Option<&Q>) -> Result { + unsafe { + let mut out_imported = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_remote_gpg_import(self.to_glib_none().0, name.to_glib_none().0, source_stream.map(|p| p.as_ref()).to_glib_none().0, key_ids.to_glib_none().0, &mut out_imported, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(out_imported) } else { Err(from_glib_full(error)) } + } + } + + pub fn remote_list(&self) -> Vec { + unsafe { + let mut out_n_remotes = mem::uninitialized(); + let ret = FromGlibContainer::from_glib_full_num(ostree_sys::ostree_repo_remote_list(self.to_glib_none().0, &mut out_n_remotes), out_n_remotes as usize); + ret + } + } + + //#[cfg(any(feature = "v2018_6", feature = "dox"))] + //pub fn remote_list_collection_refs>(&self, remote_name: &str, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_remote_list_collection_refs() } + //} + + //pub fn remote_list_refs>(&self, remote_name: &str, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_remote_list_refs() } + //} + + #[cfg(any(feature = "v2018_6", feature = "dox"))] + pub fn resolve_collection_ref>(&self, ref_: &CollectionRef, allow_noent: bool, flags: RepoResolveRevExtFlags, cancellable: Option<&P>) -> Result, Error> { + unsafe { + let mut out_rev = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_resolve_collection_ref(self.to_glib_none().0, ref_.to_glib_none().0, allow_noent.to_glib(), flags.to_glib(), &mut out_rev, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(out_rev)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2018_6", feature = "dox"))] + pub fn resolve_keyring_for_collection>(&self, collection_id: &str, cancellable: Option<&P>) -> Result { + unsafe { + let mut error = ptr::null_mut(); + let ret = ostree_sys::ostree_repo_resolve_keyring_for_collection(self.to_glib_none().0, collection_id.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + } + } + + pub fn resolve_rev(&self, refspec: &str, allow_noent: bool) -> Result { + unsafe { + let mut out_rev = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_resolve_rev(self.to_glib_none().0, refspec.to_glib_none().0, allow_noent.to_glib(), &mut out_rev, &mut error); + if error.is_null() { Ok(from_glib_full(out_rev)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_7", feature = "dox"))] + pub fn resolve_rev_ext(&self, refspec: &str, allow_noent: bool, flags: RepoResolveRevExtFlags) -> Result { + unsafe { + let mut out_rev = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_resolve_rev_ext(self.to_glib_none().0, refspec.to_glib_none().0, allow_noent.to_glib(), flags.to_glib(), &mut out_rev, &mut error); + if error.is_null() { Ok(from_glib_full(out_rev)) } else { Err(from_glib_full(error)) } + } + } + + pub fn scan_hardlinks>(&self, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_scan_hardlinks(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2017_10", feature = "dox"))] - 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(); + pub fn set_alias_ref_immediate>(&self, remote: Option<&str>, ref_: &str, target: Option<&str>, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::ostree_repo_create_at(dfd, path.to_glib_none().0, mode.to_glib(), options.to_glib_none().0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_repo_set_alias_ref_immediate(self.to_glib_none().0, remote.to_glib_none().0, ref_.to_glib_none().0, target.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_5", feature = "dox"))] + pub fn set_cache_dir>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_set_cache_dir(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2018_6", feature = "dox"))] + pub fn set_collection_id(&self, collection_id: Option<&str>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_set_collection_id(self.to_glib_none().0, collection_id.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 set_collection_ref_immediate>(&self, ref_: &CollectionRef, checksum: Option<&str>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_set_collection_ref_immediate(self.to_glib_none().0, ref_.to_glib_none().0, checksum.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn set_disable_fsync(&self, disable_fsync: bool) { + unsafe { + ostree_sys::ostree_repo_set_disable_fsync(self.to_glib_none().0, disable_fsync.to_glib()); + } + } + + pub fn set_ref_immediate>(&self, remote: Option<&str>, ref_: &str, checksum: Option<&str>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_set_ref_immediate(self.to_glib_none().0, remote.to_glib_none().0, ref_.to_glib_none().0, checksum.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn sign_commit>(&self, commit_checksum: &str, key_id: &str, homedir: Option<&str>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_sign_commit(self.to_glib_none().0, commit_checksum.to_glib_none().0, key_id.to_glib_none().0, homedir.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn sign_delta>(&self, from_commit: &str, to_commit: &str, key_id: &str, homedir: &str, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_sign_delta(self.to_glib_none().0, from_commit.to_glib_none().0, to_commit.to_glib_none().0, key_id.to_glib_none().0, homedir.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn static_delta_execute_offline, Q: IsA>(&self, dir_or_file: &P, skip_validation: bool, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_static_delta_execute_offline(self.to_glib_none().0, dir_or_file.as_ref().to_glib_none().0, skip_validation.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn static_delta_generate>(&self, opt: StaticDeltaGenerateOpt, from: &str, to: &str, metadata: Option<&glib::Variant>, params: Option<&glib::Variant>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_static_delta_generate(self.to_glib_none().0, opt.to_glib(), from.to_glib_none().0, to.to_glib_none().0, metadata.to_glib_none().0, params.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2018_6", feature = "dox"))] + pub fn transaction_set_collection_ref(&self, ref_: &CollectionRef, checksum: Option<&str>) { + unsafe { + ostree_sys::ostree_repo_transaction_set_collection_ref(self.to_glib_none().0, ref_.to_glib_none().0, checksum.to_glib_none().0); + } + } + + pub fn transaction_set_ref(&self, remote: Option<&str>, ref_: &str, checksum: Option<&str>) { + unsafe { + ostree_sys::ostree_repo_transaction_set_ref(self.to_glib_none().0, remote.to_glib_none().0, ref_.to_glib_none().0, checksum.to_glib_none().0); + } + } + + pub fn transaction_set_refspec(&self, refspec: &str, checksum: Option<&str>) { + unsafe { + ostree_sys::ostree_repo_transaction_set_refspec(self.to_glib_none().0, refspec.to_glib_none().0, checksum.to_glib_none().0); + } + } + + //pub fn traverse_commit>(&self, commit_checksum: &str, maxdepth: i32, out_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_traverse_commit() } + //} + + //pub fn traverse_commit_union>(&self, commit_checksum: &str, maxdepth: i32, inout_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_traverse_commit_union() } + //} + + //#[cfg(any(feature = "v2018_5", feature = "dox"))] + //pub fn traverse_commit_union_with_parents>(&self, commit_checksum: &str, maxdepth: i32, inout_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, inout_parents: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_traverse_commit_union_with_parents() } + //} + + //#[cfg(any(feature = "v2018_6", feature = "dox"))] + //pub fn traverse_reachable_refs>(&self, depth: u32, reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_traverse_reachable_refs() } + //} + + pub fn verify_commit, Q: IsA, R: IsA>(&self, commit_checksum: &str, keyringdir: Option<&P>, extra_keyring: Option<&Q>, cancellable: Option<&R>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_verify_commit(self.to_glib_none().0, commit_checksum.to_glib_none().0, keyringdir.map(|p| p.as_ref()).to_glib_none().0, extra_keyring.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn verify_commit_ext, Q: IsA, R: IsA>(&self, commit_checksum: &str, keyringdir: Option<&P>, extra_keyring: Option<&Q>, cancellable: Option<&R>) -> Result { + unsafe { + let mut error = ptr::null_mut(); + let ret = ostree_sys::ostree_repo_verify_commit_ext(self.to_glib_none().0, commit_checksum.to_glib_none().0, keyringdir.map(|p| p.as_ref()).to_glib_none().0, extra_keyring.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + } + } + + #[cfg(any(feature = "v2016_14", feature = "dox"))] + pub fn verify_commit_for_remote>(&self, commit_checksum: &str, remote_name: &str, cancellable: Option<&P>) -> Result { + unsafe { + let mut error = ptr::null_mut(); + let ret = ostree_sys::ostree_repo_verify_commit_for_remote(self.to_glib_none().0, commit_checksum.to_glib_none().0, remote_name.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + } + } + + pub fn verify_summary>(&self, remote_name: &str, summary: &glib::Bytes, signatures: &glib::Bytes, cancellable: Option<&P>) -> Result { + unsafe { + let mut error = ptr::null_mut(); + let ret = ostree_sys::ostree_repo_verify_summary(self.to_glib_none().0, remote_name.to_glib_none().0, summary.to_glib_none().0, signatures.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_archive_to_mtree, Q: IsA, R: IsA>(&self, archive: &P, mtree: &Q, modifier: Option<&RepoCommitModifier>, autocreate_parents: bool, cancellable: Option<&R>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_archive_to_mtree(self.to_glib_none().0, archive.as_ref().to_glib_none().0, mtree.as_ref().to_glib_none().0, modifier.to_glib_none().0, autocreate_parents.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_commit, Q: IsA>(&self, parent: Option<&str>, subject: Option<&str>, body: Option<&str>, metadata: Option<&glib::Variant>, root: &P, cancellable: Option<&Q>) -> Result { + unsafe { + let mut out_commit = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_commit(self.to_glib_none().0, parent.to_glib_none().0, subject.to_glib_none().0, body.to_glib_none().0, metadata.to_glib_none().0, root.as_ref().to_glib_none().0, &mut out_commit, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(out_commit)) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_commit_detached_metadata>(&self, checksum: &str, metadata: Option<&glib::Variant>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_commit_detached_metadata(self.to_glib_none().0, checksum.to_glib_none().0, metadata.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_commit_with_time, Q: IsA>(&self, parent: Option<&str>, subject: Option<&str>, body: Option<&str>, metadata: Option<&glib::Variant>, root: &P, time: u64, cancellable: Option<&Q>) -> Result { + unsafe { + let mut out_commit = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_commit_with_time(self.to_glib_none().0, parent.to_glib_none().0, subject.to_glib_none().0, body.to_glib_none().0, metadata.to_glib_none().0, root.as_ref().to_glib_none().0, time, &mut out_commit, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(out_commit)) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_config(&self, new_config: &glib::KeyFile) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_config(self.to_glib_none().0, new_config.to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + //pub fn write_content, Q: IsA>(&self, expected_checksum: Option<&str>, object_input: &P, length: u64, out_csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: Option<&Q>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_write_content() } + //} + + pub fn write_content_trusted, Q: IsA>(&self, checksum: &str, object_input: &P, length: u64, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_content_trusted(self.to_glib_none().0, checksum.to_glib_none().0, object_input.as_ref().to_glib_none().0, length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_dfd_to_mtree, Q: IsA>(&self, dfd: i32, path: &str, mtree: &P, modifier: Option<&RepoCommitModifier>, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_dfd_to_mtree(self.to_glib_none().0, dfd, path.to_glib_none().0, mtree.as_ref().to_glib_none().0, modifier.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_directory_to_mtree, Q: IsA, R: IsA>(&self, dir: &P, mtree: &Q, modifier: Option<&RepoCommitModifier>, cancellable: Option<&R>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_directory_to_mtree(self.to_glib_none().0, dir.as_ref().to_glib_none().0, mtree.as_ref().to_glib_none().0, modifier.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + //pub fn write_metadata>(&self, objtype: ObjectType, expected_checksum: Option<&str>, object: &glib::Variant, out_csum: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_repo_write_metadata() } + //} + + pub fn write_metadata_stream_trusted, Q: IsA>(&self, objtype: ObjectType, checksum: &str, object_input: &P, length: u64, cancellable: Option<&Q>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_metadata_stream_trusted(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, object_input.as_ref().to_glib_none().0, length, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_metadata_trusted>(&self, objtype: ObjectType, checksum: &str, variant: &glib::Variant, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_metadata_trusted(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, variant.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn write_mtree, Q: IsA>(&self, mtree: &P, cancellable: Option<&Q>) -> Result { + unsafe { + let mut out_file = ptr::null_mut(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_repo_write_mtree(self.to_glib_none().0, mtree.as_ref().to_glib_none().0, &mut out_file, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(out_file)) } else { Err(from_glib_full(error)) } + } + } + + pub fn get_property_remotes_config_dir(&self) -> Option { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"remotes-config-dir\0".as_ptr() as *const _, value.to_glib_none_mut().0); + value.get() + } + } + + pub fn get_property_sysroot_path(&self) -> Option { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"sysroot-path\0".as_ptr() as *const _, value.to_glib_none_mut().0); + value.get() + } + } + + #[cfg(any(feature = "v2017_10", feature = "dox"))] + pub fn create_at>(dfd: i32, path: &str, mode: RepoMode, options: &glib::Variant, cancellable: Option<&P>) -> Result { + unsafe { + let mut error = ptr::null_mut(); + let ret = ostree_sys::ostree_repo_create_at(dfd, path.to_glib_none().0, mode.to_glib(), options.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } @@ -85,1384 +949,54 @@ impl Repo { unsafe { let mut out_mode = mem::uninitialized(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_mode_from_string(mode.to_glib_none().0, &mut out_mode, &mut error); + let _ = ostree_sys::ostree_repo_mode_from_string(mode.to_glib_none().0, &mut out_mode, &mut error); if error.is_null() { Ok(from_glib(out_mode)) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2017_10", feature = "dox"))] - pub fn open_at<'a, P: Into>>(dfd: i32, path: &str, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn open_at>(dfd: i32, path: &str, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::ostree_repo_open_at(dfd, path.to_glib_none().0, cancellable.0, &mut error); + let ret = ostree_sys::ostree_repo_open_at(dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } - //pub fn pull_default_console_progress_changed>>(progress: &AsyncProgress, user_data: P) { - // unsafe { TODO: call ffi::ostree_repo_pull_default_console_progress_changed() } + //pub fn pull_default_console_progress_changed>(progress: &P, user_data: /*Unimplemented*/Option) { + // unsafe { TODO: call ostree_sys:ostree_repo_pull_default_console_progress_changed() } //} //#[cfg(any(feature = "v2018_5", feature = "dox"))] //pub fn traverse_new_parents() -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 } { - // unsafe { TODO: call ffi::ostree_repo_traverse_new_parents() } + // unsafe { TODO: call ostree_sys:ostree_repo_traverse_new_parents() } //} //pub fn traverse_new_reachable() -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 } { - // unsafe { TODO: call ffi::ostree_repo_traverse_new_reachable() } + // unsafe { TODO: call ostree_sys:ostree_repo_traverse_new_reachable() } //} //#[cfg(any(feature = "v2018_5", feature = "dox"))] - //pub fn traverse_parents_get_commits(parents: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, object: &glib::Variant) -> Vec { - // unsafe { TODO: call ffi::ostree_repo_traverse_parents_get_commits() } - //} -} - -pub trait RepoExt { - fn abort_transaction<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - fn add_gpg_signature_summary<'a, 'b, P: Into>, Q: Into>>(&self, key_id: &[&str], homedir: P, cancellable: Q) -> Result<(), Error>; - - fn append_gpg_signature<'a, P: Into>>(&self, commit_checksum: &str, signature_bytes: &glib::Bytes, cancellable: P) -> Result<(), Error>; - - //#[cfg(any(feature = "v2016_8", feature = "dox"))] - //fn checkout_at<'a, 'b, P: Into>, Q: Into>>(&self, options: P, destination_dfd: i32, destination_path: &str, commit: &str, cancellable: Q) -> Result<(), Error>; - - fn checkout_gc<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - 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>; - - fn commit_transaction<'a, P: Into>>(&self, cancellable: P) -> Result; - - fn copy_config(&self) -> Option; - - fn create<'a, P: Into>>(&self, mode: RepoMode, cancellable: P) -> Result<(), Error>; - - fn delete_object<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result<(), Error>; - - #[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>; - - #[cfg(any(feature = "v2017_15", feature = "dox"))] - fn fsck_object<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result<(), Error>; - - #[cfg(any(feature = "v2019_2", feature = "dox"))] - fn get_bootloader(&self) -> Option; - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn get_collection_id(&self) -> Option; - - fn get_config(&self) -> Option; - - #[cfg(any(feature = "v2018_9", feature = "dox"))] - fn get_default_repo_finders(&self) -> Vec; - - #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn get_dfd(&self) -> i32; - - fn get_disable_fsync(&self) -> bool; - - #[cfg(any(feature = "v2018_9", feature = "dox"))] - fn get_min_free_space_bytes(&self) -> Result; - - fn get_mode(&self) -> RepoMode; - - fn get_parent(&self) -> Option; - - fn get_path(&self) -> Option; - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_remote_boolean_option(&self, remote_name: &str, option_name: &str, default_value: bool) -> Result; - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_remote_list_option(&self, remote_name: &str, option_name: &str) -> Result, Error>; - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_remote_option<'a, P: Into>>(&self, remote_name: &str, option_name: &str, default_value: P) -> Result; - - #[cfg(any(feature = "v2016_6", feature = "dox"))] - 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; - - fn has_object<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, cancellable: P) -> Result; - - #[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>; - - fn import_object_from<'a, P: Into>>(&self, source: &Repo, objtype: ObjectType, checksum: &str, cancellable: P) -> Result<(), Error>; - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn import_object_from_with_trust<'a, P: Into>>(&self, source: &Repo, objtype: ObjectType, checksum: &str, trusted: bool, cancellable: P) -> Result<(), Error>; - - fn is_system(&self) -> bool; - - fn is_writable(&self) -> Result<(), Error>; - - //#[cfg(any(feature = "v2018_6", feature = "dox"))] - //fn list_collection_refs<'a, 'b, P: Into>, Q: Into>>(&self, match_collection_id: P, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, flags: RepoListRefsExtFlags, cancellable: Q) -> Result<(), Error>; - - //fn list_commit_objects_starting_with<'a, P: Into>>(&self, start: &str, out_commits: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error>; - - //fn list_objects<'a, P: Into>>(&self, flags: /*Ignored*/RepoListObjectsFlags, out_objects: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error>; - - //fn list_refs<'a, 'b, P: Into>, Q: Into>>(&self, refspec_prefix: P, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: Q) -> Result<(), Error>; - - //#[cfg(any(feature = "v2016_4", feature = "dox"))] - //fn list_refs_ext<'a, 'b, P: Into>, Q: Into>>(&self, refspec_prefix: P, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, flags: RepoListRefsExtFlags, cancellable: Q) -> Result<(), Error>; - - //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>; - - #[cfg(any(feature = "v2015_7", feature = "dox"))] - fn load_commit(&self, checksum: &str) -> Result<(glib::Variant, RepoCommitState), Error>; - - fn load_file<'a, P: Into>>(&self, checksum: &str, cancellable: P) -> Result<(Option, Option, Option), Error>; - - fn load_object_stream<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, cancellable: P) -> Result<(gio::InputStream, u64), Error>; - - fn load_variant(&self, objtype: ObjectType, sha256: &str) -> Result; - - fn load_variant_if_exists(&self, objtype: ObjectType, sha256: &str) -> Result; - - #[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>; - - fn prepare_transaction<'a, P: Into>>(&self, cancellable: P) -> Result; - - fn prune<'a, P: Into>>(&self, flags: RepoPruneFlags, depth: i32, cancellable: P) -> Result<(i32, i32, u64), Error>; - - //#[cfg(any(feature = "v2017_1", feature = "dox"))] - //fn prune_from_reachable<'a, P: Into>>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: P) -> Result<(i32, i32, u64), Error>; - - fn prune_static_deltas<'a, 'b, P: Into>, Q: Into>>(&self, commit: P, cancellable: Q) -> Result<(), Error>; - - fn pull<'a, 'b, P: Into>, Q: Into>>(&self, remote_name: &str, refs_to_fetch: &[&str], flags: RepoPullFlags, progress: P, cancellable: Q) -> Result<(), Error>; - - 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>; - - 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>; - - fn query_object_storage_size<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result; - - fn read_commit<'a, P: Into>>(&self, ref_: &str, cancellable: P) -> Result<(gio::File, String), Error>; - - fn read_commit_detached_metadata<'a, P: Into>>(&self, checksum: &str, cancellable: P) -> Result; - - fn regenerate_summary<'a, 'b, P: Into>, Q: Into>>(&self, additional_metadata: P, cancellable: Q) -> Result<(), Error>; - - #[cfg(any(feature = "v2017_2", feature = "dox"))] - fn reload_config<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - fn remote_add<'a, 'b, P: Into>, Q: Into>>(&self, name: &str, url: &str, options: P, cancellable: Q) -> Result<(), Error>; - - 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>; - - fn remote_delete<'a, P: Into>>(&self, name: &str, cancellable: P) -> Result<(), Error>; - - fn remote_fetch_summary<'a, P: Into>>(&self, name: &str, cancellable: P) -> Result<(glib::Bytes, glib::Bytes), Error>; - - #[cfg(any(feature = "v2016_6", feature = "dox"))] - 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>; - - fn remote_get_gpg_verify(&self, name: &str) -> Result; - - fn remote_get_gpg_verify_summary(&self, name: &str) -> Result; - - fn remote_get_url(&self, name: &str) -> Result; - - fn remote_gpg_import<'a, 'b, P: IsA + 'a, Q: Into>, R: Into>>(&self, name: &str, source_stream: Q, key_ids: &[&str], cancellable: R) -> Result; - - fn remote_list(&self) -> Vec; - - //#[cfg(any(feature = "v2018_6", feature = "dox"))] - //fn remote_list_collection_refs<'a, P: Into>>(&self, remote_name: &str, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, cancellable: P) -> Result<(), Error>; - - //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>; - - #[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>; - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn resolve_keyring_for_collection<'a, P: Into>>(&self, collection_id: &str, cancellable: P) -> Result; - - fn resolve_rev(&self, refspec: &str, allow_noent: bool) -> Result; - - #[cfg(any(feature = "v2016_7", feature = "dox"))] - fn resolve_rev_ext(&self, refspec: &str, allow_noent: bool, flags: RepoResolveRevExtFlags) -> Result; - - fn scan_hardlinks<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - #[cfg(any(feature = "v2017_10", feature = "dox"))] - 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>; - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn set_cache_dir<'a, P: Into>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error>; - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn set_collection_id<'a, P: Into>>(&self, collection_id: P) -> Result<(), Error>; - - #[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>; - - fn set_disable_fsync(&self, disable_fsync: bool); - - fn set_ref_immediate<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, remote: P, ref_: &str, checksum: Q, cancellable: R) -> Result<(), Error>; - - fn sign_commit<'a, 'b, P: Into>, Q: Into>>(&self, commit_checksum: &str, key_id: &str, homedir: P, cancellable: Q) -> Result<(), Error>; - - fn sign_delta<'a, P: Into>>(&self, from_commit: &str, to_commit: &str, key_id: &str, homedir: &str, cancellable: P) -> Result<(), Error>; - - fn static_delta_execute_offline<'a, P: IsA, Q: Into>>(&self, dir_or_file: &P, skip_validation: bool, cancellable: Q) -> Result<(), Error>; - - 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>; - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn transaction_set_collection_ref<'a, P: Into>>(&self, ref_: &CollectionRef, checksum: P); - - fn transaction_set_ref<'a, 'b, P: Into>, Q: Into>>(&self, remote: P, ref_: &str, checksum: Q); - - 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: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error>; - - //fn traverse_commit_union<'a, P: Into>>(&self, commit_checksum: &str, maxdepth: i32, inout_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, cancellable: P) -> Result<(), Error>; - - //#[cfg(any(feature = "v2018_5", feature = "dox"))] - //fn traverse_commit_union_with_parents<'a, P: Into>>(&self, commit_checksum: &str, maxdepth: i32, inout_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, inout_parents: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, cancellable: P) -> Result<(), Error>; - - //#[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: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error>; - - 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>; - - 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; - - #[cfg(any(feature = "v2016_14", feature = "dox"))] - fn verify_commit_for_remote<'a, P: Into>>(&self, commit_checksum: &str, remote_name: &str, cancellable: P) -> Result; - - fn verify_summary<'a, P: Into>>(&self, remote_name: &str, summary: &glib::Bytes, signatures: &glib::Bytes, cancellable: P) -> Result; - - 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>; - - 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; - - fn write_commit_detached_metadata<'a, 'b, P: Into>, Q: Into>>(&self, checksum: &str, metadata: P, cancellable: Q) -> Result<(), Error>; - - 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; - - 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>; - - fn write_content_trusted<'a, P: IsA, Q: Into>>(&self, checksum: &str, object_input: &P, length: u64, cancellable: Q) -> Result<(), Error>; - - fn write_dfd_to_mtree<'a, 'b, P: Into>, Q: Into>>(&self, dfd: i32, path: &str, mtree: &MutableTree, modifier: P, cancellable: Q) -> Result<(), Error>; - - 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>; - - fn write_metadata_stream_trusted<'a, P: IsA, Q: Into>>(&self, objtype: ObjectType, checksum: &str, object_input: &P, length: u64, cancellable: Q) -> Result<(), Error>; - - fn write_metadata_trusted<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, variant: &glib::Variant, cancellable: P) -> Result<(), Error>; - - 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; - - fn connect_gpg_verify_result(&self, f: F) -> SignalHandlerId; -} - -impl + IsA> RepoExt for O { - fn abort_transaction<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_abort_transaction(self.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn add_gpg_signature_summary<'a, 'b, P: Into>, Q: Into>>(&self, key_id: &[&str], homedir: P, cancellable: Q) -> Result<(), Error> { - let homedir = homedir.into(); - let homedir = homedir.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_add_gpg_signature_summary(self.to_glib_none().0, key_id.to_glib_none().0, homedir.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn append_gpg_signature<'a, P: Into>>(&self, commit_checksum: &str, signature_bytes: &glib::Bytes, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_append_gpg_signature(self.to_glib_none().0, commit_checksum.to_glib_none().0, signature_bytes.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - //#[cfg(any(feature = "v2016_8", feature = "dox"))] - //fn checkout_at<'a, 'b, P: Into>, Q: Into>>(&self, options: P, destination_dfd: i32, destination_path: &str, commit: &str, cancellable: Q) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_checkout_at() } + //pub fn traverse_parents_get_commits(parents: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, object: &glib::Variant) -> Vec { + // unsafe { TODO: call ostree_sys:ostree_repo_traverse_parents_get_commits() } //} - fn checkout_gc<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn connect_gpg_verify_result(&self, f: F) -> SignalHandlerId { unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_checkout_gc(self.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - 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> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_checkout_tree(self.to_glib_none().0, mode.to_glib(), overwrite_mode.to_glib(), destination.to_glib_none().0, source.to_glib_none().0, source_info.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(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> { - // unsafe { TODO: call ffi::ostree_repo_checkout_tree_at() } - //} - - fn commit_transaction<'a, P: Into>>(&self, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_stats = RepoTransactionStats::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_commit_transaction(self.to_glib_none().0, out_stats.to_glib_none_mut().0, cancellable.0, &mut error); - if error.is_null() { Ok(out_stats) } else { Err(from_glib_full(error)) } - } - } - - fn copy_config(&self) -> Option { - unsafe { - from_glib_full(ffi::ostree_repo_copy_config(self.to_glib_none().0)) - } - } - - fn create<'a, P: Into>>(&self, mode: RepoMode, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_create(self.to_glib_none().0, mode.to_glib(), cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn delete_object<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_delete_object(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2017_12", feature = "dox"))] - fn equal(&self, b: &Repo) -> bool { - unsafe { - from_glib(ffi::ostree_repo_equal(self.to_glib_none().0, b.to_glib_none().0)) - } - } - - //fn export_tree_to_archive<'a, P: Into>, Q: Into>>(&self, opts: /*Ignored*/&mut RepoExportArchiveOptions, root: &RepoFile, archive: P, cancellable: Q) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_export_tree_to_archive() } - //} - - #[cfg(any(feature = "v2017_15", feature = "dox"))] - fn fsck_object<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_fsck_object(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2019_2", feature = "dox"))] - fn get_bootloader(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_repo_get_bootloader(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn get_collection_id(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_repo_get_collection_id(self.to_glib_none().0)) - } - } - - fn get_config(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_repo_get_config(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2018_9", feature = "dox"))] - fn get_default_repo_finders(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_none(ffi::ostree_repo_get_default_repo_finders(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn get_dfd(&self) -> i32 { - unsafe { - ffi::ostree_repo_get_dfd(self.to_glib_none().0) - } - } - - fn get_disable_fsync(&self) -> bool { - unsafe { - from_glib(ffi::ostree_repo_get_disable_fsync(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2018_9", feature = "dox"))] - fn get_min_free_space_bytes(&self) -> Result { - unsafe { - let mut out_reserved_bytes = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_get_min_free_space_bytes(self.to_glib_none().0, &mut out_reserved_bytes, &mut error); - if error.is_null() { Ok(out_reserved_bytes) } else { Err(from_glib_full(error)) } - } - } - - fn get_mode(&self) -> RepoMode { - unsafe { - from_glib(ffi::ostree_repo_get_mode(self.to_glib_none().0)) - } - } - - fn get_parent(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_repo_get_parent(self.to_glib_none().0)) - } - } - - fn get_path(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_repo_get_path(self.to_glib_none().0)) - } - } - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_remote_boolean_option(&self, remote_name: &str, option_name: &str, default_value: bool) -> Result { - unsafe { - let mut out_value = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_get_remote_boolean_option(self.to_glib_none().0, remote_name.to_glib_none().0, option_name.to_glib_none().0, default_value.to_glib(), &mut out_value, &mut error); - if error.is_null() { Ok(from_glib(out_value)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_remote_list_option(&self, remote_name: &str, option_name: &str) -> Result, Error> { - unsafe { - let mut out_value = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_get_remote_list_option(self.to_glib_none().0, remote_name.to_glib_none().0, option_name.to_glib_none().0, &mut out_value, &mut error); - if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(out_value)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_remote_option<'a, P: Into>>(&self, remote_name: &str, option_name: &str, default_value: P) -> Result { - let default_value = default_value.into(); - let default_value = default_value.to_glib_none(); - unsafe { - let mut out_value = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_get_remote_option(self.to_glib_none().0, remote_name.to_glib_none().0, option_name.to_glib_none().0, default_value.0, &mut out_value, &mut error); - if error.is_null() { Ok(from_glib_full(out_value)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_6", feature = "dox"))] - 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 { - let remote_name = remote_name.into(); - let remote_name = remote_name.to_glib_none(); - let keyringdir = keyringdir.into(); - let keyringdir = keyringdir.to_glib_none(); - let extra_keyring = extra_keyring.into(); - let extra_keyring = extra_keyring.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let ret = ffi::ostree_repo_gpg_verify_data(self.to_glib_none().0, remote_name.0, data.to_glib_none().0, signatures.to_glib_none().0, keyringdir.0, extra_keyring.0, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } - } - } - - fn has_object<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_have_object = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_has_object(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, &mut out_have_object, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib(out_have_object)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2017_12", feature = "dox"))] - fn hash(&self) -> u32 { - unsafe { - ffi::ostree_repo_hash(self.to_glib_none().0) - } - } - - //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> { - // unsafe { TODO: call ffi::ostree_repo_import_archive_to_mtree() } - //} - - fn import_object_from<'a, P: Into>>(&self, source: &Repo, objtype: ObjectType, checksum: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_import_object_from(self.to_glib_none().0, source.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn import_object_from_with_trust<'a, P: Into>>(&self, source: &Repo, objtype: ObjectType, checksum: &str, trusted: 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_repo_import_object_from_with_trust(self.to_glib_none().0, source.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, trusted.to_glib(), cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn is_system(&self) -> bool { - unsafe { - from_glib(ffi::ostree_repo_is_system(self.to_glib_none().0)) - } - } - - fn is_writable(&self) -> Result<(), Error> { - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_is_writable(self.to_glib_none().0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - //#[cfg(any(feature = "v2018_6", feature = "dox"))] - //fn list_collection_refs<'a, 'b, P: Into>, Q: Into>>(&self, match_collection_id: P, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, flags: RepoListRefsExtFlags, cancellable: Q) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_list_collection_refs() } - //} - - //fn list_commit_objects_starting_with<'a, P: Into>>(&self, start: &str, out_commits: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_list_commit_objects_starting_with() } - //} - - //fn list_objects<'a, P: Into>>(&self, flags: /*Ignored*/RepoListObjectsFlags, out_objects: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_list_objects() } - //} - - //fn list_refs<'a, 'b, P: Into>, Q: Into>>(&self, refspec_prefix: P, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, cancellable: Q) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_list_refs() } - //} - - //#[cfg(any(feature = "v2016_4", feature = "dox"))] - //fn list_refs_ext<'a, 'b, P: Into>, Q: Into>>(&self, refspec_prefix: P, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, flags: RepoListRefsExtFlags, cancellable: Q) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_list_refs_ext() } - //} - - //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> { - // unsafe { TODO: call ffi::ostree_repo_list_static_delta_names() } - //} - - #[cfg(any(feature = "v2015_7", feature = "dox"))] - fn load_commit(&self, checksum: &str) -> Result<(glib::Variant, RepoCommitState), Error> { - unsafe { - let mut out_commit = ptr::null_mut(); - let mut out_state = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_load_commit(self.to_glib_none().0, checksum.to_glib_none().0, &mut out_commit, &mut out_state, &mut error); - if error.is_null() { Ok((from_glib_full(out_commit), from_glib(out_state))) } else { Err(from_glib_full(error)) } - } - } - - fn load_file<'a, P: Into>>(&self, checksum: &str, cancellable: P) -> Result<(Option, Option, Option), 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_repo_load_file(self.to_glib_none().0, checksum.to_glib_none().0, &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)) } - } - } - - fn load_object_stream<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, cancellable: P) -> Result<(gio::InputStream, u64), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_input = ptr::null_mut(); - let mut out_size = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_load_object_stream(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, &mut out_input, &mut out_size, cancellable.0, &mut error); - if error.is_null() { Ok((from_glib_full(out_input), out_size)) } else { Err(from_glib_full(error)) } - } - } - - fn load_variant(&self, objtype: ObjectType, sha256: &str) -> Result { - unsafe { - let mut out_variant = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_load_variant(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, &mut out_variant, &mut error); - if error.is_null() { Ok(from_glib_full(out_variant)) } else { Err(from_glib_full(error)) } - } - } - - fn load_variant_if_exists(&self, objtype: ObjectType, sha256: &str) -> Result { - unsafe { - let mut out_variant = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_load_variant_if_exists(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, &mut out_variant, &mut error); - if error.is_null() { Ok(from_glib_full(out_variant)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2017_15", feature = "dox"))] - fn mark_commit_partial(&self, checksum: &str, is_partial: bool) -> Result<(), Error> { - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_mark_commit_partial(self.to_glib_none().0, checksum.to_glib_none().0, is_partial.to_glib(), &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn open<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_open(self.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn prepare_transaction<'a, P: Into>>(&self, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_transaction_resume = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_prepare_transaction(self.to_glib_none().0, &mut out_transaction_resume, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib(out_transaction_resume)) } else { Err(from_glib_full(error)) } - } - } - - fn prune<'a, P: Into>>(&self, flags: RepoPruneFlags, depth: i32, cancellable: P) -> Result<(i32, i32, u64), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_objects_total = mem::uninitialized(); - let mut out_objects_pruned = mem::uninitialized(); - let mut out_pruned_object_size_total = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_prune(self.to_glib_none().0, flags.to_glib(), depth, &mut out_objects_total, &mut out_objects_pruned, &mut out_pruned_object_size_total, cancellable.0, &mut error); - if error.is_null() { Ok((out_objects_total, out_objects_pruned, out_pruned_object_size_total)) } else { Err(from_glib_full(error)) } - } - } - - //#[cfg(any(feature = "v2017_1", feature = "dox"))] - //fn prune_from_reachable<'a, P: Into>>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: P) -> Result<(i32, i32, u64), Error> { - // unsafe { TODO: call ffi::ostree_repo_prune_from_reachable() } - //} - - fn prune_static_deltas<'a, 'b, P: Into>, Q: Into>>(&self, commit: P, cancellable: Q) -> Result<(), Error> { - let commit = commit.into(); - let commit = commit.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_prune_static_deltas(self.to_glib_none().0, commit.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn pull<'a, 'b, P: Into>, Q: Into>>(&self, remote_name: &str, refs_to_fetch: &[&str], flags: RepoPullFlags, progress: P, cancellable: Q) -> Result<(), Error> { - let progress = progress.into(); - let progress = progress.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_pull(self.to_glib_none().0, remote_name.to_glib_none().0, refs_to_fetch.to_glib_none().0, flags.to_glib(), progress.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - 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> { - let progress = progress.into(); - let progress = progress.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_pull_one_dir(self.to_glib_none().0, remote_name.to_glib_none().0, dir_to_pull.to_glib_none().0, refs_to_fetch.to_glib_none().0, flags.to_glib(), progress.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - 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> { - let progress = progress.into(); - let progress = progress.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_pull_with_options(self.to_glib_none().0, remote_name_or_baseurl.to_glib_none().0, options.to_glib_none().0, progress.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn query_object_storage_size<'a, P: Into>>(&self, objtype: ObjectType, sha256: &str, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_size = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_query_object_storage_size(self.to_glib_none().0, objtype.to_glib(), sha256.to_glib_none().0, &mut out_size, cancellable.0, &mut error); - if error.is_null() { Ok(out_size) } else { Err(from_glib_full(error)) } - } - } - - fn read_commit<'a, P: Into>>(&self, ref_: &str, cancellable: P) -> Result<(gio::File, String), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_root = ptr::null_mut(); - let mut out_commit = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_read_commit(self.to_glib_none().0, ref_.to_glib_none().0, &mut out_root, &mut out_commit, cancellable.0, &mut error); - if error.is_null() { Ok((from_glib_full(out_root), from_glib_full(out_commit))) } else { Err(from_glib_full(error)) } - } - } - - fn read_commit_detached_metadata<'a, P: Into>>(&self, checksum: &str, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_metadata = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_read_commit_detached_metadata(self.to_glib_none().0, checksum.to_glib_none().0, &mut out_metadata, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(out_metadata)) } else { Err(from_glib_full(error)) } - } - } - - fn regenerate_summary<'a, 'b, P: Into>, Q: Into>>(&self, additional_metadata: P, cancellable: Q) -> Result<(), Error> { - let additional_metadata = additional_metadata.into(); - let additional_metadata = additional_metadata.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_regenerate_summary(self.to_glib_none().0, additional_metadata.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2017_2", feature = "dox"))] - fn reload_config<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_reload_config(self.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn remote_add<'a, 'b, P: Into>, Q: Into>>(&self, name: &str, url: &str, options: P, cancellable: Q) -> Result<(), Error> { - let options = options.into(); - let options = options.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_add(self.to_glib_none().0, name.to_glib_none().0, url.to_glib_none().0, options.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - 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> { - let sysroot = sysroot.into(); - let sysroot = sysroot.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 error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_change(self.to_glib_none().0, sysroot.0, changeop.to_glib(), name.to_glib_none().0, url.to_glib_none().0, options.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn remote_delete<'a, P: Into>>(&self, name: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_delete(self.to_glib_none().0, name.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn remote_fetch_summary<'a, P: Into>>(&self, name: &str, cancellable: P) -> Result<(glib::Bytes, glib::Bytes), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_summary = ptr::null_mut(); - let mut out_signatures = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_fetch_summary(self.to_glib_none().0, name.to_glib_none().0, &mut out_summary, &mut out_signatures, cancellable.0, &mut error); - if error.is_null() { Ok((from_glib_full(out_summary), from_glib_full(out_signatures))) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_6", feature = "dox"))] - 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> { - let options = options.into(); - let options = options.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_summary = ptr::null_mut(); - let mut out_signatures = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_fetch_summary_with_options(self.to_glib_none().0, name.to_glib_none().0, options.0, &mut out_summary, &mut out_signatures, cancellable.0, &mut error); - if error.is_null() { Ok((from_glib_full(out_summary), from_glib_full(out_signatures))) } else { Err(from_glib_full(error)) } - } - } - - fn remote_get_gpg_verify(&self, name: &str) -> Result { - unsafe { - let mut out_gpg_verify = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_get_gpg_verify(self.to_glib_none().0, name.to_glib_none().0, &mut out_gpg_verify, &mut error); - if error.is_null() { Ok(from_glib(out_gpg_verify)) } else { Err(from_glib_full(error)) } - } - } - - fn remote_get_gpg_verify_summary(&self, name: &str) -> Result { - unsafe { - let mut out_gpg_verify_summary = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_get_gpg_verify_summary(self.to_glib_none().0, name.to_glib_none().0, &mut out_gpg_verify_summary, &mut error); - if error.is_null() { Ok(from_glib(out_gpg_verify_summary)) } else { Err(from_glib_full(error)) } - } - } - - fn remote_get_url(&self, name: &str) -> Result { - unsafe { - let mut out_url = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_get_url(self.to_glib_none().0, name.to_glib_none().0, &mut out_url, &mut error); - if error.is_null() { Ok(from_glib_full(out_url)) } else { Err(from_glib_full(error)) } - } - } - - fn remote_gpg_import<'a, 'b, P: IsA + 'a, Q: Into>, R: Into>>(&self, name: &str, source_stream: Q, key_ids: &[&str], cancellable: R) -> Result { - let source_stream = source_stream.into(); - let source_stream = source_stream.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_imported = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_remote_gpg_import(self.to_glib_none().0, name.to_glib_none().0, source_stream.0, key_ids.to_glib_none().0, &mut out_imported, cancellable.0, &mut error); - if error.is_null() { Ok(out_imported) } else { Err(from_glib_full(error)) } - } - } - - fn remote_list(&self) -> Vec { - unsafe { - let mut out_n_remotes = mem::uninitialized(); - let ret = FromGlibContainer::from_glib_full_num(ffi::ostree_repo_remote_list(self.to_glib_none().0, &mut out_n_remotes), out_n_remotes as usize); - ret - } - } - - //#[cfg(any(feature = "v2018_6", feature = "dox"))] - //fn remote_list_collection_refs<'a, P: Into>>(&self, remote_name: &str, out_all_refs: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_remote_list_collection_refs() } - //} - - //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> { - // unsafe { TODO: call ffi::ostree_repo_remote_list_refs() } - //} - - #[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> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_rev = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_resolve_collection_ref(self.to_glib_none().0, ref_.to_glib_none().0, allow_noent.to_glib(), flags.to_glib(), &mut out_rev, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(out_rev)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn resolve_keyring_for_collection<'a, P: Into>>(&self, collection_id: &str, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let ret = ffi::ostree_repo_resolve_keyring_for_collection(self.to_glib_none().0, collection_id.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } - } - } - - fn resolve_rev(&self, refspec: &str, allow_noent: bool) -> Result { - unsafe { - let mut out_rev = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_resolve_rev(self.to_glib_none().0, refspec.to_glib_none().0, allow_noent.to_glib(), &mut out_rev, &mut error); - if error.is_null() { Ok(from_glib_full(out_rev)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_7", feature = "dox"))] - fn resolve_rev_ext(&self, refspec: &str, allow_noent: bool, flags: RepoResolveRevExtFlags) -> Result { - unsafe { - let mut out_rev = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_resolve_rev_ext(self.to_glib_none().0, refspec.to_glib_none().0, allow_noent.to_glib(), flags.to_glib(), &mut out_rev, &mut error); - if error.is_null() { Ok(from_glib_full(out_rev)) } else { Err(from_glib_full(error)) } - } - } - - fn scan_hardlinks<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_scan_hardlinks(self.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2017_10", feature = "dox"))] - 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> { - let remote = remote.into(); - let remote = remote.to_glib_none(); - let target = target.into(); - let target = target.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_set_alias_ref_immediate(self.to_glib_none().0, remote.0, ref_.to_glib_none().0, target.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn set_cache_dir<'a, P: Into>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_set_cache_dir(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn set_collection_id<'a, P: Into>>(&self, 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_repo_set_collection_id(self.to_glib_none().0, collection_id.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[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> { - let checksum = checksum.into(); - let checksum = checksum.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_set_collection_ref_immediate(self.to_glib_none().0, ref_.to_glib_none().0, checksum.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn set_disable_fsync(&self, disable_fsync: bool) { - unsafe { - ffi::ostree_repo_set_disable_fsync(self.to_glib_none().0, disable_fsync.to_glib()); - } - } - - fn set_ref_immediate<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, remote: P, ref_: &str, checksum: Q, cancellable: R) -> Result<(), Error> { - let remote = remote.into(); - let remote = remote.to_glib_none(); - let checksum = checksum.into(); - let checksum = checksum.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_set_ref_immediate(self.to_glib_none().0, remote.0, ref_.to_glib_none().0, checksum.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn sign_commit<'a, 'b, P: Into>, Q: Into>>(&self, commit_checksum: &str, key_id: &str, homedir: P, cancellable: Q) -> Result<(), Error> { - let homedir = homedir.into(); - let homedir = homedir.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_sign_commit(self.to_glib_none().0, commit_checksum.to_glib_none().0, key_id.to_glib_none().0, homedir.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn sign_delta<'a, P: Into>>(&self, from_commit: &str, to_commit: &str, key_id: &str, homedir: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_sign_delta(self.to_glib_none().0, from_commit.to_glib_none().0, to_commit.to_glib_none().0, key_id.to_glib_none().0, homedir.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn static_delta_execute_offline<'a, P: IsA, Q: Into>>(&self, dir_or_file: &P, skip_validation: bool, cancellable: Q) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_static_delta_execute_offline(self.to_glib_none().0, dir_or_file.to_glib_none().0, skip_validation.to_glib(), cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - 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> { - let metadata = metadata.into(); - let metadata = metadata.to_glib_none(); - let params = params.into(); - let params = params.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_static_delta_generate(self.to_glib_none().0, opt.to_glib(), from.to_glib_none().0, to.to_glib_none().0, metadata.0, params.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2018_6", feature = "dox"))] - fn transaction_set_collection_ref<'a, P: Into>>(&self, ref_: &CollectionRef, checksum: P) { - let checksum = checksum.into(); - let checksum = checksum.to_glib_none(); - unsafe { - ffi::ostree_repo_transaction_set_collection_ref(self.to_glib_none().0, ref_.to_glib_none().0, checksum.0); - } - } - - fn transaction_set_ref<'a, 'b, P: Into>, Q: Into>>(&self, remote: P, ref_: &str, checksum: Q) { - let remote = remote.into(); - let remote = remote.to_glib_none(); - let checksum = checksum.into(); - let checksum = checksum.to_glib_none(); - unsafe { - ffi::ostree_repo_transaction_set_ref(self.to_glib_none().0, remote.0, ref_.to_glib_none().0, checksum.0); - } - } - - fn transaction_set_refspec<'a, P: Into>>(&self, refspec: &str, checksum: P) { - let checksum = checksum.into(); - let checksum = checksum.to_glib_none(); - unsafe { - ffi::ostree_repo_transaction_set_refspec(self.to_glib_none().0, refspec.to_glib_none().0, checksum.0); - } - } - - //fn traverse_commit<'a, P: Into>>(&self, commit_checksum: &str, maxdepth: i32, out_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 2, id: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_traverse_commit() } - //} - - //fn traverse_commit_union<'a, P: Into>>(&self, commit_checksum: &str, maxdepth: i32, inout_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_traverse_commit_union() } - //} - - //#[cfg(any(feature = "v2018_5", feature = "dox"))] - //fn traverse_commit_union_with_parents<'a, P: Into>>(&self, commit_checksum: &str, maxdepth: i32, inout_reachable: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, inout_parents: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 25 }/TypeId { ns_id: 0, id: 25 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_traverse_commit_union_with_parents() } - //} - - //#[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: 182 }/TypeId { ns_id: 2, id: 182 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_repo_traverse_reachable_refs() } - //} - - 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> { - let keyringdir = keyringdir.into(); - let keyringdir = keyringdir.to_glib_none(); - let extra_keyring = extra_keyring.into(); - let extra_keyring = extra_keyring.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_verify_commit(self.to_glib_none().0, commit_checksum.to_glib_none().0, keyringdir.0, extra_keyring.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(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 { - let keyringdir = keyringdir.into(); - let keyringdir = keyringdir.to_glib_none(); - let extra_keyring = extra_keyring.into(); - let extra_keyring = extra_keyring.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let ret = ffi::ostree_repo_verify_commit_ext(self.to_glib_none().0, commit_checksum.to_glib_none().0, keyringdir.0, extra_keyring.0, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } - } - } - - #[cfg(any(feature = "v2016_14", feature = "dox"))] - fn verify_commit_for_remote<'a, P: Into>>(&self, commit_checksum: &str, remote_name: &str, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let ret = ffi::ostree_repo_verify_commit_for_remote(self.to_glib_none().0, commit_checksum.to_glib_none().0, remote_name.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } - } - } - - fn verify_summary<'a, P: Into>>(&self, remote_name: &str, summary: &glib::Bytes, signatures: &glib::Bytes, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let ret = ffi::ostree_repo_verify_summary(self.to_glib_none().0, remote_name.to_glib_none().0, summary.to_glib_none().0, signatures.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } - } - } - - 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> { - let modifier = modifier.into(); - let modifier = modifier.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_archive_to_mtree(self.to_glib_none().0, archive.to_glib_none().0, mtree.to_glib_none().0, modifier.0, autocreate_parents.to_glib(), cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - 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 { - let parent = parent.into(); - let parent = parent.to_glib_none(); - let subject = subject.into(); - let subject = subject.to_glib_none(); - let body = body.into(); - let body = body.to_glib_none(); - let metadata = metadata.into(); - let metadata = metadata.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_commit = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_commit(self.to_glib_none().0, parent.0, subject.0, body.0, metadata.0, root.to_glib_none().0, &mut out_commit, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(out_commit)) } else { Err(from_glib_full(error)) } - } - } - - fn write_commit_detached_metadata<'a, 'b, P: Into>, Q: Into>>(&self, checksum: &str, metadata: P, cancellable: Q) -> Result<(), Error> { - let metadata = metadata.into(); - let metadata = metadata.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_commit_detached_metadata(self.to_glib_none().0, checksum.to_glib_none().0, metadata.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - 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 { - let parent = parent.into(); - let parent = parent.to_glib_none(); - let subject = subject.into(); - let subject = subject.to_glib_none(); - let body = body.into(); - let body = body.to_glib_none(); - let metadata = metadata.into(); - let metadata = metadata.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_commit = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_commit_with_time(self.to_glib_none().0, parent.0, subject.0, body.0, metadata.0, root.to_glib_none().0, time, &mut out_commit, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(out_commit)) } else { Err(from_glib_full(error)) } - } - } - - fn write_config(&self, new_config: &glib::KeyFile) -> Result<(), Error> { - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_config(self.to_glib_none().0, new_config.to_glib_none().0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(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> { - // unsafe { TODO: call ffi::ostree_repo_write_content() } - //} - - fn write_content_trusted<'a, P: IsA, Q: Into>>(&self, checksum: &str, object_input: &P, length: u64, cancellable: Q) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_content_trusted(self.to_glib_none().0, checksum.to_glib_none().0, object_input.to_glib_none().0, length, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn write_dfd_to_mtree<'a, 'b, P: Into>, Q: Into>>(&self, dfd: i32, path: &str, mtree: &MutableTree, modifier: P, cancellable: Q) -> Result<(), Error> { - let modifier = modifier.into(); - let modifier = modifier.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_dfd_to_mtree(self.to_glib_none().0, dfd, path.to_glib_none().0, mtree.to_glib_none().0, modifier.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn write_directory_to_mtree<'a, 'b, P: IsA, Q: Into>, R: Into>>(&self, dir: &P, mtree: &MutableTree, modifier: Q, cancellable: R) -> Result<(), Error> { - let modifier = modifier.into(); - let modifier = modifier.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_directory_to_mtree(self.to_glib_none().0, dir.to_glib_none().0, mtree.to_glib_none().0, modifier.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(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> { - // unsafe { TODO: call ffi::ostree_repo_write_metadata() } - //} - - fn write_metadata_stream_trusted<'a, P: IsA, Q: Into>>(&self, objtype: ObjectType, checksum: &str, object_input: &P, length: u64, cancellable: Q) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_metadata_stream_trusted(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, object_input.to_glib_none().0, length, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn write_metadata_trusted<'a, P: Into>>(&self, objtype: ObjectType, checksum: &str, variant: &glib::Variant, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_metadata_trusted(self.to_glib_none().0, objtype.to_glib(), checksum.to_glib_none().0, variant.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn write_mtree<'a, P: Into>>(&self, mtree: &MutableTree, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_file = ptr::null_mut(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_write_mtree(self.to_glib_none().0, mtree.to_glib_none().0, &mut out_file, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib_full(out_file)) } else { Err(from_glib_full(error)) } - } - } - - fn get_property_remotes_config_dir(&self) -> Option { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "remotes-config-dir".to_glib_none().0, value.to_glib_none_mut().0); - value.get() - } - } - - fn get_property_sysroot_path(&self) -> Option { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "sysroot-path".to_glib_none().0, value.to_glib_none_mut().0); - value.get() - } - } - - fn connect_gpg_verify_result(&self, f: F) -> SignalHandlerId { - unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "gpg-verify-result", - transmute(gpg_verify_result_trampoline:: as usize), Box_::into_raw(f) as *mut _) + let f: Box_ = Box_::new(f); + connect_raw(self.as_ptr() as *mut _, b"gpg-verify-result\0".as_ptr() as *const _, + Some(transmute(gpg_verify_result_trampoline:: as usize)), Box_::into_raw(f)) } } } -unsafe extern "C" fn gpg_verify_result_trampoline

(this: *mut ffi::OstreeRepo, checksum: *mut libc::c_char, result: *mut ffi::OstreeGpgVerifyResult, f: glib_ffi::gpointer) -where P: IsA { - let f: &&(Fn(&P, &str, &GpgVerifyResult) + 'static) = transmute(f); - f(&Repo::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(checksum), &from_glib_borrow(result)) +unsafe extern "C" fn gpg_verify_result_trampoline(this: *mut ostree_sys::OstreeRepo, checksum: *mut libc::c_char, result: *mut ostree_sys::OstreeGpgVerifyResult, f: glib_sys::gpointer) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this), &GString::from_glib_borrow(checksum), &from_glib_borrow(result)) +} + +impl fmt::Display for Repo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Repo") + } } diff --git a/rust-bindings/rust/src/auto/repo_commit_modifier.rs b/rust-bindings/rust/src/auto/repo_commit_modifier.rs index e4c02fc6..9854cee7 100644 --- a/rust-bindings/rust/src/auto/repo_commit_modifier.rs +++ b/rust-bindings/rust/src/auto/repo_commit_modifier.rs @@ -2,48 +2,64 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +use Repo; #[cfg(any(feature = "v2017_13", feature = "dox"))] use RepoDevInoCache; use SePolicy; -use ffi; +use gio; +use glib; +use glib::GString; use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::ptr; +use ostree_sys; +use std::boxed::Box as Box_; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct RepoCommitModifier(Shared); + pub struct RepoCommitModifier(Shared); match fn { - ref => |ptr| ffi::ostree_repo_commit_modifier_ref(ptr), - unref => |ptr| ffi::ostree_repo_commit_modifier_unref(ptr), - get_type => || ffi::ostree_repo_commit_modifier_get_type(), + ref => |ptr| ostree_sys::ostree_repo_commit_modifier_ref(ptr), + unref => |ptr| ostree_sys::ostree_repo_commit_modifier_unref(ptr), + get_type => || ostree_sys::ostree_repo_commit_modifier_get_type(), } } impl RepoCommitModifier { - //pub fn new<'a, P: Into>>(flags: /*Ignored*/RepoCommitModifierFlags, commit_filter: P, destroy_notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> RepoCommitModifier { - // unsafe { TODO: call ffi::ostree_repo_commit_modifier_new() } + //pub fn new(flags: /*Ignored*/RepoCommitModifierFlags, commit_filter: /*Unimplemented*/Fn(&Repo, &str, &gio::FileInfo) -> /*Ignored*/RepoCommitFilterResult, user_data: /*Unimplemented*/Option) -> RepoCommitModifier { + // unsafe { TODO: call ostree_sys:ostree_repo_commit_modifier_new() } //} #[cfg(any(feature = "v2017_13", feature = "dox"))] pub fn set_devino_cache(&self, cache: &RepoDevInoCache) { unsafe { - ffi::ostree_repo_commit_modifier_set_devino_cache(self.to_glib_none().0, cache.to_glib_none().0); + ostree_sys::ostree_repo_commit_modifier_set_devino_cache(self.to_glib_none().0, cache.to_glib_none().0); } } - pub fn set_sepolicy<'a, P: Into>>(&self, sepolicy: P) { - let sepolicy = sepolicy.into(); - let sepolicy = sepolicy.to_glib_none(); + pub fn set_sepolicy(&self, sepolicy: Option<&SePolicy>) { unsafe { - ffi::ostree_repo_commit_modifier_set_sepolicy(self.to_glib_none().0, sepolicy.0); + ostree_sys::ostree_repo_commit_modifier_set_sepolicy(self.to_glib_none().0, sepolicy.to_glib_none().0); } } - //pub fn set_xattr_callback(&self, callback: /*Unknown conversion*//*Unimplemented*/RepoCommitModifierXattrCallback, destroy: /*Unknown conversion*//*Unimplemented*/DestroyNotify) { - // unsafe { TODO: call ffi::ostree_repo_commit_modifier_set_xattr_callback() } - //} + pub fn set_xattr_callback glib::Variant + 'static>(&self, callback: P) { + let callback_data: Box_

= Box::new(callback); + unsafe extern "C" fn callback_func glib::Variant + 'static>(repo: *mut ostree_sys::OstreeRepo, path: *const libc::c_char, file_info: *mut gio_sys::GFileInfo, user_data: glib_sys::gpointer) -> *mut glib_sys::GVariant { + let repo = from_glib_borrow(repo); + let path: GString = from_glib_borrow(path); + let file_info = from_glib_borrow(file_info); + let callback: &P = &*(user_data as *mut _); + let res = (*callback)(&repo, path.as_str(), &file_info); + res.to_glib_full() + } + let callback = Some(callback_func::

as _); + unsafe extern "C" fn destroy_func glib::Variant + 'static>(data: glib_sys::gpointer) { + let _callback: Box_

= Box_::from_raw(data as *mut _); + } + let destroy_call2 = Some(destroy_func::

as _); + let super_callback0: Box_

= callback_data; + unsafe { + ostree_sys::ostree_repo_commit_modifier_set_xattr_callback(self.to_glib_none().0, callback, destroy_call2, Box::into_raw(super_callback0) as *mut _); + } + } } diff --git a/rust-bindings/rust/src/auto/repo_dev_ino_cache.rs b/rust-bindings/rust/src/auto/repo_dev_ino_cache.rs index 94c5a3b0..70ca418b 100644 --- a/rust-bindings/rust/src/auto/repo_dev_ino_cache.rs +++ b/rust-bindings/rust/src/auto/repo_dev_ino_cache.rs @@ -2,28 +2,24 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::ptr; +use ostree_sys; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct RepoDevInoCache(Shared); + pub struct RepoDevInoCache(Shared); match fn { - ref => |ptr| ffi::ostree_repo_devino_cache_ref(ptr), - unref => |ptr| ffi::ostree_repo_devino_cache_unref(ptr), - get_type => || ffi::ostree_repo_devino_cache_get_type(), + ref => |ptr| ostree_sys::ostree_repo_devino_cache_ref(ptr), + unref => |ptr| ostree_sys::ostree_repo_devino_cache_unref(ptr), + get_type => || ostree_sys::ostree_repo_devino_cache_get_type(), } } impl RepoDevInoCache { pub fn new() -> RepoDevInoCache { unsafe { - from_glib_full(ffi::ostree_repo_devino_cache_new()) + from_glib_full(ostree_sys::ostree_repo_devino_cache_new()) } } } diff --git a/rust-bindings/rust/src/auto/repo_file.rs b/rust-bindings/rust/src/auto/repo_file.rs index 500023fe..d7e7b81e 100644 --- a/rust-bindings/rust/src/auto/repo_file.rs +++ b/rust-bindings/rust/src/auto/repo_file.rs @@ -4,49 +4,48 @@ use Error; use Repo; -use ffi; use gio; -use gio_ffi; use glib; +use glib::GString; use glib::object::IsA; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use ostree_sys; +use std::fmt; use std::mem; use std::ptr; glib_wrapper! { - pub struct RepoFile(Object): [ - gio::File => gio_ffi::GFile, - ]; + pub struct RepoFile(Object) @implements gio::File; match fn { - get_type => || ffi::ostree_repo_file_get_type(), + get_type => || ostree_sys::ostree_repo_file_get_type(), } } -pub trait RepoFileExt { +pub const NONE_REPO_FILE: Option<&RepoFile> = None; + +pub trait RepoFileExt: 'static { fn ensure_resolved(&self) -> Result<(), Error>; - fn get_checksum(&self) -> Option; + fn get_checksum(&self) -> Option; fn get_repo(&self) -> Option; fn get_root(&self) -> Option; - fn get_xattrs<'a, P: Into>>(&self, cancellable: P) -> Result; + fn get_xattrs>(&self, cancellable: Option<&P>) -> Result; fn tree_find_child(&self, name: &str) -> (i32, bool, glib::Variant); fn tree_get_contents(&self) -> Option; - fn tree_get_contents_checksum(&self) -> Option; + fn tree_get_contents_checksum(&self) -> Option; fn tree_get_metadata(&self) -> Option; - fn tree_get_metadata_checksum(&self) -> Option; + fn tree_get_metadata_checksum(&self) -> Option; - fn tree_query_child<'a, P: Into>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: P) -> Result; + fn tree_query_child>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: Option<&P>) -> Result; fn tree_set_metadata(&self, checksum: &str, metadata: &glib::Variant); } @@ -55,36 +54,34 @@ impl> RepoFileExt for O { fn ensure_resolved(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_file_ensure_resolved(self.to_glib_none().0, &mut error); + let _ = ostree_sys::ostree_repo_file_ensure_resolved(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - fn get_checksum(&self) -> Option { + fn get_checksum(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_repo_file_get_checksum(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_repo_file_get_checksum(self.as_ref().to_glib_none().0)) } } fn get_repo(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_repo_file_get_repo(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_repo_file_get_repo(self.as_ref().to_glib_none().0)) } } fn get_root(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_repo_file_get_root(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_repo_file_get_root(self.as_ref().to_glib_none().0)) } } - fn get_xattrs<'a, P: Into>>(&self, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + fn get_xattrs>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut out_xattrs = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_file_get_xattrs(self.to_glib_none().0, &mut out_xattrs, cancellable.0, &mut error); + let _ = ostree_sys::ostree_repo_file_get_xattrs(self.as_ref().to_glib_none().0, &mut out_xattrs, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(out_xattrs)) } else { Err(from_glib_full(error)) } } } @@ -93,49 +90,53 @@ impl> RepoFileExt for O { unsafe { let mut is_dir = mem::uninitialized(); let mut out_container = ptr::null_mut(); - let ret = ffi::ostree_repo_file_tree_find_child(self.to_glib_none().0, name.to_glib_none().0, &mut is_dir, &mut out_container); + let ret = ostree_sys::ostree_repo_file_tree_find_child(self.as_ref().to_glib_none().0, name.to_glib_none().0, &mut is_dir, &mut out_container); (ret, from_glib(is_dir), from_glib_full(out_container)) } } fn tree_get_contents(&self) -> Option { unsafe { - from_glib_full(ffi::ostree_repo_file_tree_get_contents(self.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_repo_file_tree_get_contents(self.as_ref().to_glib_none().0)) } } - fn tree_get_contents_checksum(&self) -> Option { + fn tree_get_contents_checksum(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_repo_file_tree_get_contents_checksum(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_repo_file_tree_get_contents_checksum(self.as_ref().to_glib_none().0)) } } fn tree_get_metadata(&self) -> Option { unsafe { - from_glib_full(ffi::ostree_repo_file_tree_get_metadata(self.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_repo_file_tree_get_metadata(self.as_ref().to_glib_none().0)) } } - fn tree_get_metadata_checksum(&self) -> Option { + fn tree_get_metadata_checksum(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_repo_file_tree_get_metadata_checksum(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_repo_file_tree_get_metadata_checksum(self.as_ref().to_glib_none().0)) } } - fn tree_query_child<'a, P: Into>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + fn tree_query_child>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: Option<&P>) -> Result { unsafe { let mut out_info = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_repo_file_tree_query_child(self.to_glib_none().0, n, attributes.to_glib_none().0, flags.to_glib(), &mut out_info, cancellable.0, &mut error); + let _ = ostree_sys::ostree_repo_file_tree_query_child(self.as_ref().to_glib_none().0, n, attributes.to_glib_none().0, flags.to_glib(), &mut out_info, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(out_info)) } else { Err(from_glib_full(error)) } } } fn tree_set_metadata(&self, checksum: &str, metadata: &glib::Variant) { unsafe { - ffi::ostree_repo_file_tree_set_metadata(self.to_glib_none().0, checksum.to_glib_none().0, metadata.to_glib_none().0); + ostree_sys::ostree_repo_file_tree_set_metadata(self.as_ref().to_glib_none().0, checksum.to_glib_none().0, metadata.to_glib_none().0); } } } + +impl fmt::Display for RepoFile { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RepoFile") + } +} diff --git a/rust-bindings/rust/src/auto/repo_transaction_stats.rs b/rust-bindings/rust/src/auto/repo_transaction_stats.rs index 5f94acf3..1011c4ae 100644 --- a/rust-bindings/rust/src/auto/repo_transaction_stats.rs +++ b/rust-bindings/rust/src/auto/repo_transaction_stats.rs @@ -2,20 +2,16 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT -use ffi; -use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; -use std::ptr; +use gobject_sys; +use ostree_sys; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] - pub struct RepoTransactionStats(Boxed); + pub struct RepoTransactionStats(Boxed); match fn { - copy => |ptr| gobject_ffi::g_boxed_copy(ffi::ostree_repo_transaction_stats_get_type(), ptr as *mut _) as *mut ffi::OstreeRepoTransactionStats, - free => |ptr| gobject_ffi::g_boxed_free(ffi::ostree_repo_transaction_stats_get_type(), ptr as *mut _), - get_type => || ffi::ostree_repo_transaction_stats_get_type(), + copy => |ptr| gobject_sys::g_boxed_copy(ostree_sys::ostree_repo_transaction_stats_get_type(), ptr as *mut _) as *mut ostree_sys::OstreeRepoTransactionStats, + free => |ptr| gobject_sys::g_boxed_free(ostree_sys::ostree_repo_transaction_stats_get_type(), ptr as *mut _), + get_type => || ostree_sys::ostree_repo_transaction_stats_get_type(), } } diff --git a/rust-bindings/rust/src/auto/se_policy.rs b/rust-bindings/rust/src/auto/se_policy.rs index 588895b2..f52c9535 100644 --- a/rust-bindings/rust/src/auto/se_policy.rs +++ b/rust-bindings/rust/src/auto/se_policy.rs @@ -4,127 +4,104 @@ use Error; use SePolicyRestoreconFlags; -use ffi; use gio; -use glib; +use glib::GString; use glib::StaticType; use glib::Value; use glib::object::IsA; +use glib::object::ObjectType as _; use glib::translate::*; -use glib_ffi; -use gobject_ffi; -use std::mem; +use gobject_sys; +use ostree_sys; +use std::fmt; use std::ptr; glib_wrapper! { - pub struct SePolicy(Object); + pub struct SePolicy(Object); match fn { - get_type => || ffi::ostree_sepolicy_get_type(), + get_type => || ostree_sys::ostree_sepolicy_get_type(), } } impl SePolicy { - pub fn new<'a, P: IsA, Q: Into>>(path: &P, cancellable: Q) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn new, Q: IsA>(path: &P, cancellable: Option<&Q>) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::ostree_sepolicy_new(path.to_glib_none().0, cancellable.0, &mut error); + let ret = ostree_sys::ostree_sepolicy_new(path.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2017_4", feature = "dox"))] - pub fn new_at<'a, P: Into>>(rootfs_dfd: i32, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn new_at>(rootfs_dfd: i32, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::ostree_sepolicy_new_at(rootfs_dfd, cancellable.0, &mut error); + let ret = ostree_sys::ostree_sepolicy_new_at(rootfs_dfd, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } - //pub fn fscreatecon_cleanup>>(unused: P) { - // unsafe { TODO: call ffi::ostree_sepolicy_fscreatecon_cleanup() } - //} -} - -pub trait SePolicyExt { #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_csum(&self) -> Option; - - fn get_label<'a, P: Into>>(&self, relpath: &str, unix_mode: u32, cancellable: P) -> Result; - - fn get_name(&self) -> Option; - - fn get_path(&self) -> Option; - - fn restorecon<'a, 'b, P: Into>, Q: IsA, R: Into>>(&self, path: &str, info: P, target: &Q, flags: SePolicyRestoreconFlags, cancellable: R) -> Result; - - fn setfscreatecon(&self, path: &str, mode: u32) -> Result<(), Error>; - - fn get_property_rootfs_dfd(&self) -> i32; -} - -impl + IsA> SePolicyExt for O { - #[cfg(any(feature = "v2016_5", feature = "dox"))] - fn get_csum(&self) -> Option { + pub fn get_csum(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_sepolicy_get_csum(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_sepolicy_get_csum(self.to_glib_none().0)) } } - fn get_label<'a, P: Into>>(&self, relpath: &str, unix_mode: u32, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn get_label>(&self, relpath: &str, unix_mode: u32, cancellable: Option<&P>) -> Result { unsafe { let mut out_label = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_sepolicy_get_label(self.to_glib_none().0, relpath.to_glib_none().0, unix_mode, &mut out_label, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sepolicy_get_label(self.to_glib_none().0, relpath.to_glib_none().0, unix_mode, &mut out_label, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(out_label)) } else { Err(from_glib_full(error)) } } } - fn get_name(&self) -> Option { + pub fn get_name(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_sepolicy_get_name(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_sepolicy_get_name(self.to_glib_none().0)) } } - fn get_path(&self) -> Option { + pub fn get_path(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_sepolicy_get_path(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_sepolicy_get_path(self.to_glib_none().0)) } } - fn restorecon<'a, 'b, P: Into>, Q: IsA, R: Into>>(&self, path: &str, info: P, target: &Q, flags: SePolicyRestoreconFlags, cancellable: R) -> Result { - let info = info.into(); - let info = info.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn restorecon, Q: IsA>(&self, path: &str, info: Option<&gio::FileInfo>, target: &P, flags: SePolicyRestoreconFlags, cancellable: Option<&Q>) -> Result { unsafe { let mut out_new_label = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_sepolicy_restorecon(self.to_glib_none().0, path.to_glib_none().0, info.0, target.to_glib_none().0, flags.to_glib(), &mut out_new_label, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sepolicy_restorecon(self.to_glib_none().0, path.to_glib_none().0, info.to_glib_none().0, target.as_ref().to_glib_none().0, flags.to_glib(), &mut out_new_label, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(out_new_label)) } else { Err(from_glib_full(error)) } } } - fn setfscreatecon(&self, path: &str, mode: u32) -> Result<(), Error> { + pub fn setfscreatecon(&self, path: &str, mode: u32) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sepolicy_setfscreatecon(self.to_glib_none().0, path.to_glib_none().0, mode, &mut error); + let _ = ostree_sys::ostree_sepolicy_setfscreatecon(self.to_glib_none().0, path.to_glib_none().0, mode, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - fn get_property_rootfs_dfd(&self) -> i32 { + pub fn get_property_rootfs_dfd(&self) -> i32 { unsafe { let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "rootfs-dfd".to_glib_none().0, value.to_glib_none_mut().0); + gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"rootfs-dfd\0".as_ptr() as *const _, value.to_glib_none_mut().0); value.get().unwrap() } } + + //pub fn fscreatecon_cleanup(unused: /*Unimplemented*/Option) { + // unsafe { TODO: call ostree_sys:ostree_sepolicy_fscreatecon_cleanup() } + //} +} + +impl fmt::Display for SePolicy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "SePolicy") + } } diff --git a/rust-bindings/rust/src/auto/sysroot.rs b/rust-bindings/rust/src/auto/sysroot.rs index 087b2694..60eae219 100644 --- a/rust-bindings/rust/src/auto/sysroot.rs +++ b/rust-bindings/rust/src/auto/sysroot.rs @@ -8,508 +8,365 @@ use DeploymentUnlockedState; use Error; use Repo; use SysrootSimpleWriteDeploymentFlags; -use ffi; #[cfg(feature = "futures")] -use futures_core; +use futures::future; use gio; -use gio_ffi; +use gio_sys; use glib; -#[cfg(any(feature = "v2017_10", feature = "dox"))] -use glib::object::Downcast; +use glib::GString; use glib::object::IsA; #[cfg(any(feature = "v2017_10", feature = "dox"))] +use glib::object::ObjectType as _; +#[cfg(any(feature = "v2017_10", feature = "dox"))] use glib::signal::SignalHandlerId; #[cfg(any(feature = "v2017_10", feature = "dox"))] -use glib::signal::connect; +use glib::signal::connect_raw; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib_sys; +use gobject_sys; #[cfg(any(feature = "v2017_10", feature = "dox"))] use libc; +use ostree_sys; use std::boxed::Box as Box_; +use std::fmt; use std::mem; #[cfg(any(feature = "v2017_10", feature = "dox"))] use std::mem::transmute; use std::ptr; glib_wrapper! { - pub struct Sysroot(Object); + pub struct Sysroot(Object); match fn { - get_type => || ffi::ostree_sysroot_get_type(), + get_type => || ostree_sys::ostree_sysroot_get_type(), } } impl Sysroot { - pub fn new<'a, P: IsA + 'a, Q: Into>>(path: Q) -> Sysroot { - let path = path.into(); - let path = path.to_glib_none(); + pub fn new>(path: Option<&P>) -> Sysroot { unsafe { - from_glib_full(ffi::ostree_sysroot_new(path.0)) + from_glib_full(ostree_sys::ostree_sysroot_new(path.map(|p| p.as_ref()).to_glib_none().0)) } } pub fn new_default() -> Sysroot { unsafe { - from_glib_full(ffi::ostree_sysroot_new_default()) + from_glib_full(ostree_sys::ostree_sysroot_new_default()) } } - pub fn get_deployment_origin_path>(deployment_path: &P) -> Option { - unsafe { - from_glib_full(ffi::ostree_sysroot_get_deployment_origin_path(deployment_path.to_glib_none().0)) - } - } -} - -pub trait SysrootExt: Sized { - fn cleanup<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - //#[cfg(any(feature = "v2018_6", feature = "dox"))] - //fn cleanup_prune_repo<'a, P: Into>>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: P) -> Result<(i32, i32, u64), Error>; - - fn deploy_tree<'a, 'b, 'c, 'd, P: Into>, Q: Into>, R: Into>, S: Into>>(&self, osname: P, revision: &str, origin: Q, provided_merge_deployment: R, override_kernel_argv: &[&str], cancellable: S) -> Result; - - fn deployment_set_kargs<'a, P: Into>>(&self, deployment: &Deployment, new_kargs: &[&str], cancellable: P) -> Result<(), Error>; - - fn deployment_set_mutable<'a, P: Into>>(&self, deployment: &Deployment, is_mutable: bool, cancellable: P) -> Result<(), Error>; - - #[cfg(any(feature = "v2018_3", feature = "dox"))] - fn deployment_set_pinned(&self, deployment: &Deployment, is_pinned: bool) -> Result<(), Error>; - - #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn deployment_unlock<'a, P: Into>>(&self, deployment: &Deployment, unlocked_state: DeploymentUnlockedState, cancellable: P) -> Result<(), Error>; - - fn ensure_initialized<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - fn get_booted_deployment(&self) -> Option; - - fn get_bootversion(&self) -> i32; - - fn get_deployment_directory(&self, deployment: &Deployment) -> Option; - - fn get_deployment_dirpath(&self, deployment: &Deployment) -> Option; - - //fn get_deployments(&self) -> /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 }; - - fn get_fd(&self) -> i32; - - fn get_merge_deployment<'a, P: Into>>(&self, osname: P) -> Option; - - fn get_path(&self) -> Option; - - fn get_repo<'a, P: Into>>(&self, cancellable: P) -> Result; - - #[cfg(any(feature = "v2018_5", feature = "dox"))] - fn get_staged_deployment(&self) -> Option; - - fn get_subbootversion(&self) -> i32; - - #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn init_osname<'a, P: Into>>(&self, osname: &str, cancellable: P) -> Result<(), Error>; - - fn load<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn load_if_changed<'a, P: Into>>(&self, cancellable: P) -> Result; - - fn lock(&self) -> Result<(), Error>; - - fn lock_async<'a, P: Into>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cancellable: P, callback: Q); - - #[cfg(feature = "futures")] - fn lock_async_future(&self) -> Box_>; - - fn origin_new_from_refspec(&self, refspec: &str) -> Option; - - fn prepare_cleanup<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - #[cfg(any(feature = "v2017_7", feature = "dox"))] - fn query_deployments_for<'a, P: Into>>(&self, osname: P) -> (Deployment, Deployment); - - #[cfg(any(feature = "v2017_7", feature = "dox"))] - fn repo(&self) -> Option; - - fn simple_write_deployment<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, osname: P, new_deployment: &Deployment, merge_deployment: Q, flags: SysrootSimpleWriteDeploymentFlags, cancellable: R) -> Result<(), Error>; - - #[cfg(any(feature = "v2018_5", feature = "dox"))] - fn stage_tree<'a, 'b, 'c, 'd, P: Into>, Q: Into>, R: Into>, S: Into>>(&self, osname: P, revision: &str, origin: Q, merge_deployment: R, override_kernel_argv: &[&str], cancellable: S) -> Result; - - fn try_lock(&self) -> Result; - - fn unload(&self); - - fn unlock(&self); - - //fn write_deployments<'a, P: Into>>(&self, new_deployments: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 }, cancellable: P) -> Result<(), Error>; - - //#[cfg(any(feature = "v2017_4", feature = "dox"))] - //fn write_deployments_with_options<'a, P: Into>>(&self, new_deployments: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 }, opts: /*Ignored*/&mut SysrootWriteDeploymentsOpts, cancellable: P) -> Result<(), Error>; - - fn write_origin_file<'a, 'b, P: Into>, Q: Into>>(&self, deployment: &Deployment, new_origin: P, cancellable: Q) -> Result<(), Error>; - - #[cfg(any(feature = "v2017_10", feature = "dox"))] - fn connect_journal_msg(&self, f: F) -> SignalHandlerId; -} - -impl + IsA + Clone + 'static> SysrootExt for O { - fn cleanup<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn cleanup>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_cleanup(self.to_glib_none().0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_cleanup(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } //#[cfg(any(feature = "v2018_6", feature = "dox"))] - //fn cleanup_prune_repo<'a, P: Into>>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: P) -> Result<(i32, i32, u64), Error> { - // unsafe { TODO: call ffi::ostree_sysroot_cleanup_prune_repo() } + //pub fn cleanup_prune_repo>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: Option<&P>) -> Result<(i32, i32, u64), Error> { + // unsafe { TODO: call ostree_sys:ostree_sysroot_cleanup_prune_repo() } //} - fn deploy_tree<'a, 'b, 'c, 'd, P: Into>, Q: Into>, R: Into>, S: Into>>(&self, osname: P, revision: &str, origin: Q, provided_merge_deployment: R, override_kernel_argv: &[&str], cancellable: S) -> Result { - let osname = osname.into(); - let osname = osname.to_glib_none(); - let origin = origin.into(); - let origin = origin.to_glib_none(); - let provided_merge_deployment = provided_merge_deployment.into(); - let provided_merge_deployment = provided_merge_deployment.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn deploy_tree>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, provided_merge_deployment: Option<&Deployment>, override_kernel_argv: &[&str], cancellable: Option<&P>) -> Result { unsafe { let mut out_new_deployment = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_deploy_tree(self.to_glib_none().0, osname.0, revision.to_glib_none().0, origin.0, provided_merge_deployment.0, override_kernel_argv.to_glib_none().0, &mut out_new_deployment, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_deploy_tree(self.to_glib_none().0, osname.to_glib_none().0, revision.to_glib_none().0, origin.to_glib_none().0, provided_merge_deployment.to_glib_none().0, override_kernel_argv.to_glib_none().0, &mut out_new_deployment, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(out_new_deployment)) } else { Err(from_glib_full(error)) } } } - fn deployment_set_kargs<'a, P: Into>>(&self, deployment: &Deployment, new_kargs: &[&str], cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn deployment_set_kargs>(&self, deployment: &Deployment, new_kargs: &[&str], cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_deployment_set_kargs(self.to_glib_none().0, deployment.to_glib_none().0, new_kargs.to_glib_none().0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_deployment_set_kargs(self.to_glib_none().0, deployment.to_glib_none().0, new_kargs.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - fn deployment_set_mutable<'a, P: Into>>(&self, deployment: &Deployment, is_mutable: bool, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn deployment_set_mutable>(&self, deployment: &Deployment, is_mutable: bool, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_deployment_set_mutable(self.to_glib_none().0, deployment.to_glib_none().0, is_mutable.to_glib(), cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_deployment_set_mutable(self.to_glib_none().0, deployment.to_glib_none().0, is_mutable.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2018_3", feature = "dox"))] - fn deployment_set_pinned(&self, deployment: &Deployment, is_pinned: bool) -> Result<(), Error> { + pub fn deployment_set_pinned(&self, deployment: &Deployment, is_pinned: bool) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_deployment_set_pinned(self.to_glib_none().0, deployment.to_glib_none().0, is_pinned.to_glib(), &mut error); + let _ = ostree_sys::ostree_sysroot_deployment_set_pinned(self.to_glib_none().0, deployment.to_glib_none().0, is_pinned.to_glib(), &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn deployment_unlock<'a, P: Into>>(&self, deployment: &Deployment, unlocked_state: DeploymentUnlockedState, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn deployment_unlock>(&self, deployment: &Deployment, unlocked_state: DeploymentUnlockedState, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_deployment_unlock(self.to_glib_none().0, deployment.to_glib_none().0, unlocked_state.to_glib(), cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_deployment_unlock(self.to_glib_none().0, deployment.to_glib_none().0, unlocked_state.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - fn ensure_initialized<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn ensure_initialized>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_ensure_initialized(self.to_glib_none().0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_ensure_initialized(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - fn get_booted_deployment(&self) -> Option { + pub fn get_booted_deployment(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_sysroot_get_booted_deployment(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_sysroot_get_booted_deployment(self.to_glib_none().0)) } } - fn get_bootversion(&self) -> i32 { + pub fn get_bootversion(&self) -> i32 { unsafe { - ffi::ostree_sysroot_get_bootversion(self.to_glib_none().0) + ostree_sys::ostree_sysroot_get_bootversion(self.to_glib_none().0) } } - fn get_deployment_directory(&self, deployment: &Deployment) -> Option { + pub fn get_deployment_directory(&self, deployment: &Deployment) -> Option { unsafe { - from_glib_full(ffi::ostree_sysroot_get_deployment_directory(self.to_glib_none().0, deployment.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_sysroot_get_deployment_directory(self.to_glib_none().0, deployment.to_glib_none().0)) } } - fn get_deployment_dirpath(&self, deployment: &Deployment) -> Option { + pub fn get_deployment_dirpath(&self, deployment: &Deployment) -> Option { unsafe { - from_glib_full(ffi::ostree_sysroot_get_deployment_dirpath(self.to_glib_none().0, deployment.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_sysroot_get_deployment_dirpath(self.to_glib_none().0, deployment.to_glib_none().0)) } } - //fn get_deployments(&self) -> /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 } { - // unsafe { TODO: call ffi::ostree_sysroot_get_deployments() } + //pub fn get_deployments(&self) -> /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 } { + // unsafe { TODO: call ostree_sys:ostree_sysroot_get_deployments() } //} - fn get_fd(&self) -> i32 { + pub fn get_fd(&self) -> i32 { unsafe { - ffi::ostree_sysroot_get_fd(self.to_glib_none().0) + ostree_sys::ostree_sysroot_get_fd(self.to_glib_none().0) } } - fn get_merge_deployment<'a, P: Into>>(&self, osname: P) -> Option { - let osname = osname.into(); - let osname = osname.to_glib_none(); + pub fn get_merge_deployment(&self, osname: Option<&str>) -> Option { unsafe { - from_glib_full(ffi::ostree_sysroot_get_merge_deployment(self.to_glib_none().0, osname.0)) + from_glib_full(ostree_sys::ostree_sysroot_get_merge_deployment(self.to_glib_none().0, osname.to_glib_none().0)) } } - fn get_path(&self) -> Option { + pub fn get_path(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_sysroot_get_path(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_sysroot_get_path(self.to_glib_none().0)) } } - fn get_repo<'a, P: Into>>(&self, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn get_repo>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut out_repo = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_get_repo(self.to_glib_none().0, &mut out_repo, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_get_repo(self.to_glib_none().0, &mut out_repo, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(out_repo)) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2018_5", feature = "dox"))] - fn get_staged_deployment(&self) -> Option { + pub fn get_staged_deployment(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_sysroot_get_staged_deployment(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_sysroot_get_staged_deployment(self.to_glib_none().0)) } } - fn get_subbootversion(&self) -> i32 { + pub fn get_subbootversion(&self) -> i32 { unsafe { - ffi::ostree_sysroot_get_subbootversion(self.to_glib_none().0) + ostree_sys::ostree_sysroot_get_subbootversion(self.to_glib_none().0) } } #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn init_osname<'a, P: Into>>(&self, osname: &str, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn init_osname>(&self, osname: &str, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_init_osname(self.to_glib_none().0, osname.to_glib_none().0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_init_osname(self.to_glib_none().0, osname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - fn load<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn load>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_load(self.to_glib_none().0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_load(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn load_if_changed<'a, P: Into>>(&self, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn load_if_changed>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut out_changed = mem::uninitialized(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_load_if_changed(self.to_glib_none().0, &mut out_changed, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_load_if_changed(self.to_glib_none().0, &mut out_changed, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) } } } - fn lock(&self) -> Result<(), Error> { + pub fn lock(&self) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_lock(self.to_glib_none().0, &mut error); + let _ = ostree_sys::ostree_sysroot_lock(self.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - fn lock_async<'a, P: Into>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cancellable: P, callback: Q) { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - let user_data: Box> = Box::new(Box::new(callback)); - unsafe extern "C" fn lock_async_trampoline) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer) - { + pub fn lock_async, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cancellable: Option<&P>, callback: Q) { + let user_data: Box = Box::new(callback); + unsafe extern "C" fn lock_async_trampoline) + Send + 'static>(_source_object: *mut gobject_sys::GObject, res: *mut gio_sys::GAsyncResult, user_data: glib_sys::gpointer) { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_lock_finish(_source_object as *mut _, res, &mut error); + let _ = ostree_sys::ostree_sysroot_lock_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; - let callback: Box> = Box::from_raw(user_data as *mut _); + let callback: Box = Box::from_raw(user_data as *mut _); callback(result); } let callback = lock_async_trampoline::; unsafe { - ffi::ostree_sysroot_lock_async(self.to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _); + ostree_sys::ostree_sysroot_lock_async(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _); } } #[cfg(feature = "futures")] - fn lock_async_future(&self) -> Box_> { + pub fn lock_async_future(&self) -> Box_> + std::marker::Unpin> { use gio::GioFuture; use fragile::Fragile; GioFuture::new(self, move |obj, send| { let cancellable = gio::Cancellable::new(); let send = Fragile::new(send); - let obj_clone = Fragile::new(obj.clone()); obj.lock_async( - Some(&cancellable), - move |res| { - let obj = obj_clone.into_inner(); - let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v)); - let _ = send.into_inner().send(res); - }, + Some(&cancellable), + move |res| { + let _ = send.into_inner().send(res); + }, ); cancellable }) } - fn origin_new_from_refspec(&self, refspec: &str) -> Option { + pub fn origin_new_from_refspec(&self, refspec: &str) -> Option { unsafe { - from_glib_full(ffi::ostree_sysroot_origin_new_from_refspec(self.to_glib_none().0, refspec.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_sysroot_origin_new_from_refspec(self.to_glib_none().0, refspec.to_glib_none().0)) } } - fn prepare_cleanup<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn prepare_cleanup>(&self, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_prepare_cleanup(self.to_glib_none().0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_prepare_cleanup(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2017_7", feature = "dox"))] - fn query_deployments_for<'a, P: Into>>(&self, osname: P) -> (Deployment, Deployment) { - let osname = osname.into(); - let osname = osname.to_glib_none(); + pub fn query_deployments_for(&self, osname: Option<&str>) -> (Deployment, Deployment) { unsafe { let mut out_pending = ptr::null_mut(); let mut out_rollback = ptr::null_mut(); - ffi::ostree_sysroot_query_deployments_for(self.to_glib_none().0, osname.0, &mut out_pending, &mut out_rollback); + ostree_sys::ostree_sysroot_query_deployments_for(self.to_glib_none().0, osname.to_glib_none().0, &mut out_pending, &mut out_rollback); (from_glib_full(out_pending), from_glib_full(out_rollback)) } } #[cfg(any(feature = "v2017_7", feature = "dox"))] - fn repo(&self) -> Option { + pub fn repo(&self) -> Option { unsafe { - from_glib_none(ffi::ostree_sysroot_repo(self.to_glib_none().0)) + from_glib_none(ostree_sys::ostree_sysroot_repo(self.to_glib_none().0)) } } - fn simple_write_deployment<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, osname: P, new_deployment: &Deployment, merge_deployment: Q, flags: SysrootSimpleWriteDeploymentFlags, cancellable: R) -> Result<(), Error> { - let osname = osname.into(); - let osname = osname.to_glib_none(); - let merge_deployment = merge_deployment.into(); - let merge_deployment = merge_deployment.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn simple_write_deployment>(&self, osname: Option<&str>, new_deployment: &Deployment, merge_deployment: Option<&Deployment>, flags: SysrootSimpleWriteDeploymentFlags, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_simple_write_deployment(self.to_glib_none().0, osname.0, new_deployment.to_glib_none().0, merge_deployment.0, flags.to_glib(), cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_simple_write_deployment(self.to_glib_none().0, osname.to_glib_none().0, new_deployment.to_glib_none().0, merge_deployment.to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2018_5", feature = "dox"))] - fn stage_tree<'a, 'b, 'c, 'd, P: Into>, Q: Into>, R: Into>, S: Into>>(&self, osname: P, revision: &str, origin: Q, merge_deployment: R, override_kernel_argv: &[&str], cancellable: S) -> Result { - let osname = osname.into(); - let osname = osname.to_glib_none(); - let origin = origin.into(); - let origin = origin.to_glib_none(); - let merge_deployment = merge_deployment.into(); - let merge_deployment = merge_deployment.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn stage_tree>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, merge_deployment: Option<&Deployment>, override_kernel_argv: &[&str], cancellable: Option<&P>) -> Result { unsafe { let mut out_new_deployment = ptr::null_mut(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_stage_tree(self.to_glib_none().0, osname.0, revision.to_glib_none().0, origin.0, merge_deployment.0, override_kernel_argv.to_glib_none().0, &mut out_new_deployment, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_stage_tree(self.to_glib_none().0, osname.to_glib_none().0, revision.to_glib_none().0, origin.to_glib_none().0, merge_deployment.to_glib_none().0, override_kernel_argv.to_glib_none().0, &mut out_new_deployment, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(out_new_deployment)) } else { Err(from_glib_full(error)) } } } - fn try_lock(&self) -> Result { + pub fn try_lock(&self) -> Result { unsafe { let mut out_acquired = mem::uninitialized(); let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_try_lock(self.to_glib_none().0, &mut out_acquired, &mut error); + let _ = ostree_sys::ostree_sysroot_try_lock(self.to_glib_none().0, &mut out_acquired, &mut error); if error.is_null() { Ok(from_glib(out_acquired)) } else { Err(from_glib_full(error)) } } } - fn unload(&self) { + pub fn unload(&self) { unsafe { - ffi::ostree_sysroot_unload(self.to_glib_none().0); + ostree_sys::ostree_sysroot_unload(self.to_glib_none().0); } } - fn unlock(&self) { + pub fn unlock(&self) { unsafe { - ffi::ostree_sysroot_unlock(self.to_glib_none().0); + ostree_sys::ostree_sysroot_unlock(self.to_glib_none().0); } } - //fn write_deployments<'a, P: Into>>(&self, new_deployments: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 }, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_sysroot_write_deployments() } + //pub fn write_deployments>(&self, new_deployments: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 }, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_sysroot_write_deployments() } //} //#[cfg(any(feature = "v2017_4", feature = "dox"))] - //fn write_deployments_with_options<'a, P: Into>>(&self, new_deployments: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 }, opts: /*Ignored*/&mut SysrootWriteDeploymentsOpts, cancellable: P) -> Result<(), Error> { - // unsafe { TODO: call ffi::ostree_sysroot_write_deployments_with_options() } + //pub fn write_deployments_with_options>(&self, new_deployments: /*Unknown conversion*//*Unimplemented*/PtrArray TypeId { ns_id: 1, id: 19 }, opts: /*Ignored*/&mut SysrootWriteDeploymentsOpts, cancellable: Option<&P>) -> Result<(), Error> { + // unsafe { TODO: call ostree_sys:ostree_sysroot_write_deployments_with_options() } //} - fn write_origin_file<'a, 'b, P: Into>, Q: Into>>(&self, deployment: &Deployment, new_origin: P, cancellable: Q) -> Result<(), Error> { - let new_origin = new_origin.into(); - let new_origin = new_origin.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn write_origin_file>(&self, deployment: &Deployment, new_origin: Option<&glib::KeyFile>, cancellable: Option<&P>) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_write_origin_file(self.to_glib_none().0, deployment.to_glib_none().0, new_origin.0, cancellable.0, &mut error); + let _ = ostree_sys::ostree_sysroot_write_origin_file(self.to_glib_none().0, deployment.to_glib_none().0, new_origin.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } - #[cfg(any(feature = "v2017_10", feature = "dox"))] - fn connect_journal_msg(&self, f: F) -> SignalHandlerId { + pub fn get_deployment_origin_path>(deployment_path: &P) -> Option { unsafe { - let f: Box_> = Box_::new(Box_::new(f)); - connect(self.to_glib_none().0, "journal-msg", - transmute(journal_msg_trampoline:: as usize), Box_::into_raw(f) as *mut _) + from_glib_full(ostree_sys::ostree_sysroot_get_deployment_origin_path(deployment_path.as_ref().to_glib_none().0)) + } + } + + #[cfg(any(feature = "v2017_10", feature = "dox"))] + pub fn connect_journal_msg(&self, f: F) -> SignalHandlerId { + unsafe { + let f: Box_ = Box_::new(f); + connect_raw(self.as_ptr() as *mut _, b"journal-msg\0".as_ptr() as *const _, + Some(transmute(journal_msg_trampoline:: as usize)), Box_::into_raw(f)) } } } #[cfg(any(feature = "v2017_10", feature = "dox"))] -unsafe extern "C" fn journal_msg_trampoline

(this: *mut ffi::OstreeSysroot, msg: *mut libc::c_char, f: glib_ffi::gpointer) -where P: IsA { - let f: &&(Fn(&P, &str) + 'static) = transmute(f); - f(&Sysroot::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(msg)) +unsafe extern "C" fn journal_msg_trampoline(this: *mut ostree_sys::OstreeSysroot, msg: *mut libc::c_char, f: glib_sys::gpointer) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this), &GString::from_glib_borrow(msg)) +} + +impl fmt::Display for Sysroot { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Sysroot") + } } diff --git a/rust-bindings/rust/src/auto/sysroot_upgrader.rs b/rust-bindings/rust/src/auto/sysroot_upgrader.rs index 4b504848..4e51db9c 100644 --- a/rust-bindings/rust/src/auto/sysroot_upgrader.rs +++ b/rust-bindings/rust/src/auto/sysroot_upgrader.rs @@ -9,180 +9,140 @@ use RepoPullFlags; use Sysroot; use SysrootUpgraderFlags; use SysrootUpgraderPullFlags; -use ffi; use gio; use glib; +use glib::GString; use glib::StaticType; use glib::Value; use glib::object::IsA; +use glib::object::ObjectType as _; use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use gobject_sys; +use ostree_sys; +use std::fmt; use std::mem; use std::ptr; glib_wrapper! { - pub struct SysrootUpgrader(Object); + pub struct SysrootUpgrader(Object); match fn { - get_type => || ffi::ostree_sysroot_upgrader_get_type(), + get_type => || ostree_sys::ostree_sysroot_upgrader_get_type(), } } impl SysrootUpgrader { - pub fn new<'a, P: Into>>(sysroot: &Sysroot, cancellable: P) -> Result { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn new>(sysroot: &Sysroot, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::ostree_sysroot_upgrader_new(sysroot.to_glib_none().0, cancellable.0, &mut error); + let ret = ostree_sys::ostree_sysroot_upgrader_new(sysroot.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } - pub fn new_for_os<'a, 'b, P: Into>, Q: Into>>(sysroot: &Sysroot, osname: P, cancellable: Q) -> Result { - let osname = osname.into(); - let osname = osname.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn new_for_os>(sysroot: &Sysroot, osname: Option<&str>, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::ostree_sysroot_upgrader_new_for_os(sysroot.to_glib_none().0, osname.0, cancellable.0, &mut error); + let ret = ostree_sys::ostree_sysroot_upgrader_new_for_os(sysroot.to_glib_none().0, osname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } - pub fn new_for_os_with_flags<'a, 'b, P: Into>, Q: Into>>(sysroot: &Sysroot, osname: P, flags: SysrootUpgraderFlags, cancellable: Q) -> Result { - let osname = osname.into(); - let osname = osname.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); + pub fn new_for_os_with_flags>(sysroot: &Sysroot, osname: Option<&str>, flags: SysrootUpgraderFlags, cancellable: Option<&P>) -> Result { unsafe { let mut error = ptr::null_mut(); - let ret = ffi::ostree_sysroot_upgrader_new_for_os_with_flags(sysroot.to_glib_none().0, osname.0, flags.to_glib(), cancellable.0, &mut error); + let ret = ostree_sys::ostree_sysroot_upgrader_new_for_os_with_flags(sysroot.to_glib_none().0, osname.to_glib_none().0, flags.to_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } + pub fn deploy>(&self, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_sysroot_upgrader_deploy(self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn dup_origin(&self) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_sysroot_upgrader_dup_origin(self.to_glib_none().0)) + } + } + + pub fn get_origin(&self) -> Option { + unsafe { + from_glib_none(ostree_sys::ostree_sysroot_upgrader_get_origin(self.to_glib_none().0)) + } + } + + pub fn get_origin_description(&self) -> Option { + unsafe { + from_glib_full(ostree_sys::ostree_sysroot_upgrader_get_origin_description(self.to_glib_none().0)) + } + } + + pub fn pull, Q: IsA>(&self, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: Option<&P>, cancellable: Option<&Q>) -> Result { + unsafe { + let mut out_changed = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_sysroot_upgrader_pull(self.to_glib_none().0, flags.to_glib(), upgrader_flags.to_glib(), progress.map(|p| p.as_ref()).to_glib_none().0, &mut out_changed, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) } + } + } + + pub fn pull_one_dir, Q: IsA>(&self, dir_to_pull: &str, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: Option<&P>, cancellable: Option<&Q>) -> Result { + unsafe { + let mut out_changed = mem::uninitialized(); + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_sysroot_upgrader_pull_one_dir(self.to_glib_none().0, dir_to_pull.to_glib_none().0, flags.to_glib(), upgrader_flags.to_glib(), progress.map(|p| p.as_ref()).to_glib_none().0, &mut out_changed, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) } + } + } + + pub fn set_origin>(&self, origin: Option<&glib::KeyFile>, cancellable: Option<&P>) -> Result<(), Error> { + unsafe { + let mut error = ptr::null_mut(); + let _ = ostree_sys::ostree_sysroot_upgrader_set_origin(self.to_glib_none().0, origin.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error); + if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } + } + } + + pub fn get_property_flags(&self) -> SysrootUpgraderFlags { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"flags\0".as_ptr() as *const _, value.to_glib_none_mut().0); + value.get().unwrap() + } + } + + pub fn get_property_osname(&self) -> Option { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"osname\0".as_ptr() as *const _, value.to_glib_none_mut().0); + value.get() + } + } + + pub fn get_property_sysroot(&self) -> Option { + unsafe { + let mut value = Value::from_type(::static_type()); + gobject_sys::g_object_get_property(self.as_ptr() as *mut gobject_sys::GObject, b"sysroot\0".as_ptr() as *const _, value.to_glib_none_mut().0); + value.get() + } + } + pub fn check_timestamps(repo: &Repo, from_rev: &str, to_rev: &str) -> Result<(), Error> { unsafe { let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_upgrader_check_timestamps(repo.to_glib_none().0, from_rev.to_glib_none().0, to_rev.to_glib_none().0, &mut error); + let _ = ostree_sys::ostree_sysroot_upgrader_check_timestamps(repo.to_glib_none().0, from_rev.to_glib_none().0, to_rev.to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } -pub trait SysrootUpgraderExt { - fn deploy<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error>; - - fn dup_origin(&self) -> Option; - - fn get_origin(&self) -> Option; - - fn get_origin_description(&self) -> Option; - - fn pull<'a, 'b, P: Into>, Q: Into>>(&self, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: P, cancellable: Q) -> Result; - - fn pull_one_dir<'a, 'b, P: Into>, Q: Into>>(&self, dir_to_pull: &str, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: P, cancellable: Q) -> Result; - - fn set_origin<'a, 'b, P: Into>, Q: Into>>(&self, origin: P, cancellable: Q) -> Result<(), Error>; - - fn get_property_flags(&self) -> SysrootUpgraderFlags; - - fn get_property_osname(&self) -> Option; - - fn get_property_sysroot(&self) -> Option; -} - -impl + IsA> SysrootUpgraderExt for O { - fn deploy<'a, P: Into>>(&self, cancellable: P) -> Result<(), Error> { - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_upgrader_deploy(self.to_glib_none().0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn dup_origin(&self) -> Option { - unsafe { - from_glib_full(ffi::ostree_sysroot_upgrader_dup_origin(self.to_glib_none().0)) - } - } - - fn get_origin(&self) -> Option { - unsafe { - from_glib_none(ffi::ostree_sysroot_upgrader_get_origin(self.to_glib_none().0)) - } - } - - fn get_origin_description(&self) -> Option { - unsafe { - from_glib_full(ffi::ostree_sysroot_upgrader_get_origin_description(self.to_glib_none().0)) - } - } - - fn pull<'a, 'b, P: Into>, Q: Into>>(&self, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: P, cancellable: Q) -> Result { - let progress = progress.into(); - let progress = progress.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_changed = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_upgrader_pull(self.to_glib_none().0, flags.to_glib(), upgrader_flags.to_glib(), progress.0, &mut out_changed, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) } - } - } - - fn pull_one_dir<'a, 'b, P: Into>, Q: Into>>(&self, dir_to_pull: &str, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: P, cancellable: Q) -> Result { - let progress = progress.into(); - let progress = progress.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut out_changed = mem::uninitialized(); - let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_upgrader_pull_one_dir(self.to_glib_none().0, dir_to_pull.to_glib_none().0, flags.to_glib(), upgrader_flags.to_glib(), progress.0, &mut out_changed, cancellable.0, &mut error); - if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) } - } - } - - fn set_origin<'a, 'b, P: Into>, Q: Into>>(&self, origin: P, cancellable: Q) -> Result<(), Error> { - let origin = origin.into(); - let origin = origin.to_glib_none(); - let cancellable = cancellable.into(); - let cancellable = cancellable.to_glib_none(); - unsafe { - let mut error = ptr::null_mut(); - let _ = ffi::ostree_sysroot_upgrader_set_origin(self.to_glib_none().0, origin.0, cancellable.0, &mut error); - if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } - } - } - - fn get_property_flags(&self) -> SysrootUpgraderFlags { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "flags".to_glib_none().0, value.to_glib_none_mut().0); - value.get().unwrap() - } - } - - fn get_property_osname(&self) -> Option { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "osname".to_glib_none().0, value.to_glib_none_mut().0); - value.get() - } - } - - fn get_property_sysroot(&self) -> Option { - unsafe { - let mut value = Value::from_type(::static_type()); - gobject_ffi::g_object_get_property(self.to_glib_none().0, "sysroot".to_glib_none().0, value.to_glib_none_mut().0); - value.get() - } +impl fmt::Display for SysrootUpgrader { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "SysrootUpgrader") } } diff --git a/rust-bindings/rust/src/auto/versions.txt b/rust-bindings/rust/src/auto/versions.txt index 1e3acbd1..be52760a 100644 --- a/rust-bindings/rust/src/auto/versions.txt +++ b/rust-bindings/rust/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ffda6f9) +Generated by gir (https://github.com/gtk-rs/gir @ fec179c) from gir-files (https://github.com/gtk-rs/gir-files @ ???) diff --git a/rust-bindings/rust/src/collection_ref/mod.rs b/rust-bindings/rust/src/collection_ref/mod.rs index dd93cb4f..35ea396b 100644 --- a/rust-bindings/rust/src/collection_ref/mod.rs +++ b/rust-bindings/rust/src/collection_ref/mod.rs @@ -1,31 +1,30 @@ // Based on a file generated by gir. Changes are marked below. -use ffi; +#[cfg(any(feature = "v2018_6", feature = "dox"))] use glib::translate::*; -use glib_ffi; -use gobject_ffi; +use glib_sys; +use gobject_sys; +use ostree_sys; use std::hash; -use std::mem; -use std::ptr; glib_wrapper! { #[derive(Debug, PartialOrd, Ord)] - pub struct CollectionRef(Boxed); + pub struct CollectionRef(Boxed); match fn { - copy => |ptr| gobject_ffi::g_boxed_copy(ffi::ostree_collection_ref_get_type(), ptr as *mut _) as *mut ffi::OstreeCollectionRef, - free => |ptr| gobject_ffi::g_boxed_free(ffi::ostree_collection_ref_get_type(), ptr as *mut _), - get_type => || ffi::ostree_collection_ref_get_type(), + copy => |ptr| gobject_sys::g_boxed_copy(ostree_sys::ostree_collection_ref_get_type(), ptr as *mut _) as *mut ostree_sys::OstreeCollectionRef, + free => |ptr| gobject_sys::g_boxed_free(ostree_sys::ostree_collection_ref_get_type(), ptr as *mut _), + get_type => || ostree_sys::ostree_collection_ref_get_type(), } } impl CollectionRef { #[cfg(any(feature = "v2018_6", feature = "dox"))] - // CHANGE: return type CollectionRef to Option - pub fn new<'a, P: Into>>(collection_id: P, ref_name: &str) -> Option { - let collection_id = collection_id.into(); - let collection_id = collection_id.to_glib_none(); + pub fn new(collection_id: Option<&str>, ref_name: &str) -> Option { unsafe { - from_glib_full(ffi::ostree_collection_ref_new(collection_id.0, ref_name.to_glib_none().0)) + from_glib_full(ostree_sys::ostree_collection_ref_new( + collection_id.to_glib_none().0, + ref_name.to_glib_none().0, + )) } } @@ -33,7 +32,12 @@ impl CollectionRef { fn equal(&self, ref2: &CollectionRef) -> bool { unsafe { // CHANGE: both instances of *mut to *const - from_glib(ffi::ostree_collection_ref_equal(ToGlibPtr::<*const ffi::OstreeCollectionRef>::to_glib_none(self).0 as glib_ffi::gconstpointer, ToGlibPtr::<*const ffi::OstreeCollectionRef>::to_glib_none(ref2).0 as glib_ffi::gconstpointer)) + from_glib(ostree_sys::ostree_collection_ref_equal( + ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(self).0 + as glib_sys::gconstpointer, + ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(ref2).0 + as glib_sys::gconstpointer, + )) } } @@ -41,7 +45,10 @@ impl CollectionRef { fn hash(&self) -> u32 { unsafe { // CHANGE: *mut to *const - ffi::ostree_collection_ref_hash(ToGlibPtr::<*const ffi::OstreeCollectionRef>::to_glib_none(self).0 as glib_ffi::gconstpointer) + ostree_sys::ostree_collection_ref_hash( + ToGlibPtr::<*const ostree_sys::OstreeCollectionRef>::to_glib_none(self).0 + as glib_sys::gconstpointer, + ) } } } @@ -57,7 +64,10 @@ impl Eq for CollectionRef {} impl hash::Hash for CollectionRef { #[inline] - fn hash(&self, state: &mut H) where H: hash::Hasher { + fn hash(&self, state: &mut H) + where + H: hash::Hasher, + { hash::Hash::hash(&self.hash(), state) } } diff --git a/rust-bindings/rust/src/collection_ref/tests.rs b/rust-bindings/rust/src/collection_ref/tests.rs index ac0a9e08..5dc72deb 100644 --- a/rust-bindings/rust/src/collection_ref/tests.rs +++ b/rust-bindings/rust/src/collection_ref/tests.rs @@ -1,6 +1,6 @@ use super::*; -use std::hash::{Hash, Hasher}; use std::collections::hash_map::DefaultHasher; +use std::hash::{Hash, Hasher}; fn hash(v: &impl Hash) -> u64 { let mut s = DefaultHasher::new(); @@ -10,14 +10,14 @@ fn hash(v: &impl Hash) -> u64 { #[test] fn same_value_should_be_equal() { - let r = CollectionRef::new("io.gitlab.fkrull", "ref").unwrap(); + let r = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); assert_eq!(r, r); } #[test] fn equal_values_should_be_equal() { - let a = CollectionRef::new("io.gitlab.fkrull", "ref").unwrap(); - let b = CollectionRef::new("io.gitlab.fkrull", "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); assert_eq!(a, b); } @@ -30,48 +30,48 @@ fn equal_values_without_collection_id_should_be_equal() { #[test] fn different_values_should_not_be_equal() { - let a = CollectionRef::new("io.gitlab.fkrull", "ref1").unwrap(); - let b = CollectionRef::new("io.gitlab.fkrull", "ref2").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1").unwrap(); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2").unwrap(); assert_ne!(a, b); } #[test] fn new_with_invalid_collection_id_should_return_none() { - let r = CollectionRef::new(".abc", "ref"); + let r = CollectionRef::new(Some(".abc"), "ref"); assert_eq!(r, None); } #[test] fn hash_for_equal_values_should_be_equal() { - let a = CollectionRef::new("io.gitlab.fkrull", "ref").unwrap(); - let b = CollectionRef::new("io.gitlab.fkrull", "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); assert_eq!(hash(&a), hash(&b)); } #[test] fn hash_for_values_with_different_collection_id_should_be_different() { - let a = CollectionRef::new("io.gitlab.fkrull1", "ref").unwrap(); - let b = CollectionRef::new("io.gitlab.fkrull2", "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref").unwrap(); + let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref").unwrap(); assert_ne!(hash(&a), hash(&b)); } #[test] fn hash_for_values_with_different_ref_id_should_be_different() { - let a = CollectionRef::new("io.gitlab.fkrull", "ref-1").unwrap(); - let b = CollectionRef::new("io.gitlab.fkrull", "ref-2").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1").unwrap(); + let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2").unwrap(); assert_ne!(hash(&a), hash(&b)); } #[test] fn hash_should_be_different_if_collection_id_is_absent() { - let a = CollectionRef::new("io.gitlab.fkrull", "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); let b = CollectionRef::new(None, "ref").unwrap(); assert_ne!(hash(&a), hash(&b)); } #[test] fn clone_should_be_equal_to_original_value() { - let a = CollectionRef::new("io.gitlab.fkrull", "ref").unwrap(); + let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap(); let b = a.clone(); assert_eq!(a, b); } diff --git a/rust-bindings/rust/src/lib.rs b/rust-bindings/rust/src/lib.rs index 2e6e77bb..6344ed15 100644 --- a/rust-bindings/rust/src/lib.rs +++ b/rust-bindings/rust/src/lib.rs @@ -1,7 +1,7 @@ -extern crate gio_sys as gio_ffi; -extern crate glib_sys as glib_ffi; -extern crate gobject_sys as gobject_ffi; -extern crate ostree_sys as ffi; +extern crate gio_sys; +extern crate glib_sys; +extern crate gobject_sys; +extern crate ostree_sys; #[macro_use] extern crate glib; extern crate gio; diff --git a/rust-bindings/rust/src/object_name.rs b/rust-bindings/rust/src/object_name.rs index abff8c08..25635ec7 100644 --- a/rust-bindings/rust/src/object_name.rs +++ b/rust-bindings/rust/src/object_name.rs @@ -1,8 +1,8 @@ -use ffi; use functions::{object_name_deserialize, object_name_serialize, object_to_string}; use glib; use glib::translate::*; -use glib_ffi; +use glib_sys; +use ostree_sys; use std::fmt::Display; use std::fmt::Error; use std::fmt::Formatter; @@ -11,12 +11,13 @@ use std::hash::Hasher; use ObjectType; fn hash_object_name(v: &glib::Variant) -> u32 { - unsafe { ffi::ostree_hash_object_name(v.to_glib_none().0 as glib_ffi::gconstpointer) } + unsafe { ostree_sys::ostree_hash_object_name(v.to_glib_none().0 as glib_sys::gconstpointer) } } #[derive(Eq, Debug)] pub struct ObjectName { variant: glib::Variant, + // TODO: can I store a GString here? checksum: String, object_type: ObjectType, } @@ -26,7 +27,7 @@ impl ObjectName { let deserialize = object_name_deserialize(&variant); ObjectName { variant, - checksum: deserialize.0, + checksum: deserialize.0.into(), object_type: deserialize.1, } } @@ -49,9 +50,11 @@ impl ObjectName { self.object_type } + // TODO: return GString pub fn name(&self) -> String { object_to_string(self.checksum(), self.object_type()) .expect("type checks should make this safe") + .into() } } diff --git a/rust-bindings/rust/src/repo/mod.rs b/rust-bindings/rust/src/repo/mod.rs index 1245496c..220372e3 100644 --- a/rust-bindings/rust/src/repo/mod.rs +++ b/rust-bindings/rust/src/repo/mod.rs @@ -1,84 +1,85 @@ -use crate::auto::Repo; +use crate::Repo; #[cfg(any(feature = "v2016_4", feature = "dox"))] -use crate::auto::RepoListRefsExtFlags; -use ffi; +use crate::RepoListRefsExtFlags; use gio; use glib; use glib::translate::*; use glib::Error; use glib::IsA; -use glib_ffi; +use glib_sys; +use ostree_sys; use std::collections::{HashMap, HashSet}; use std::path::Path; use std::ptr; use ObjectName; unsafe extern "C" fn read_variant_table( - _key: glib_ffi::gpointer, - value: glib_ffi::gpointer, - hash_set: glib_ffi::gpointer, + _key: glib_sys::gpointer, + value: glib_sys::gpointer, + hash_set: glib_sys::gpointer, ) { - let value: glib::Variant = from_glib_none(value as *const glib_ffi::GVariant); + let value: glib::Variant = from_glib_none(value as *const glib_sys::GVariant); let set: &mut HashSet = &mut *(hash_set as *mut HashSet); set.insert(ObjectName::new_from_variant(value)); } -unsafe fn from_glib_container_variant_set(ptr: *mut glib_ffi::GHashTable) -> HashSet { +unsafe fn from_glib_container_variant_set(ptr: *mut glib_sys::GHashTable) -> HashSet { let mut set = HashSet::new(); - glib_ffi::g_hash_table_foreach( + glib_sys::g_hash_table_foreach( ptr, Some(read_variant_table), &mut set as *mut HashSet as *mut _, ); - glib_ffi::g_hash_table_unref(ptr); + glib_sys::g_hash_table_unref(ptr); set } pub trait RepoExtManual { fn new_for_path>(path: P) -> Repo; - fn traverse_commit<'a, P: Into>>( + fn traverse_commit>( &self, commit_checksum: &str, maxdepth: i32, - cancellable: P, + cancellable: Option<&P>, ) -> Result, Error>; - fn list_refs<'a, 'b, P: Into>, Q: Into>>( + // TODO: return GString? + fn list_refs>( &self, - refspec_prefix: P, - cancellable: Q, + refspec_prefix: Option<&str>, + cancellable: Option<&P>, ) -> Result, Error>; #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn list_refs_ext<'a, 'b, P: Into>, Q: Into>>( + fn list_refs_ext>( &self, - refspec_prefix: P, + refspec_prefix: Option<&str>, flags: RepoListRefsExtFlags, - cancellable: Q, + cancellable: Option<&P>, ) -> Result, Error>; } -impl + IsA + Clone + 'static> RepoExtManual for O { +impl> RepoExtManual for O { fn new_for_path>(path: P) -> Repo { Repo::new(&gio::File::new_for_path(path.as_ref())) } - fn traverse_commit<'a, P: Into>>( + fn traverse_commit>( &self, commit_checksum: &str, maxdepth: i32, - cancellable: P, + cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let mut hashtable = ptr::null_mut(); - let _ = ffi::ostree_repo_traverse_commit( - self.to_glib_none().0, + let _ = ostree_sys::ostree_repo_traverse_commit( + self.as_ref().to_glib_none().0, commit_checksum.to_glib_none().0, maxdepth, &mut hashtable, - cancellable.into().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { @@ -89,19 +90,19 @@ impl + IsA + Clone + 'static> RepoExtManual for O { } } - fn list_refs<'a, 'b, P: Into>, Q: Into>>( + fn list_refs>( &self, - refspec_prefix: P, - cancellable: Q, + refspec_prefix: Option<&str>, + cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let mut hashtable = ptr::null_mut(); - let _ = ffi::ostree_repo_list_refs( - self.to_glib_none().0, - refspec_prefix.into().to_glib_none().0, + let _ = ostree_sys::ostree_repo_list_refs( + self.as_ref().to_glib_none().0, + refspec_prefix.to_glib_none().0, &mut hashtable, - cancellable.into().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); @@ -114,21 +115,21 @@ impl + IsA + Clone + 'static> RepoExtManual for O { } #[cfg(any(feature = "v2016_4", feature = "dox"))] - fn list_refs_ext<'a, 'b, P: Into>, Q: Into>>( + fn list_refs_ext>( &self, - refspec_prefix: P, + refspec_prefix: Option<&str>, flags: RepoListRefsExtFlags, - cancellable: Q, + cancellable: Option<&P>, ) -> Result, Error> { unsafe { let mut error = ptr::null_mut(); let mut hashtable = ptr::null_mut(); - let _ = ffi::ostree_repo_list_refs_ext( - self.to_glib_none().0, - refspec_prefix.into().to_glib_none().0, + let _ = ostree_sys::ostree_repo_list_refs_ext( + self.as_ref().to_glib_none().0, + refspec_prefix.to_glib_none().0, &mut hashtable, flags.to_glib(), - cancellable.into().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); diff --git a/rust-bindings/rust/tests/roundtrip.rs b/rust-bindings/rust/tests/roundtrip.rs index 1093a3f1..6e273b99 100644 --- a/rust-bindings/rust/tests/roundtrip.rs +++ b/rust-bindings/rust/tests/roundtrip.rs @@ -3,15 +3,17 @@ extern crate glib; extern crate ostree; extern crate tempfile; +use gio::NONE_CANCELLABLE; use glib::prelude::*; use ostree::prelude::*; +use ostree::RepoFile; use std::fs; use std::io; use std::io::Write; fn create_repo(repodir: &tempfile::TempDir) -> Result { let repo = ostree::Repo::new_for_path(repodir.path()); - repo.create(ostree::RepoMode::Archive, None)?; + repo.create(ostree::RepoMode::Archive, NONE_CANCELLABLE)?; Ok(repo) } @@ -27,25 +29,34 @@ fn create_mtree( ) -> Result { let gfile = gio::File::new_for_path(treedir.path()); let mtree = ostree::MutableTree::new(); - repo.write_directory_to_mtree(&gfile, &mtree, None, None)?; + repo.write_directory_to_mtree(&gfile, &mtree, None, NONE_CANCELLABLE)?; Ok(mtree) } -fn commit_mtree( - repo: &ostree::Repo, - mtree: &ostree::MutableTree, -) -> Result { - repo.prepare_transaction(None)?; - let repo_file = repo.write_mtree(mtree, None)?.downcast().unwrap(); - let checksum = repo.write_commit(None, "Test Commit", None, None, &repo_file, None)?; - repo.transaction_set_ref(None, "test", checksum.as_str()); - repo.commit_transaction(None)?; +fn commit_mtree(repo: &ostree::Repo, mtree: &ostree::MutableTree) -> Result { + repo.prepare_transaction(NONE_CANCELLABLE)?; + let repo_file = repo + .write_mtree(mtree, NONE_CANCELLABLE)? + .downcast::() + .unwrap(); + let checksum = repo + .write_commit( + None, + "Test Commit".into(), + None, + None, + &repo_file, + NONE_CANCELLABLE, + )? + .to_string(); + repo.transaction_set_ref(None, "test", checksum.as_str().into()); + repo.commit_transaction(NONE_CANCELLABLE)?; Ok(checksum) } fn open_repo(repodir: &tempfile::TempDir) -> Result { let repo = ostree::Repo::new_for_path(repodir.path()); - repo.open(None)?; + repo.open(NONE_CANCELLABLE)?; Ok(repo) } @@ -60,7 +71,9 @@ fn should_commit_content_to_repo_and_list_refs_again() { let checksum = commit_mtree(&repo, &mtree).expect("failed to commit mtree"); let repo = open_repo(&repodir).expect("failed to open repo"); - let refs = repo.list_refs(None, None).expect("failed to list refs"); + let refs = repo + .list_refs(None, NONE_CANCELLABLE) + .expect("failed to list refs"); assert_eq!(refs.len(), 1); assert_eq!(refs["test"], checksum); }