ostree/cargo: bump to ostree-sys 0.9.2

This commit is contained in:
Luca BRUNO authored and Colin Walters committed 2022-05-06 12:53:57 -04:00
1 parent 61b4629b37
commit 3fc55a524b
91 files changed
+2 -1

No files matched your search

+1
View File
@@ -0,0 +1 @@
auto/** linguist-generated=true
+157
View File
@@ -0,0 +1,157 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
glib::wrapper! {
#[doc(alias = "OstreeAsyncProgress")]
pub struct AsyncProgress(Object<ffi::OstreeAsyncProgress, ffi::OstreeAsyncProgressClass>);
match fn {
type_ => || ffi::ostree_async_progress_get_type(),
}
}
impl AsyncProgress {
#[doc(alias = "ostree_async_progress_new")]
pub fn new() -> AsyncProgress {
unsafe {
from_glib_full(ffi::ostree_async_progress_new())
}
}
//#[doc(alias = "ostree_async_progress_new_and_connect")]
//pub fn new_and_connect(changed: /*Unimplemented*/Option<Fundamental: Pointer>, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> AsyncProgress {
// unsafe { TODO: call ffi:ostree_async_progress_new_and_connect() }
//}
#[cfg(any(feature = "v2019_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2019_6")))]
#[doc(alias = "ostree_async_progress_copy_state")]
pub fn copy_state(&self, dest: &AsyncProgress) {
unsafe {
ffi::ostree_async_progress_copy_state(self.to_glib_none().0, dest.to_glib_none().0);
}
}
#[doc(alias = "ostree_async_progress_finish")]
pub fn finish(&self) {
unsafe {
ffi::ostree_async_progress_finish(self.to_glib_none().0);
}
}
//#[cfg(any(feature = "v2017_6", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
//#[doc(alias = "ostree_async_progress_get")]
//pub fn get(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi:ostree_async_progress_get() }
//}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_get_status")]
#[doc(alias = "get_status")]
pub fn status(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_async_progress_get_status(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_async_progress_get_uint")]
#[doc(alias = "get_uint")]
pub fn uint(&self, key: &str) -> u32 {
unsafe {
ffi::ostree_async_progress_get_uint(self.to_glib_none().0, key.to_glib_none().0)
}
}
#[doc(alias = "ostree_async_progress_get_uint64")]
#[doc(alias = "get_uint64")]
pub fn uint64(&self, key: &str) -> u64 {
unsafe {
ffi::ostree_async_progress_get_uint64(self.to_glib_none().0, key.to_glib_none().0)
}
}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_get_variant")]
#[doc(alias = "get_variant")]
pub fn variant(&self, key: &str) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_async_progress_get_variant(self.to_glib_none().0, key.to_glib_none().0))
}
}
//#[cfg(any(feature = "v2017_6", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
//#[doc(alias = "ostree_async_progress_set")]
//pub fn set(&self, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) {
// unsafe { TODO: call ffi:ostree_async_progress_set() }
//}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_set_status")]
pub fn set_status(&self, status: Option<&str>) {
unsafe {
ffi::ostree_async_progress_set_status(self.to_glib_none().0, status.to_glib_none().0);
}
}
#[doc(alias = "ostree_async_progress_set_uint")]
pub 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);
}
}
#[doc(alias = "ostree_async_progress_set_uint64")]
pub 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);
}
}
#[cfg(any(feature = "v2017_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_6")))]
#[doc(alias = "ostree_async_progress_set_variant")]
pub 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);
}
}
#[doc(alias = "changed")]
pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn changed_trampoline<F: Fn(&AsyncProgress) + 'static>(this: *mut ffi::OstreeAsyncProgress, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(changed_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
impl Default for AsyncProgress {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for AsyncProgress {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("AsyncProgress")
}
}
+114
View File
@@ -0,0 +1,114 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeBootconfigParser")]
pub struct BootconfigParser(Object<ffi::OstreeBootconfigParser>);
match fn {
type_ => || ffi::ostree_bootconfig_parser_get_type(),
}
}
impl BootconfigParser {
#[doc(alias = "ostree_bootconfig_parser_new")]
pub fn new() -> BootconfigParser {
unsafe {
from_glib_full(ffi::ostree_bootconfig_parser_new())
}
}
#[doc(alias = "ostree_bootconfig_parser_clone")]
pub fn clone(&self) -> Option<BootconfigParser> {
unsafe {
from_glib_full(ffi::ostree_bootconfig_parser_clone(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_bootconfig_parser_get")]
pub fn get(&self, key: &str) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_bootconfig_parser_get(self.to_glib_none().0, key.to_glib_none().0))
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_bootconfig_parser_get_overlay_initrds")]
#[doc(alias = "get_overlay_initrds")]
pub fn overlay_initrds(&self) -> Vec<glib::GString> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::ostree_bootconfig_parser_get_overlay_initrds(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_bootconfig_parser_parse")]
pub fn parse<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, path: &P, cancellable: Option<&Q>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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)) }
}
}
#[doc(alias = "ostree_bootconfig_parser_parse_at")]
pub fn parse_at<P: IsA<gio::Cancellable>>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
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.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_bootconfig_parser_set")]
pub 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);
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_bootconfig_parser_set_overlay_initrds")]
pub fn set_overlay_initrds(&self, initrds: &[&str]) {
unsafe {
ffi::ostree_bootconfig_parser_set_overlay_initrds(self.to_glib_none().0, initrds.to_glib_none().0);
}
}
#[doc(alias = "ostree_bootconfig_parser_write")]
pub fn write<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, output: &P, cancellable: Option<&Q>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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)) }
}
}
#[doc(alias = "ostree_bootconfig_parser_write_at")]
pub fn write_at<P: IsA<gio::Cancellable>>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
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.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}
impl Default for BootconfigParser {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for BootconfigParser {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("BootconfigParser")
}
}
+56
View File
@@ -0,0 +1,56 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
use std::hash;
glib::wrapper! {
#[derive(Debug, PartialOrd, Ord)]
pub struct CollectionRef(Boxed<ffi::OstreeCollectionRef>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::ostree_collection_ref_get_type(), ptr as *mut _) as *mut ffi::OstreeCollectionRef,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::ostree_collection_ref_get_type(), ptr as *mut _),
type_ => || ffi::ostree_collection_ref_get_type(),
}
}
impl CollectionRef {
#[doc(alias = "ostree_collection_ref_new")]
pub fn new(collection_id: Option<&str>, ref_name: &str) -> Option<CollectionRef> {
unsafe {
from_glib_full(ffi::ostree_collection_ref_new(collection_id.to_glib_none().0, ref_name.to_glib_none().0))
}
}
#[doc(alias = "ostree_collection_ref_equal")]
fn equal(&self, ref2: &CollectionRef) -> bool {
unsafe {
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))
}
}
#[doc(alias = "ostree_collection_ref_hash")]
fn hash(&self) -> u32 {
unsafe {
ffi::ostree_collection_ref_hash(ToGlibPtr::<*const ffi::OstreeCollectionRef>::to_glib_none(self).0 as glib::ffi::gconstpointer)
}
}
}
impl PartialEq for CollectionRef {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for CollectionRef {}
impl hash::Hash for CollectionRef {
#[inline]
fn hash<H>(&self, state: &mut H) where H: hash::Hasher {
hash::Hash::hash(&self.hash(), state)
}
}
+26
View File
@@ -0,0 +1,26 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::ObjectType;
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CommitSizesEntry(Boxed<ffi::OstreeCommitSizesEntry>);
match fn {
copy => |ptr| ffi::ostree_commit_sizes_entry_copy(ptr),
free => |ptr| ffi::ostree_commit_sizes_entry_free(ptr),
type_ => || ffi::ostree_commit_sizes_entry_get_type(),
}
}
impl CommitSizesEntry {
#[doc(alias = "ostree_commit_sizes_entry_new")]
pub fn new(checksum: &str, objtype: ObjectType, unpacked: u64, archived: u64) -> Option<CommitSizesEntry> {
unsafe {
from_glib_full(ffi::ostree_commit_sizes_entry_new(checksum.to_glib_none().0, objtype.into_glib(), unpacked, archived))
}
}
}
+72
View File
@@ -0,0 +1,72 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use std::ffi::CStr;
#[doc(alias = "OSTREE_COMMIT_GVARIANT_STRING")]
pub static COMMIT_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_GVARIANT_STRING).to_str().unwrap()});
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_ARCHITECTURE")]
pub static COMMIT_META_KEY_ARCHITECTURE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ARCHITECTURE).to_str().unwrap()});
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_COLLECTION_BINDING")]
pub static COMMIT_META_KEY_COLLECTION_BINDING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_COLLECTION_BINDING).to_str().unwrap()});
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_ENDOFLIFE")]
pub static COMMIT_META_KEY_ENDOFLIFE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ENDOFLIFE).to_str().unwrap()});
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE")]
pub static COMMIT_META_KEY_ENDOFLIFE_REBASE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_ENDOFLIFE_REBASE).to_str().unwrap()});
#[cfg(any(feature = "v2017_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_9")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_REF_BINDING")]
pub static COMMIT_META_KEY_REF_BINDING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_REF_BINDING).to_str().unwrap()});
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_SOURCE_TITLE")]
pub static COMMIT_META_KEY_SOURCE_TITLE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_SOURCE_TITLE).to_str().unwrap()});
#[cfg(any(feature = "v2014_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2014_9")))]
#[doc(alias = "OSTREE_COMMIT_META_KEY_VERSION")]
pub static COMMIT_META_KEY_VERSION: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_COMMIT_META_KEY_VERSION).to_str().unwrap()});
#[doc(alias = "OSTREE_DIRMETA_GVARIANT_STRING")]
pub static DIRMETA_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_DIRMETA_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_FILEMETA_GVARIANT_STRING")]
pub static FILEMETA_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_FILEMETA_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_GPG_KEY_GVARIANT_STRING")]
pub static GPG_KEY_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_GPG_KEY_GVARIANT_STRING).to_str().unwrap()});
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
#[doc(alias = "OSTREE_METADATA_KEY_BOOTABLE")]
pub static METADATA_KEY_BOOTABLE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_METADATA_KEY_BOOTABLE).to_str().unwrap()});
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
#[doc(alias = "OSTREE_METADATA_KEY_LINUX")]
pub static METADATA_KEY_LINUX: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_METADATA_KEY_LINUX).to_str().unwrap()});
#[cfg(any(feature = "v2018_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_9")))]
#[doc(alias = "OSTREE_META_KEY_DEPLOY_COLLECTION_ID")]
pub static META_KEY_DEPLOY_COLLECTION_ID: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_META_KEY_DEPLOY_COLLECTION_ID).to_str().unwrap()});
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "OSTREE_ORIGIN_TRANSIENT_GROUP")]
pub static ORIGIN_TRANSIENT_GROUP: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_ORIGIN_TRANSIENT_GROUP).to_str().unwrap()});
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
#[doc(alias = "OSTREE_REPO_METADATA_REF")]
pub static REPO_METADATA_REF: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_REPO_METADATA_REF).to_str().unwrap()});
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
#[doc(alias = "OSTREE_SIGN_NAME_ED25519")]
pub static SIGN_NAME_ED25519: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_SIGN_NAME_ED25519).to_str().unwrap()});
#[doc(alias = "OSTREE_SUMMARY_GVARIANT_STRING")]
pub static SUMMARY_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_SUMMARY_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_SUMMARY_SIG_GVARIANT_STRING")]
pub static SUMMARY_SIG_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_SUMMARY_SIG_GVARIANT_STRING).to_str().unwrap()});
#[doc(alias = "OSTREE_TREE_GVARIANT_STRING")]
pub static TREE_GVARIANT_STRING: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe{CStr::from_ptr(ffi::OSTREE_TREE_GVARIANT_STRING).to_str().unwrap()});
+34
View File
@@ -0,0 +1,34 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeContentWriter")]
pub struct ContentWriter(Object<ffi::OstreeContentWriter, ffi::OstreeContentWriterClass>) @extends gio::OutputStream;
match fn {
type_ => || ffi::ostree_content_writer_get_type(),
}
}
impl ContentWriter {
#[doc(alias = "ostree_content_writer_finish")]
pub fn finish<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<glib::GString, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_content_writer_finish(self.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)) }
}
}
}
impl fmt::Display for ContentWriter {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("ContentWriter")
}
}
+201
View File
@@ -0,0 +1,201 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::BootconfigParser;
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
use crate::DeploymentUnlockedState;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeDeployment")]
pub struct Deployment(Object<ffi::OstreeDeployment>);
match fn {
type_ => || ffi::ostree_deployment_get_type(),
}
}
impl Deployment {
#[doc(alias = "ostree_deployment_new")]
pub fn new(index: i32, osname: &str, csum: &str, deployserial: i32, bootcsum: Option<&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))
}
}
#[doc(alias = "ostree_deployment_clone")]
pub fn clone(&self) -> Option<Deployment> {
unsafe {
from_glib_full(ffi::ostree_deployment_clone(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_equal")]
pub 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))
}
}
#[doc(alias = "ostree_deployment_get_bootconfig")]
#[doc(alias = "get_bootconfig")]
pub fn bootconfig(&self) -> Option<BootconfigParser> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_bootconfig(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_bootcsum")]
#[doc(alias = "get_bootcsum")]
pub fn bootcsum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_bootcsum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_bootserial")]
#[doc(alias = "get_bootserial")]
pub fn bootserial(&self) -> i32 {
unsafe {
ffi::ostree_deployment_get_bootserial(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_deployment_get_csum")]
#[doc(alias = "get_csum")]
pub fn csum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_csum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_deployserial")]
#[doc(alias = "get_deployserial")]
pub fn deployserial(&self) -> i32 {
unsafe {
ffi::ostree_deployment_get_deployserial(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_deployment_get_index")]
#[doc(alias = "get_index")]
pub fn index(&self) -> i32 {
unsafe {
ffi::ostree_deployment_get_index(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_deployment_get_origin")]
#[doc(alias = "get_origin")]
pub fn origin(&self) -> Option<glib::KeyFile> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_origin(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_origin_relpath")]
#[doc(alias = "get_origin_relpath")]
pub fn origin_relpath(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_deployment_get_origin_relpath(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_get_osname")]
#[doc(alias = "get_osname")]
pub fn osname(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_get_osname(self.to_glib_none().0))
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_deployment_get_unlocked")]
#[doc(alias = "get_unlocked")]
pub fn unlocked(&self) -> DeploymentUnlockedState {
unsafe {
from_glib(ffi::ostree_deployment_get_unlocked(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_hash")]
pub fn hash(&self) -> u32 {
unsafe {
ffi::ostree_deployment_hash(ToGlibPtr::<*mut ffi::OstreeDeployment>::to_glib_none(self).0 as glib::ffi::gconstpointer)
}
}
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_deployment_is_pinned")]
pub 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"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_deployment_is_staged")]
pub fn is_staged(&self) -> bool {
unsafe {
from_glib(ffi::ostree_deployment_is_staged(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_deployment_set_bootconfig")]
pub fn set_bootconfig(&self, bootconfig: Option<&BootconfigParser>) {
unsafe {
ffi::ostree_deployment_set_bootconfig(self.to_glib_none().0, bootconfig.to_glib_none().0);
}
}
#[doc(alias = "ostree_deployment_set_bootserial")]
pub fn set_bootserial(&self, index: i32) {
unsafe {
ffi::ostree_deployment_set_bootserial(self.to_glib_none().0, index);
}
}
#[doc(alias = "ostree_deployment_set_index")]
pub fn set_index(&self, index: i32) {
unsafe {
ffi::ostree_deployment_set_index(self.to_glib_none().0, index);
}
}
#[doc(alias = "ostree_deployment_set_origin")]
pub fn set_origin(&self, origin: Option<&glib::KeyFile>) {
unsafe {
ffi::ostree_deployment_set_origin(self.to_glib_none().0, origin.to_glib_none().0);
}
}
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_deployment_origin_remove_transient_state")]
pub fn origin_remove_transient_state(origin: &glib::KeyFile) {
unsafe {
ffi::ostree_deployment_origin_remove_transient_state(origin.to_glib_none().0);
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_deployment_unlocked_state_to_string")]
pub fn unlocked_state_to_string(state: DeploymentUnlockedState) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_deployment_unlocked_state_to_string(state.into_glib()))
}
}
}
impl fmt::Display for Deployment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Deployment")
}
}
+15
View File
@@ -0,0 +1,15 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct DiffItem(Shared<ffi::OstreeDiffItem>);
match fn {
ref => |ptr| ffi::ostree_diff_item_ref(ptr),
unref => |ptr| ffi::ostree_diff_item_unref(ptr),
type_ => || ffi::ostree_diff_item_get_type(),
}
}
+677
View File
@@ -0,0 +1,677 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
use std::fmt;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeDeploymentUnlockedState")]
pub enum DeploymentUnlockedState {
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_NONE")]
None,
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT")]
Development,
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX")]
Hotfix,
#[doc(alias = "OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT")]
Transient,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for DeploymentUnlockedState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "DeploymentUnlockedState::{}", match *self {
Self::None => "None",
Self::Development => "Development",
Self::Hotfix => "Hotfix",
Self::Transient => "Transient",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for DeploymentUnlockedState {
type GlibType = ffi::OstreeDeploymentUnlockedState;
fn into_glib(self) -> ffi::OstreeDeploymentUnlockedState {
match self {
Self::None => ffi::OSTREE_DEPLOYMENT_UNLOCKED_NONE,
Self::Development => ffi::OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT,
Self::Hotfix => ffi::OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX,
Self::Transient => ffi::OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeDeploymentUnlockedState> for DeploymentUnlockedState {
unsafe fn from_glib(value: ffi::OstreeDeploymentUnlockedState) -> Self {
match value {
ffi::OSTREE_DEPLOYMENT_UNLOCKED_NONE => Self::None,
ffi::OSTREE_DEPLOYMENT_UNLOCKED_DEVELOPMENT => Self::Development,
ffi::OSTREE_DEPLOYMENT_UNLOCKED_HOTFIX => Self::Hotfix,
ffi::OSTREE_DEPLOYMENT_UNLOCKED_TRANSIENT => Self::Transient,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeGpgSignatureAttr")]
pub enum GpgSignatureAttr {
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_VALID")]
Valid,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED")]
SigExpired,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED")]
KeyExpired,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED")]
KeyRevoked,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING")]
KeyMissing,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT")]
Fingerprint,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP")]
Timestamp,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP")]
ExpTimestamp,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME")]
PubkeyAlgoName,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME")]
HashAlgoName,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_USER_NAME")]
UserName,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL")]
UserEmail,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY")]
FingerprintPrimary,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP")]
KeyExpTimestamp,
#[doc(alias = "OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY")]
KeyExpTimestampPrimary,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for GpgSignatureAttr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "GpgSignatureAttr::{}", match *self {
Self::Valid => "Valid",
Self::SigExpired => "SigExpired",
Self::KeyExpired => "KeyExpired",
Self::KeyRevoked => "KeyRevoked",
Self::KeyMissing => "KeyMissing",
Self::Fingerprint => "Fingerprint",
Self::Timestamp => "Timestamp",
Self::ExpTimestamp => "ExpTimestamp",
Self::PubkeyAlgoName => "PubkeyAlgoName",
Self::HashAlgoName => "HashAlgoName",
Self::UserName => "UserName",
Self::UserEmail => "UserEmail",
Self::FingerprintPrimary => "FingerprintPrimary",
Self::KeyExpTimestamp => "KeyExpTimestamp",
Self::KeyExpTimestampPrimary => "KeyExpTimestampPrimary",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for GpgSignatureAttr {
type GlibType = ffi::OstreeGpgSignatureAttr;
fn into_glib(self) -> ffi::OstreeGpgSignatureAttr {
match self {
Self::Valid => ffi::OSTREE_GPG_SIGNATURE_ATTR_VALID,
Self::SigExpired => ffi::OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED,
Self::KeyExpired => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED,
Self::KeyRevoked => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED,
Self::KeyMissing => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING,
Self::Fingerprint => ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT,
Self::Timestamp => ffi::OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP,
Self::ExpTimestamp => ffi::OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP,
Self::PubkeyAlgoName => ffi::OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME,
Self::HashAlgoName => ffi::OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME,
Self::UserName => ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_NAME,
Self::UserEmail => ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL,
Self::FingerprintPrimary => ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY,
Self::KeyExpTimestamp => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP,
Self::KeyExpTimestampPrimary => ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeGpgSignatureAttr> for GpgSignatureAttr {
unsafe fn from_glib(value: ffi::OstreeGpgSignatureAttr) -> Self {
match value {
ffi::OSTREE_GPG_SIGNATURE_ATTR_VALID => Self::Valid,
ffi::OSTREE_GPG_SIGNATURE_ATTR_SIG_EXPIRED => Self::SigExpired,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXPIRED => Self::KeyExpired,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_REVOKED => Self::KeyRevoked,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_MISSING => Self::KeyMissing,
ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT => Self::Fingerprint,
ffi::OSTREE_GPG_SIGNATURE_ATTR_TIMESTAMP => Self::Timestamp,
ffi::OSTREE_GPG_SIGNATURE_ATTR_EXP_TIMESTAMP => Self::ExpTimestamp,
ffi::OSTREE_GPG_SIGNATURE_ATTR_PUBKEY_ALGO_NAME => Self::PubkeyAlgoName,
ffi::OSTREE_GPG_SIGNATURE_ATTR_HASH_ALGO_NAME => Self::HashAlgoName,
ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_NAME => Self::UserName,
ffi::OSTREE_GPG_SIGNATURE_ATTR_USER_EMAIL => Self::UserEmail,
ffi::OSTREE_GPG_SIGNATURE_ATTR_FINGERPRINT_PRIMARY => Self::FingerprintPrimary,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP => Self::KeyExpTimestamp,
ffi::OSTREE_GPG_SIGNATURE_ATTR_KEY_EXP_TIMESTAMP_PRIMARY => Self::KeyExpTimestampPrimary,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeObjectType")]
pub enum ObjectType {
#[doc(alias = "OSTREE_OBJECT_TYPE_FILE")]
File,
#[doc(alias = "OSTREE_OBJECT_TYPE_DIR_TREE")]
DirTree,
#[doc(alias = "OSTREE_OBJECT_TYPE_DIR_META")]
DirMeta,
#[doc(alias = "OSTREE_OBJECT_TYPE_COMMIT")]
Commit,
#[doc(alias = "OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT")]
TombstoneCommit,
#[doc(alias = "OSTREE_OBJECT_TYPE_COMMIT_META")]
CommitMeta,
#[doc(alias = "OSTREE_OBJECT_TYPE_PAYLOAD_LINK")]
PayloadLink,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for ObjectType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ObjectType::{}", match *self {
Self::File => "File",
Self::DirTree => "DirTree",
Self::DirMeta => "DirMeta",
Self::Commit => "Commit",
Self::TombstoneCommit => "TombstoneCommit",
Self::CommitMeta => "CommitMeta",
Self::PayloadLink => "PayloadLink",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for ObjectType {
type GlibType = ffi::OstreeObjectType;
fn into_glib(self) -> ffi::OstreeObjectType {
match self {
Self::File => ffi::OSTREE_OBJECT_TYPE_FILE,
Self::DirTree => ffi::OSTREE_OBJECT_TYPE_DIR_TREE,
Self::DirMeta => ffi::OSTREE_OBJECT_TYPE_DIR_META,
Self::Commit => ffi::OSTREE_OBJECT_TYPE_COMMIT,
Self::TombstoneCommit => ffi::OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
Self::CommitMeta => ffi::OSTREE_OBJECT_TYPE_COMMIT_META,
Self::PayloadLink => ffi::OSTREE_OBJECT_TYPE_PAYLOAD_LINK,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeObjectType> for ObjectType {
unsafe fn from_glib(value: ffi::OstreeObjectType) -> Self {
match value {
ffi::OSTREE_OBJECT_TYPE_FILE => Self::File,
ffi::OSTREE_OBJECT_TYPE_DIR_TREE => Self::DirTree,
ffi::OSTREE_OBJECT_TYPE_DIR_META => Self::DirMeta,
ffi::OSTREE_OBJECT_TYPE_COMMIT => Self::Commit,
ffi::OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT => Self::TombstoneCommit,
ffi::OSTREE_OBJECT_TYPE_COMMIT_META => Self::CommitMeta,
ffi::OSTREE_OBJECT_TYPE_PAYLOAD_LINK => Self::PayloadLink,
value => Self::__Unknown(value),
}
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCheckoutFilterResult")]
pub enum RepoCheckoutFilterResult {
#[doc(alias = "OSTREE_REPO_CHECKOUT_FILTER_ALLOW")]
Allow,
#[doc(alias = "OSTREE_REPO_CHECKOUT_FILTER_SKIP")]
Skip,
#[doc(hidden)]
__Unknown(i32),
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
impl fmt::Display for RepoCheckoutFilterResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCheckoutFilterResult::{}", match *self {
Self::Allow => "Allow",
Self::Skip => "Skip",
_ => "Unknown",
})
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[doc(hidden)]
impl IntoGlib for RepoCheckoutFilterResult {
type GlibType = ffi::OstreeRepoCheckoutFilterResult;
fn into_glib(self) -> ffi::OstreeRepoCheckoutFilterResult {
match self {
Self::Allow => ffi::OSTREE_REPO_CHECKOUT_FILTER_ALLOW,
Self::Skip => ffi::OSTREE_REPO_CHECKOUT_FILTER_SKIP,
Self::__Unknown(value) => value,
}
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCheckoutFilterResult> for RepoCheckoutFilterResult {
unsafe fn from_glib(value: ffi::OstreeRepoCheckoutFilterResult) -> Self {
match value {
ffi::OSTREE_REPO_CHECKOUT_FILTER_ALLOW => Self::Allow,
ffi::OSTREE_REPO_CHECKOUT_FILTER_SKIP => Self::Skip,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCheckoutMode")]
pub enum RepoCheckoutMode {
#[doc(alias = "OSTREE_REPO_CHECKOUT_MODE_NONE")]
None,
#[doc(alias = "OSTREE_REPO_CHECKOUT_MODE_USER")]
User,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCheckoutMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCheckoutMode::{}", match *self {
Self::None => "None",
Self::User => "User",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCheckoutMode {
type GlibType = ffi::OstreeRepoCheckoutMode;
fn into_glib(self) -> ffi::OstreeRepoCheckoutMode {
match self {
Self::None => ffi::OSTREE_REPO_CHECKOUT_MODE_NONE,
Self::User => ffi::OSTREE_REPO_CHECKOUT_MODE_USER,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCheckoutMode> for RepoCheckoutMode {
unsafe fn from_glib(value: ffi::OstreeRepoCheckoutMode) -> Self {
match value {
ffi::OSTREE_REPO_CHECKOUT_MODE_NONE => Self::None,
ffi::OSTREE_REPO_CHECKOUT_MODE_USER => Self::User,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCheckoutOverwriteMode")]
pub enum RepoCheckoutOverwriteMode {
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_NONE")]
None,
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES")]
UnionFiles,
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES")]
AddFiles,
#[doc(alias = "OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL")]
UnionIdentical,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCheckoutOverwriteMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCheckoutOverwriteMode::{}", match *self {
Self::None => "None",
Self::UnionFiles => "UnionFiles",
Self::AddFiles => "AddFiles",
Self::UnionIdentical => "UnionIdentical",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCheckoutOverwriteMode {
type GlibType = ffi::OstreeRepoCheckoutOverwriteMode;
fn into_glib(self) -> ffi::OstreeRepoCheckoutOverwriteMode {
match self {
Self::None => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE,
Self::UnionFiles => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES,
Self::AddFiles => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES,
Self::UnionIdentical => ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCheckoutOverwriteMode> for RepoCheckoutOverwriteMode {
unsafe fn from_glib(value: ffi::OstreeRepoCheckoutOverwriteMode) -> Self {
match value {
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE => Self::None,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_FILES => Self::UnionFiles,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_ADD_FILES => Self::AddFiles,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL => Self::UnionIdentical,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCommitFilterResult")]
pub enum RepoCommitFilterResult {
#[doc(alias = "OSTREE_REPO_COMMIT_FILTER_ALLOW")]
Allow,
#[doc(alias = "OSTREE_REPO_COMMIT_FILTER_SKIP")]
Skip,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCommitFilterResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCommitFilterResult::{}", match *self {
Self::Allow => "Allow",
Self::Skip => "Skip",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitFilterResult {
type GlibType = ffi::OstreeRepoCommitFilterResult;
fn into_glib(self) -> ffi::OstreeRepoCommitFilterResult {
match self {
Self::Allow => ffi::OSTREE_REPO_COMMIT_FILTER_ALLOW,
Self::Skip => ffi::OSTREE_REPO_COMMIT_FILTER_SKIP,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitFilterResult> for RepoCommitFilterResult {
unsafe fn from_glib(value: ffi::OstreeRepoCommitFilterResult) -> Self {
match value {
ffi::OSTREE_REPO_COMMIT_FILTER_ALLOW => Self::Allow,
ffi::OSTREE_REPO_COMMIT_FILTER_SKIP => Self::Skip,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoCommitIterResult")]
pub enum RepoCommitIterResult {
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_ERROR")]
Error,
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_END")]
End,
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_FILE")]
File,
#[doc(alias = "OSTREE_REPO_COMMIT_ITER_RESULT_DIR")]
Dir,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoCommitIterResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoCommitIterResult::{}", match *self {
Self::Error => "Error",
Self::End => "End",
Self::File => "File",
Self::Dir => "Dir",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitIterResult {
type GlibType = ffi::OstreeRepoCommitIterResult;
fn into_glib(self) -> ffi::OstreeRepoCommitIterResult {
match self {
Self::Error => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_ERROR,
Self::End => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_END,
Self::File => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_FILE,
Self::Dir => ffi::OSTREE_REPO_COMMIT_ITER_RESULT_DIR,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitIterResult> for RepoCommitIterResult {
unsafe fn from_glib(value: ffi::OstreeRepoCommitIterResult) -> Self {
match value {
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_ERROR => Self::Error,
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_END => Self::End,
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_FILE => Self::File,
ffi::OSTREE_REPO_COMMIT_ITER_RESULT_DIR => Self::Dir,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoMode")]
pub enum RepoMode {
#[doc(alias = "OSTREE_REPO_MODE_BARE")]
Bare,
#[doc(alias = "OSTREE_REPO_MODE_ARCHIVE")]
Archive,
#[doc(alias = "OSTREE_REPO_MODE_BARE_USER")]
BareUser,
#[doc(alias = "OSTREE_REPO_MODE_BARE_USER_ONLY")]
BareUserOnly,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoMode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoMode::{}", match *self {
Self::Bare => "Bare",
Self::Archive => "Archive",
Self::BareUser => "BareUser",
Self::BareUserOnly => "BareUserOnly",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoMode {
type GlibType = ffi::OstreeRepoMode;
fn into_glib(self) -> ffi::OstreeRepoMode {
match self {
Self::Bare => ffi::OSTREE_REPO_MODE_BARE,
Self::Archive => ffi::OSTREE_REPO_MODE_ARCHIVE,
Self::BareUser => ffi::OSTREE_REPO_MODE_BARE_USER,
Self::BareUserOnly => ffi::OSTREE_REPO_MODE_BARE_USER_ONLY,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoMode> for RepoMode {
unsafe fn from_glib(value: ffi::OstreeRepoMode) -> Self {
match value {
ffi::OSTREE_REPO_MODE_BARE => Self::Bare,
ffi::OSTREE_REPO_MODE_ARCHIVE => Self::Archive,
ffi::OSTREE_REPO_MODE_BARE_USER => Self::BareUser,
ffi::OSTREE_REPO_MODE_BARE_USER_ONLY => Self::BareUserOnly,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeRepoRemoteChange")]
pub enum RepoRemoteChange {
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_ADD")]
Add,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS")]
AddIfNotExists,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_DELETE")]
Delete,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS")]
DeleteIfExists,
#[doc(alias = "OSTREE_REPO_REMOTE_CHANGE_REPLACE")]
Replace,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for RepoRemoteChange {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RepoRemoteChange::{}", match *self {
Self::Add => "Add",
Self::AddIfNotExists => "AddIfNotExists",
Self::Delete => "Delete",
Self::DeleteIfExists => "DeleteIfExists",
Self::Replace => "Replace",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for RepoRemoteChange {
type GlibType = ffi::OstreeRepoRemoteChange;
fn into_glib(self) -> ffi::OstreeRepoRemoteChange {
match self {
Self::Add => ffi::OSTREE_REPO_REMOTE_CHANGE_ADD,
Self::AddIfNotExists => ffi::OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS,
Self::Delete => ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE,
Self::DeleteIfExists => ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS,
Self::Replace => ffi::OSTREE_REPO_REMOTE_CHANGE_REPLACE,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoRemoteChange> for RepoRemoteChange {
unsafe fn from_glib(value: ffi::OstreeRepoRemoteChange) -> Self {
match value {
ffi::OSTREE_REPO_REMOTE_CHANGE_ADD => Self::Add,
ffi::OSTREE_REPO_REMOTE_CHANGE_ADD_IF_NOT_EXISTS => Self::AddIfNotExists,
ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE => Self::Delete,
ffi::OSTREE_REPO_REMOTE_CHANGE_DELETE_IF_EXISTS => Self::DeleteIfExists,
ffi::OSTREE_REPO_REMOTE_CHANGE_REPLACE => Self::Replace,
value => Self::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "OstreeStaticDeltaGenerateOpt")]
pub enum StaticDeltaGenerateOpt {
#[doc(alias = "OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY")]
Lowlatency,
#[doc(alias = "OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR")]
Major,
#[doc(hidden)]
__Unknown(i32),
}
impl fmt::Display for StaticDeltaGenerateOpt {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "StaticDeltaGenerateOpt::{}", match *self {
Self::Lowlatency => "Lowlatency",
Self::Major => "Major",
_ => "Unknown",
})
}
}
#[doc(hidden)]
impl IntoGlib for StaticDeltaGenerateOpt {
type GlibType = ffi::OstreeStaticDeltaGenerateOpt;
fn into_glib(self) -> ffi::OstreeStaticDeltaGenerateOpt {
match self {
Self::Lowlatency => ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY,
Self::Major => ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR,
Self::__Unknown(value) => value,
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeStaticDeltaGenerateOpt> for StaticDeltaGenerateOpt {
unsafe fn from_glib(value: ffi::OstreeStaticDeltaGenerateOpt) -> Self {
match value {
ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_LOWLATENCY => Self::Lowlatency,
ffi::OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR => Self::Major,
value => Self::__Unknown(value),
}
}
}
+622
View File
@@ -0,0 +1,622 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use bitflags::bitflags;
use glib::translate::*;
use glib::value::FromValue;
use glib::value::ToValue;
use glib::StaticType;
use glib::Type;
use std::fmt;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
bitflags! {
#[doc(alias = "OstreeChecksumFlags")]
pub struct ChecksumFlags: u32 {
#[doc(alias = "OSTREE_CHECKSUM_FLAGS_NONE")]
const NONE = ffi::OSTREE_CHECKSUM_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS")]
const IGNORE_XATTRS = ffi::OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS as u32;
#[doc(alias = "OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS")]
const CANONICAL_PERMISSIONS = ffi::OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS as u32;
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
impl fmt::Display for ChecksumFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(hidden)]
impl IntoGlib for ChecksumFlags {
type GlibType = ffi::OstreeChecksumFlags;
fn into_glib(self) -> ffi::OstreeChecksumFlags {
self.bits()
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeChecksumFlags> for ChecksumFlags {
unsafe fn from_glib(value: ffi::OstreeChecksumFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeDiffFlags")]
pub struct DiffFlags: u32 {
#[doc(alias = "OSTREE_DIFF_FLAGS_NONE")]
const NONE = ffi::OSTREE_DIFF_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_DIFF_FLAGS_IGNORE_XATTRS")]
const IGNORE_XATTRS = ffi::OSTREE_DIFF_FLAGS_IGNORE_XATTRS as u32;
}
}
impl fmt::Display for DiffFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for DiffFlags {
type GlibType = ffi::OstreeDiffFlags;
fn into_glib(self) -> ffi::OstreeDiffFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeDiffFlags> for DiffFlags {
unsafe fn from_glib(value: ffi::OstreeDiffFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeGpgSignatureFormatFlags")]
pub struct GpgSignatureFormatFlags: u32 {
#[doc(alias = "OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT")]
const GPG_SIGNATURE_FORMAT_DEFAULT = ffi::OSTREE_GPG_SIGNATURE_FORMAT_DEFAULT as u32;
}
}
impl fmt::Display for GpgSignatureFormatFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for GpgSignatureFormatFlags {
type GlibType = ffi::OstreeGpgSignatureFormatFlags;
fn into_glib(self) -> ffi::OstreeGpgSignatureFormatFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeGpgSignatureFormatFlags> for GpgSignatureFormatFlags {
unsafe fn from_glib(value: ffi::OstreeGpgSignatureFormatFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoCommitModifierFlags")]
pub struct RepoCommitModifierFlags: u32 {
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS")]
const SKIP_XATTRS = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES")]
const GENERATE_SIZES = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS")]
const CANONICAL_PERMISSIONS = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED")]
const ERROR_ON_UNLABELED = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME")]
const CONSUME = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL")]
const DEVINO_CANONICAL = ffi::OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL as u32;
}
}
impl fmt::Display for RepoCommitModifierFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitModifierFlags {
type GlibType = ffi::OstreeRepoCommitModifierFlags;
fn into_glib(self) -> ffi::OstreeRepoCommitModifierFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitModifierFlags> for RepoCommitModifierFlags {
unsafe fn from_glib(value: ffi::OstreeRepoCommitModifierFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
bitflags! {
#[doc(alias = "OstreeRepoCommitState")]
pub struct RepoCommitState: u32 {
#[doc(alias = "OSTREE_REPO_COMMIT_STATE_NORMAL")]
const NORMAL = ffi::OSTREE_REPO_COMMIT_STATE_NORMAL as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_STATE_PARTIAL")]
const PARTIAL = ffi::OSTREE_REPO_COMMIT_STATE_PARTIAL as u32;
#[doc(alias = "OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL")]
const FSCK_PARTIAL = ffi::OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL as u32;
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
impl fmt::Display for RepoCommitState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
#[doc(hidden)]
impl IntoGlib for RepoCommitState {
type GlibType = ffi::OstreeRepoCommitState;
fn into_glib(self) -> ffi::OstreeRepoCommitState {
self.bits()
}
}
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitState> for RepoCommitState {
unsafe fn from_glib(value: ffi::OstreeRepoCommitState) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoCommitTraverseFlags")]
pub struct RepoCommitTraverseFlags: u32 {
#[doc(alias = "OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE")]
const REPO_COMMIT_TRAVERSE_FLAG_NONE = ffi::OSTREE_REPO_COMMIT_TRAVERSE_FLAG_NONE as u32;
}
}
impl fmt::Display for RepoCommitTraverseFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoCommitTraverseFlags {
type GlibType = ffi::OstreeRepoCommitTraverseFlags;
fn into_glib(self) -> ffi::OstreeRepoCommitTraverseFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoCommitTraverseFlags> for RepoCommitTraverseFlags {
unsafe fn from_glib(value: ffi::OstreeRepoCommitTraverseFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoListObjectsFlags")]
pub struct RepoListObjectsFlags: u32 {
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_LOOSE")]
const LOOSE = ffi::OSTREE_REPO_LIST_OBJECTS_LOOSE as u32;
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_PACKED")]
const PACKED = ffi::OSTREE_REPO_LIST_OBJECTS_PACKED as u32;
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_ALL")]
const ALL = ffi::OSTREE_REPO_LIST_OBJECTS_ALL as u32;
#[doc(alias = "OSTREE_REPO_LIST_OBJECTS_NO_PARENTS")]
const NO_PARENTS = ffi::OSTREE_REPO_LIST_OBJECTS_NO_PARENTS as u32;
}
}
impl fmt::Display for RepoListObjectsFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoListObjectsFlags {
type GlibType = ffi::OstreeRepoListObjectsFlags;
fn into_glib(self) -> ffi::OstreeRepoListObjectsFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoListObjectsFlags> for RepoListObjectsFlags {
unsafe fn from_glib(value: ffi::OstreeRepoListObjectsFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoListRefsExtFlags")]
pub struct RepoListRefsExtFlags: u32 {
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_NONE")]
const NONE = ffi::OSTREE_REPO_LIST_REFS_EXT_NONE as u32;
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_ALIASES")]
const ALIASES = ffi::OSTREE_REPO_LIST_REFS_EXT_ALIASES as u32;
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES")]
const EXCLUDE_REMOTES = ffi::OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_REMOTES as u32;
#[doc(alias = "OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS")]
const EXCLUDE_MIRRORS = ffi::OSTREE_REPO_LIST_REFS_EXT_EXCLUDE_MIRRORS as u32;
}
}
impl fmt::Display for RepoListRefsExtFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoListRefsExtFlags {
type GlibType = ffi::OstreeRepoListRefsExtFlags;
fn into_glib(self) -> ffi::OstreeRepoListRefsExtFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoListRefsExtFlags> for RepoListRefsExtFlags {
unsafe fn from_glib(value: ffi::OstreeRepoListRefsExtFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoPruneFlags")]
pub struct RepoPruneFlags: u32 {
#[doc(alias = "OSTREE_REPO_PRUNE_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_PRUNE_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE")]
const NO_PRUNE = ffi::OSTREE_REPO_PRUNE_FLAGS_NO_PRUNE as u32;
#[doc(alias = "OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY")]
const REFS_ONLY = ffi::OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY as u32;
}
}
impl fmt::Display for RepoPruneFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoPruneFlags {
type GlibType = ffi::OstreeRepoPruneFlags;
fn into_glib(self) -> ffi::OstreeRepoPruneFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoPruneFlags> for RepoPruneFlags {
unsafe fn from_glib(value: ffi::OstreeRepoPruneFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoPullFlags")]
pub struct RepoPullFlags: u32 {
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_PULL_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_MIRROR")]
const MIRROR = ffi::OSTREE_REPO_PULL_FLAGS_MIRROR as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY")]
const COMMIT_ONLY = ffi::OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_UNTRUSTED")]
const UNTRUSTED = ffi::OSTREE_REPO_PULL_FLAGS_UNTRUSTED as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES")]
const BAREUSERONLY_FILES = ffi::OSTREE_REPO_PULL_FLAGS_BAREUSERONLY_FILES as u32;
#[doc(alias = "OSTREE_REPO_PULL_FLAGS_TRUSTED_HTTP")]
const TRUSTED_HTTP = ffi::OSTREE_REPO_PULL_FLAGS_TRUSTED_HTTP as u32;
}
}
impl fmt::Display for RepoPullFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoPullFlags {
type GlibType = ffi::OstreeRepoPullFlags;
fn into_glib(self) -> ffi::OstreeRepoPullFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoPullFlags> for RepoPullFlags {
unsafe fn from_glib(value: ffi::OstreeRepoPullFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeRepoResolveRevExtFlags")]
pub struct RepoResolveRevExtFlags: u32 {
#[doc(alias = "OSTREE_REPO_RESOLVE_REV_EXT_NONE")]
const NONE = ffi::OSTREE_REPO_RESOLVE_REV_EXT_NONE as u32;
#[doc(alias = "OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY")]
const LOCAL_ONLY = ffi::OSTREE_REPO_RESOLVE_REV_EXT_LOCAL_ONLY as u32;
}
}
impl fmt::Display for RepoResolveRevExtFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for RepoResolveRevExtFlags {
type GlibType = ffi::OstreeRepoResolveRevExtFlags;
fn into_glib(self) -> ffi::OstreeRepoResolveRevExtFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoResolveRevExtFlags> for RepoResolveRevExtFlags {
unsafe fn from_glib(value: ffi::OstreeRepoResolveRevExtFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
bitflags! {
#[doc(alias = "OstreeRepoVerifyFlags")]
pub struct RepoVerifyFlags: u32 {
#[doc(alias = "OSTREE_REPO_VERIFY_FLAGS_NONE")]
const NONE = ffi::OSTREE_REPO_VERIFY_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_REPO_VERIFY_FLAGS_NO_GPG")]
const NO_GPG = ffi::OSTREE_REPO_VERIFY_FLAGS_NO_GPG as u32;
#[doc(alias = "OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI")]
const NO_SIGNAPI = ffi::OSTREE_REPO_VERIFY_FLAGS_NO_SIGNAPI as u32;
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
impl fmt::Display for RepoVerifyFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
#[doc(hidden)]
impl IntoGlib for RepoVerifyFlags {
type GlibType = ffi::OstreeRepoVerifyFlags;
fn into_glib(self) -> ffi::OstreeRepoVerifyFlags {
self.bits()
}
}
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
#[doc(hidden)]
impl FromGlib<ffi::OstreeRepoVerifyFlags> for RepoVerifyFlags {
unsafe fn from_glib(value: ffi::OstreeRepoVerifyFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeSePolicyRestoreconFlags")]
pub struct SePolicyRestoreconFlags: u32 {
#[doc(alias = "OSTREE_SEPOLICY_RESTORECON_FLAGS_NONE")]
const NONE = ffi::OSTREE_SEPOLICY_RESTORECON_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL")]
const ALLOW_NOLABEL = ffi::OSTREE_SEPOLICY_RESTORECON_FLAGS_ALLOW_NOLABEL as u32;
#[doc(alias = "OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING")]
const KEEP_EXISTING = ffi::OSTREE_SEPOLICY_RESTORECON_FLAGS_KEEP_EXISTING as u32;
}
}
impl fmt::Display for SePolicyRestoreconFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SePolicyRestoreconFlags {
type GlibType = ffi::OstreeSePolicyRestoreconFlags;
fn into_glib(self) -> ffi::OstreeSePolicyRestoreconFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSePolicyRestoreconFlags> for SePolicyRestoreconFlags {
unsafe fn from_glib(value: ffi::OstreeSePolicyRestoreconFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeSysrootSimpleWriteDeploymentFlags")]
pub struct SysrootSimpleWriteDeploymentFlags: u32 {
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE")]
const NONE = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN")]
const RETAIN = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT")]
const NOT_DEFAULT = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NOT_DEFAULT as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN")]
const NO_CLEAN = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING")]
const RETAIN_PENDING = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_PENDING as u32;
#[doc(alias = "OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK")]
const RETAIN_ROLLBACK = ffi::OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN_ROLLBACK as u32;
}
}
impl fmt::Display for SysrootSimpleWriteDeploymentFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SysrootSimpleWriteDeploymentFlags {
type GlibType = ffi::OstreeSysrootSimpleWriteDeploymentFlags;
fn into_glib(self) -> ffi::OstreeSysrootSimpleWriteDeploymentFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSysrootSimpleWriteDeploymentFlags> for SysrootSimpleWriteDeploymentFlags {
unsafe fn from_glib(value: ffi::OstreeSysrootSimpleWriteDeploymentFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[doc(alias = "OstreeSysrootUpgraderFlags")]
pub struct SysrootUpgraderFlags: u32 {
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED")]
const IGNORE_UNCONFIGURED = ffi::OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED as u32;
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE")]
const STAGE = ffi::OSTREE_SYSROOT_UPGRADER_FLAGS_STAGE as u32;
}
}
impl fmt::Display for SysrootUpgraderFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SysrootUpgraderFlags {
type GlibType = ffi::OstreeSysrootUpgraderFlags;
fn into_glib(self) -> ffi::OstreeSysrootUpgraderFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSysrootUpgraderFlags> for SysrootUpgraderFlags {
unsafe fn from_glib(value: ffi::OstreeSysrootUpgraderFlags) -> Self {
Self::from_bits_truncate(value)
}
}
impl StaticType for SysrootUpgraderFlags {
fn static_type() -> Type {
unsafe { from_glib(ffi::ostree_sysroot_upgrader_flags_get_type()) }
}
}
impl glib::value::ValueType for SysrootUpgraderFlags {
type Type = Self;
}
unsafe impl<'a> FromValue<'a> for SysrootUpgraderFlags {
type Checker = glib::value::GenericValueTypeChecker<Self>;
unsafe fn from_value(value: &'a glib::Value) -> Self {
from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0))
}
}
impl ToValue for SysrootUpgraderFlags {
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib());
}
value
}
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}
bitflags! {
#[doc(alias = "OstreeSysrootUpgraderPullFlags")]
pub struct SysrootUpgraderPullFlags: u32 {
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_NONE")]
const NONE = ffi::OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_NONE as u32;
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER")]
const ALLOW_OLDER = ffi::OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_ALLOW_OLDER as u32;
#[doc(alias = "OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_SYNTHETIC")]
const SYNTHETIC = ffi::OSTREE_SYSROOT_UPGRADER_PULL_FLAGS_SYNTHETIC as u32;
}
}
impl fmt::Display for SysrootUpgraderPullFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SysrootUpgraderPullFlags {
type GlibType = ffi::OstreeSysrootUpgraderPullFlags;
fn into_glib(self) -> ffi::OstreeSysrootUpgraderPullFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::OstreeSysrootUpgraderPullFlags> for SysrootUpgraderPullFlags {
unsafe fn from_glib(value: ffi::OstreeSysrootUpgraderPullFlags) -> Self {
Self::from_bits_truncate(value)
}
}
+385
View File
@@ -0,0 +1,385 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
use crate::CommitSizesEntry;
use crate::DiffFlags;
use crate::DiffItem;
use crate::ObjectType;
use glib::object::IsA;
use glib::translate::*;
use std::mem;
use std::ptr;
#[cfg(any(feature = "v2017_15", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_15")))]
#[doc(alias = "ostree_break_hardlink")]
pub fn break_hardlink<P: IsA<gio::Cancellable>>(dfd: i32, path: &str, skip_xattrs: bool, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_break_hardlink(dfd, path.to_glib_none().0, skip_xattrs.into_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 = "v2017_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
#[doc(alias = "ostree_check_version")]
pub fn check_version(required_year: u32, required_release: u32) -> bool {
unsafe {
from_glib(ffi::ostree_check_version(required_year, required_release))
}
}
//#[doc(alias = "ostree_checksum_bytes_peek")]
//pub fn checksum_bytes_peek(bytes: &glib::Variant) -> /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32 {
// unsafe { TODO: call ffi:ostree_checksum_bytes_peek() }
//}
//#[doc(alias = "ostree_checksum_bytes_peek_validate")]
//pub fn checksum_bytes_peek_validate(bytes: &glib::Variant) -> Result</*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 3 }; 32, glib::Error> {
// unsafe { TODO: call ffi:ostree_checksum_bytes_peek_validate() }
//}
#[doc(alias = "ostree_checksum_from_bytes_v")]
pub fn checksum_from_bytes_v(csum_v: &glib::Variant) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_checksum_from_bytes_v(csum_v.to_glib_none().0))
}
}
#[doc(alias = "ostree_checksum_to_bytes_v")]
pub fn checksum_to_bytes_v(checksum: &str) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_checksum_to_bytes_v(checksum.to_glib_none().0))
}
}
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
#[doc(alias = "ostree_commit_get_content_checksum")]
pub fn commit_get_content_checksum(commit_variant: &glib::Variant) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_commit_get_content_checksum(commit_variant.to_glib_none().0))
}
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_commit_get_object_sizes")]
pub fn commit_get_object_sizes(commit_variant: &glib::Variant) -> Result<Vec<CommitSizesEntry>, glib::Error> {
unsafe {
let mut out_sizes_entries = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_commit_get_object_sizes(commit_variant.to_glib_none().0, &mut out_sizes_entries, &mut error);
if error.is_null() { Ok(FromGlibPtrContainer::from_glib_container(out_sizes_entries)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_commit_get_parent")]
pub fn commit_get_parent(commit_variant: &glib::Variant) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_commit_get_parent(commit_variant.to_glib_none().0))
}
}
#[cfg(any(feature = "v2016_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_3")))]
#[doc(alias = "ostree_commit_get_timestamp")]
pub fn commit_get_timestamp(commit_variant: &glib::Variant) -> u64 {
unsafe {
ffi::ostree_commit_get_timestamp(commit_variant.to_glib_none().0)
}
}
//#[cfg(any(feature = "v2021_1", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
//#[doc(alias = "ostree_commit_metadata_for_bootable")]
//pub fn commit_metadata_for_bootable<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(root: &P, dict: /*Ignored*/&glib::VariantDict, cancellable: Option<&Q>) -> Result<(), glib::Error> {
// unsafe { TODO: call ffi:ostree_commit_metadata_for_bootable() }
//}
#[doc(alias = "ostree_content_file_parse")]
pub fn content_file_parse<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(compressed: bool, content_path: &P, trusted: bool, cancellable: Option<&Q>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), glib::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.into_glib(), content_path.as_ref().to_glib_none().0, trusted.into_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)) }
}
}
#[doc(alias = "ostree_content_file_parse_at")]
pub fn content_file_parse_at<P: IsA<gio::Cancellable>>(compressed: bool, parent_dfd: i32, path: &str, trusted: bool, cancellable: Option<&P>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), glib::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.into_glib(), parent_dfd, path.to_glib_none().0, trusted.into_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)) }
}
}
#[doc(alias = "ostree_content_stream_parse")]
pub fn content_stream_parse<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(compressed: bool, input: &P, input_length: u64, trusted: bool, cancellable: Option<&Q>) -> Result<(gio::InputStream, gio::FileInfo, glib::Variant), glib::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.into_glib(), input.as_ref().to_glib_none().0, input_length, trusted.into_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)) }
}
}
#[doc(alias = "ostree_create_directory_metadata")]
pub fn create_directory_metadata(dir_info: &gio::FileInfo, xattrs: Option<&glib::Variant>) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_create_directory_metadata(dir_info.to_glib_none().0, xattrs.to_glib_none().0))
}
}
#[doc(alias = "ostree_diff_dirs")]
pub fn diff_dirs<P: IsA<gio::File>, Q: IsA<gio::File>, R: IsA<gio::Cancellable>>(flags: DiffFlags, a: &P, b: &Q, modified: &[&DiffItem], removed: &[gio::File], added: &[gio::File], cancellable: Option<&R>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_diff_dirs(flags.into_glib(), a.as_ref().to_glib_none().0, b.as_ref().to_glib_none().0, modified.to_glib_none().0, removed.to_glib_none().0, added.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_4", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
//#[doc(alias = "ostree_diff_dirs_with_options")]
//pub fn diff_dirs_with_options<P: IsA<gio::File>, Q: IsA<gio::File>, R: IsA<gio::Cancellable>>(flags: DiffFlags, a: &P, b: &Q, modified: &[&DiffItem], removed: &[gio::File], added: &[gio::File], options: /*Ignored*/Option<&mut DiffDirsOptions>, cancellable: Option<&R>) -> Result<(), glib::Error> {
// unsafe { TODO: call ffi:ostree_diff_dirs_with_options() }
//}
#[doc(alias = "ostree_diff_print")]
pub fn diff_print<P: IsA<gio::File>, Q: IsA<gio::File>>(a: &P, b: &Q, modified: &[&DiffItem], removed: &[gio::File], added: &[gio::File]) {
unsafe {
ffi::ostree_diff_print(a.as_ref().to_glib_none().0, b.as_ref().to_glib_none().0, modified.to_glib_none().0, removed.to_glib_none().0, added.to_glib_none().0);
}
}
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
#[doc(alias = "ostree_gpg_error_quark")]
pub fn gpg_error_quark() -> glib::Quark {
unsafe {
from_glib(ffi::ostree_gpg_error_quark())
}
}
#[doc(alias = "ostree_metadata_variant_type")]
pub fn metadata_variant_type(objtype: ObjectType) -> Option<glib::VariantType> {
unsafe {
from_glib_none(ffi::ostree_metadata_variant_type(objtype.into_glib()))
}
}
#[doc(alias = "ostree_object_from_string")]
pub fn object_from_string(str: &str) -> (glib::GString, ObjectType) {
unsafe {
let mut out_checksum = ptr::null_mut();
let mut out_objtype = mem::MaybeUninit::uninit();
ffi::ostree_object_from_string(str.to_glib_none().0, &mut out_checksum, out_objtype.as_mut_ptr());
let out_objtype = out_objtype.assume_init();
(from_glib_full(out_checksum), from_glib(out_objtype))
}
}
#[doc(alias = "ostree_object_name_deserialize")]
pub fn object_name_deserialize(variant: &glib::Variant) -> (glib::GString, ObjectType) {
unsafe {
let mut out_checksum = ptr::null();
let mut out_objtype = mem::MaybeUninit::uninit();
ffi::ostree_object_name_deserialize(variant.to_glib_none().0, &mut out_checksum, out_objtype.as_mut_ptr());
let out_objtype = out_objtype.assume_init();
(from_glib_none(out_checksum), from_glib(out_objtype))
}
}
#[doc(alias = "ostree_object_name_serialize")]
pub fn object_name_serialize(checksum: &str, objtype: ObjectType) -> Option<glib::Variant> {
unsafe {
from_glib_none(ffi::ostree_object_name_serialize(checksum.to_glib_none().0, objtype.into_glib()))
}
}
#[doc(alias = "ostree_object_to_string")]
pub fn object_to_string(checksum: &str, objtype: ObjectType) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_object_to_string(checksum.to_glib_none().0, objtype.into_glib()))
}
}
#[doc(alias = "ostree_object_type_from_string")]
pub fn object_type_from_string(str: &str) -> ObjectType {
unsafe {
from_glib(ffi::ostree_object_type_from_string(str.to_glib_none().0))
}
}
#[doc(alias = "ostree_object_type_to_string")]
pub fn object_type_to_string(objtype: ObjectType) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_object_type_to_string(objtype.into_glib()))
}
}
#[doc(alias = "ostree_parse_refspec")]
pub fn parse_refspec(refspec: &str) -> Result<(Option<glib::GString>, glib::GString), glib::Error> {
unsafe {
let mut out_remote = ptr::null_mut();
let mut out_ref = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_parse_refspec(refspec.to_glib_none().0, &mut out_remote, &mut out_ref, &mut error);
if error.is_null() { Ok((from_glib_full(out_remote), from_glib_full(out_ref))) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2016_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_6")))]
#[doc(alias = "ostree_raw_file_to_archive_z2_stream")]
pub fn raw_file_to_archive_z2_stream<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<gio::InputStream, glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::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"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_3")))]
#[doc(alias = "ostree_raw_file_to_archive_z2_stream_with_options")]
pub fn raw_file_to_archive_z2_stream_with_options<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, options: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<gio::InputStream, glib::Error> {
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.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)) }
}
}
#[doc(alias = "ostree_raw_file_to_content_stream")]
pub fn raw_file_to_content_stream<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(input: &P, file_info: &gio::FileInfo, xattrs: Option<&glib::Variant>, cancellable: Option<&Q>) -> Result<(gio::InputStream, u64), glib::Error> {
unsafe {
let mut out_input = ptr::null_mut();
let mut out_length = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::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, out_length.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_length = out_length.assume_init();
if error.is_null() { Ok((from_glib_full(out_input), out_length)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_checksum_string")]
pub fn validate_checksum_string(sha256: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_checksum_string(sha256.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
#[doc(alias = "ostree_validate_collection_id")]
pub fn validate_collection_id(collection_id: Option<&str>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_collection_id(collection_id.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2017_8", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_8")))]
#[doc(alias = "ostree_validate_remote_name")]
pub fn validate_remote_name(remote_name: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_remote_name(remote_name.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_rev")]
pub fn validate_rev(rev: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_rev(rev.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_checksum_string")]
pub fn validate_structureof_checksum_string(checksum: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_checksum_string(checksum.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_commit")]
pub fn validate_structureof_commit(commit: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_commit(commit.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_csum_v")]
pub fn validate_structureof_csum_v(checksum: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_csum_v(checksum.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_dirmeta")]
pub fn validate_structureof_dirmeta(dirmeta: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_dirmeta(dirmeta.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_dirtree")]
pub fn validate_structureof_dirtree(dirtree: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_dirtree(dirtree.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_file_mode")]
pub fn validate_structureof_file_mode(mode: u32) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_file_mode(mode, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_validate_structureof_objtype")]
pub fn validate_structureof_objtype(objtype: u8) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_validate_structureof_objtype(objtype, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
+90
View File
@@ -0,0 +1,90 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::GpgSignatureFormatFlags;
use glib::translate::*;
use std::fmt;
use std::mem;
#[cfg(any(feature = "v2016_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_6")))]
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeGpgVerifyResult")]
pub struct GpgVerifyResult(Object<ffi::OstreeGpgVerifyResult>);
match fn {
type_ => || ffi::ostree_gpg_verify_result_get_type(),
}
}
impl GpgVerifyResult {
#[doc(alias = "ostree_gpg_verify_result_count_all")]
pub fn count_all(&self) -> u32 {
unsafe {
ffi::ostree_gpg_verify_result_count_all(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_gpg_verify_result_count_valid")]
pub fn count_valid(&self) -> u32 {
unsafe {
ffi::ostree_gpg_verify_result_count_valid(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_gpg_verify_result_describe")]
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.to_glib_none().0, flags.into_glib());
}
}
//#[doc(alias = "ostree_gpg_verify_result_get")]
//pub fn get(&self, signature_index: u32, attrs: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 31 }) -> Option<glib::Variant> {
// unsafe { TODO: call ffi:ostree_gpg_verify_result_get() }
//}
#[doc(alias = "ostree_gpg_verify_result_get_all")]
#[doc(alias = "get_all")]
pub fn all(&self, signature_index: u32) -> Option<glib::Variant> {
unsafe {
from_glib_none(ffi::ostree_gpg_verify_result_get_all(self.to_glib_none().0, signature_index))
}
}
#[doc(alias = "ostree_gpg_verify_result_lookup")]
pub fn lookup(&self, key_id: &str) -> Option<u32> {
unsafe {
let mut out_signature_index = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::ostree_gpg_verify_result_lookup(self.to_glib_none().0, key_id.to_glib_none().0, out_signature_index.as_mut_ptr()));
let out_signature_index = out_signature_index.assume_init();
if ret { Some(out_signature_index) } else { None }
}
}
#[cfg(any(feature = "v2016_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_6")))]
#[doc(alias = "ostree_gpg_verify_result_require_valid_signature")]
pub fn require_valid_signature(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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)) }
}
}
#[doc(alias = "ostree_gpg_verify_result_describe_variant")]
pub fn describe_variant(variant: &glib::Variant, output_buffer: &mut glib::String, line_prefix: Option<&str>, flags: GpgSignatureFormatFlags) {
unsafe {
ffi::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.into_glib());
}
}
}
impl fmt::Display for GpgVerifyResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("GpgVerifyResult")
}
}
+214
View File
@@ -0,0 +1,214 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
mod async_progress;
pub use self::async_progress::{AsyncProgress};
mod bootconfig_parser;
pub use self::bootconfig_parser::{BootconfigParser};
mod content_writer;
pub use self::content_writer::{ContentWriter};
mod deployment;
pub use self::deployment::{Deployment};
mod gpg_verify_result;
pub use self::gpg_verify_result::{GpgVerifyResult};
mod mutable_tree;
pub use self::mutable_tree::{MutableTree};
mod repo;
pub use self::repo::{Repo};
mod repo_file;
pub use self::repo_file::{RepoFile};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder::{RepoFinder, NONE_REPO_FINDER};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_avahi;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_avahi::{RepoFinderAvahi};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_config;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_config::{RepoFinderConfig};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_mount;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_mount::{RepoFinderMount};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_override;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_override::{RepoFinderOverride};
mod se_policy;
pub use self::se_policy::{SePolicy};
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
mod sign;
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
pub use self::sign::{Sign, NONE_SIGN};
mod sysroot;
pub use self::sysroot::{Sysroot};
mod sysroot_upgrader;
pub use self::sysroot_upgrader::{SysrootUpgrader};
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod collection_ref;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::collection_ref::CollectionRef;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
mod commit_sizes_entry;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
pub use self::commit_sizes_entry::CommitSizesEntry;
mod diff_item;
pub use self::diff_item::DiffItem;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod remote;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::remote::Remote;
mod repo_commit_modifier;
pub use self::repo_commit_modifier::RepoCommitModifier;
mod repo_dev_ino_cache;
pub use self::repo_dev_ino_cache::RepoDevInoCache;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
mod repo_finder_result;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::repo_finder_result::RepoFinderResult;
mod enums;
pub use self::enums::DeploymentUnlockedState;
pub use self::enums::GpgSignatureAttr;
pub use self::enums::ObjectType;
#[cfg(any(feature = "v2018_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_2")))]
pub use self::enums::RepoCheckoutFilterResult;
pub use self::enums::RepoCheckoutMode;
pub use self::enums::RepoCheckoutOverwriteMode;
pub use self::enums::RepoCommitFilterResult;
pub use self::enums::RepoCommitIterResult;
pub use self::enums::RepoMode;
pub use self::enums::RepoRemoteChange;
pub use self::enums::StaticDeltaGenerateOpt;
mod flags;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
pub use self::flags::ChecksumFlags;
pub use self::flags::DiffFlags;
pub use self::flags::GpgSignatureFormatFlags;
pub use self::flags::RepoCommitModifierFlags;
#[cfg(any(feature = "v2015_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2015_7")))]
pub use self::flags::RepoCommitState;
pub use self::flags::RepoCommitTraverseFlags;
pub use self::flags::RepoListObjectsFlags;
pub use self::flags::RepoListRefsExtFlags;
pub use self::flags::RepoPruneFlags;
pub use self::flags::RepoPullFlags;
pub use self::flags::RepoResolveRevExtFlags;
#[cfg(any(feature = "v2021_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_4")))]
pub use self::flags::RepoVerifyFlags;
pub use self::flags::SePolicyRestoreconFlags;
pub use self::flags::SysrootSimpleWriteDeploymentFlags;
pub use self::flags::SysrootUpgraderFlags;
pub use self::flags::SysrootUpgraderPullFlags;
pub mod functions;
mod constants;
pub use self::constants::COMMIT_GVARIANT_STRING;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
pub use self::constants::COMMIT_META_KEY_ARCHITECTURE;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::constants::COMMIT_META_KEY_COLLECTION_BINDING;
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
pub use self::constants::COMMIT_META_KEY_ENDOFLIFE;
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
pub use self::constants::COMMIT_META_KEY_ENDOFLIFE_REBASE;
#[cfg(any(feature = "v2017_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_9")))]
pub use self::constants::COMMIT_META_KEY_REF_BINDING;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
pub use self::constants::COMMIT_META_KEY_SOURCE_TITLE;
#[cfg(any(feature = "v2014_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2014_9")))]
pub use self::constants::COMMIT_META_KEY_VERSION;
pub use self::constants::DIRMETA_GVARIANT_STRING;
pub use self::constants::FILEMETA_GVARIANT_STRING;
pub use self::constants::GPG_KEY_GVARIANT_STRING;
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
pub use self::constants::METADATA_KEY_BOOTABLE;
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
pub use self::constants::METADATA_KEY_LINUX;
#[cfg(any(feature = "v2018_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_9")))]
pub use self::constants::META_KEY_DEPLOY_COLLECTION_ID;
#[cfg(any(feature = "v2018_3", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
pub use self::constants::ORIGIN_TRANSIENT_GROUP;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use self::constants::REPO_METADATA_REF;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
pub use self::constants::SIGN_NAME_ED25519;
pub use self::constants::SUMMARY_GVARIANT_STRING;
pub use self::constants::SUMMARY_SIG_GVARIANT_STRING;
pub use self::constants::TREE_GVARIANT_STRING;
#[doc(hidden)]
pub mod traits {
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub use super::repo_finder::RepoFinderExt;
#[cfg(any(feature = "v2020_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_2")))]
pub use super::sign::SignExt;
}
+185
View File
@@ -0,0 +1,185 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
use crate::Repo;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeMutableTree")]
pub struct MutableTree(Object<ffi::OstreeMutableTree, ffi::OstreeMutableTreeClass>);
match fn {
type_ => || ffi::ostree_mutable_tree_get_type(),
}
}
impl MutableTree {
#[doc(alias = "ostree_mutable_tree_new")]
pub fn new() -> MutableTree {
unsafe {
from_glib_full(ffi::ostree_mutable_tree_new())
}
}
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
#[doc(alias = "ostree_mutable_tree_new_from_checksum")]
#[doc(alias = "new_from_checksum")]
pub fn 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))
}
}
#[cfg(any(feature = "v2021_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_5")))]
#[doc(alias = "ostree_mutable_tree_new_from_commit")]
#[doc(alias = "new_from_commit")]
pub fn from_commit(repo: &Repo, rev: &str) -> Result<MutableTree, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_mutable_tree_new_from_commit(repo.to_glib_none().0, rev.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
#[doc(alias = "ostree_mutable_tree_check_error")]
pub fn check_error(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_check_error(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_ensure_dir")]
pub fn ensure_dir(&self, name: &str) -> Result<MutableTree, glib::Error> {
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);
if error.is_null() { Ok(from_glib_full(out_subdir)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_ensure_parent_dirs")]
pub fn ensure_parent_dirs(&self, split_path: &[&str], metadata_checksum: &str) -> Result<MutableTree, glib::Error> {
unsafe {
let mut out_parent = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_ensure_parent_dirs(self.to_glib_none().0, split_path.to_glib_none().0, metadata_checksum.to_glib_none().0, &mut out_parent, &mut error);
if error.is_null() { Ok(from_glib_full(out_parent)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_7")))]
#[doc(alias = "ostree_mutable_tree_fill_empty_from_dirtree")]
pub 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))
}
}
#[doc(alias = "ostree_mutable_tree_get_contents_checksum")]
#[doc(alias = "get_contents_checksum")]
pub fn contents_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_mutable_tree_get_contents_checksum(self.to_glib_none().0))
}
}
//#[doc(alias = "ostree_mutable_tree_get_files")]
//#[doc(alias = "get_files")]
//pub fn 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() }
//}
#[doc(alias = "ostree_mutable_tree_get_metadata_checksum")]
#[doc(alias = "get_metadata_checksum")]
pub fn metadata_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_mutable_tree_get_metadata_checksum(self.to_glib_none().0))
}
}
//#[doc(alias = "ostree_mutable_tree_get_subdirs")]
//#[doc(alias = "get_subdirs")]
//pub fn subdirs(&self) -> /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 1, id: 44 } {
// unsafe { TODO: call ffi:ostree_mutable_tree_get_subdirs() }
//}
#[doc(alias = "ostree_mutable_tree_lookup")]
pub fn lookup(&self, name: &str) -> Result<(glib::GString, MutableTree), glib::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);
if error.is_null() { Ok((from_glib_full(out_file_checksum), from_glib_full(out_subdir))) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_9", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_9")))]
#[doc(alias = "ostree_mutable_tree_remove")]
pub fn remove(&self, name: &str, allow_noent: bool) -> Result<(), glib::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.into_glib(), &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_replace_file")]
pub fn replace_file(&self, name: &str, checksum: &str) -> Result<(), glib::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);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_mutable_tree_set_contents_checksum")]
pub 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);
}
}
#[doc(alias = "ostree_mutable_tree_set_metadata_checksum")]
pub 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);
}
}
#[doc(alias = "ostree_mutable_tree_walk")]
pub fn walk(&self, split_path: &[&str], start: u32) -> Result<MutableTree, glib::Error> {
unsafe {
let mut out_subdir = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_mutable_tree_walk(self.to_glib_none().0, split_path.to_glib_none().0, start, &mut out_subdir, &mut error);
if error.is_null() { Ok(from_glib_full(out_subdir)) } else { Err(from_glib_full(error)) }
}
}
}
impl Default for MutableTree {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for MutableTree {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("MutableTree")
}
}
+34
View File
@@ -0,0 +1,34 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Remote(Shared<ffi::OstreeRemote>);
match fn {
ref => |ptr| ffi::ostree_remote_ref(ptr),
unref => |ptr| ffi::ostree_remote_unref(ptr),
type_ => || ffi::ostree_remote_get_type(),
}
}
impl Remote {
#[doc(alias = "ostree_remote_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_remote_get_name(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_remote_get_url")]
#[doc(alias = "get_url")]
pub fn url(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_remote_get_url(self.to_glib_none().0))
}
}
}
+1343
View File
File diff suppressed because it is too large. Load diff
+107
View File
@@ -0,0 +1,107 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use crate::RepoCommitFilterResult;
use crate::RepoCommitModifierFlags;
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
use crate::RepoDevInoCache;
use crate::SePolicy;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
use glib::object::IsA;
use glib::translate::*;
use std::boxed::Box as Box_;
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
use std::ptr;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RepoCommitModifier(Shared<ffi::OstreeRepoCommitModifier>);
match fn {
ref => |ptr| ffi::ostree_repo_commit_modifier_ref(ptr),
unref => |ptr| ffi::ostree_repo_commit_modifier_unref(ptr),
type_ => || ffi::ostree_repo_commit_modifier_get_type(),
}
}
impl RepoCommitModifier {
#[doc(alias = "ostree_repo_commit_modifier_new")]
pub fn new(flags: RepoCommitModifierFlags, commit_filter: Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>) -> RepoCommitModifier {
let commit_filter_data: Box_<Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>> = Box_::new(commit_filter);
unsafe extern "C" fn commit_filter_func(repo: *mut ffi::OstreeRepo, path: *const libc::c_char, file_info: *mut gio::ffi::GFileInfo, user_data: glib::ffi::gpointer) -> ffi::OstreeRepoCommitFilterResult {
let repo = from_glib_borrow(repo);
let path: Borrowed<glib::GString> = from_glib_borrow(path);
let file_info = from_glib_borrow(file_info);
let callback: &Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>> = &*(user_data as *mut _);
let res = if let Some(ref callback) = *callback {
callback(&repo, path.as_str(), &file_info)
} else {
panic!("cannot get closure...")
};
res.into_glib()
}
let commit_filter = if commit_filter_data.is_some() { Some(commit_filter_func as _) } else { None };
unsafe extern "C" fn destroy_notify_func(data: glib::ffi::gpointer) {
let _callback: Box_<Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>> = Box_::from_raw(data as *mut _);
}
let destroy_call3 = Some(destroy_notify_func as _);
let super_callback0: Box_<Option<Box_<dyn Fn(&Repo, &str, &gio::FileInfo) -> RepoCommitFilterResult + 'static>>> = commit_filter_data;
unsafe {
from_glib_full(ffi::ostree_repo_commit_modifier_new(flags.into_glib(), commit_filter, Box_::into_raw(super_callback0) as *mut _, destroy_call3))
}
}
#[cfg(any(feature = "v2017_13", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_13")))]
#[doc(alias = "ostree_repo_commit_modifier_set_devino_cache")]
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);
}
}
#[doc(alias = "ostree_repo_commit_modifier_set_sepolicy")]
pub fn set_sepolicy(&self, sepolicy: Option<&SePolicy>) {
unsafe {
ffi::ostree_repo_commit_modifier_set_sepolicy(self.to_glib_none().0, sepolicy.to_glib_none().0);
}
}
#[cfg(any(feature = "v2020_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_4")))]
#[doc(alias = "ostree_repo_commit_modifier_set_sepolicy_from_commit")]
pub fn set_sepolicy_from_commit<P: IsA<gio::Cancellable>>(&self, repo: &Repo, rev: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_commit_modifier_set_sepolicy_from_commit(self.to_glib_none().0, repo.to_glib_none().0, rev.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)) }
}
}
#[doc(alias = "ostree_repo_commit_modifier_set_xattr_callback")]
pub fn set_xattr_callback<P: Fn(&Repo, &str, &gio::FileInfo) -> glib::Variant + 'static>(&self, callback: P) {
let callback_data: Box_<P> = Box_::new(callback);
unsafe extern "C" fn callback_func<P: Fn(&Repo, &str, &gio::FileInfo) -> glib::Variant + 'static>(repo: *mut ffi::OstreeRepo, path: *const libc::c_char, file_info: *mut gio::ffi::GFileInfo, user_data: glib::ffi::gpointer) -> *mut glib::ffi::GVariant {
let repo = from_glib_borrow(repo);
let path: Borrowed<glib::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::<P> as _);
unsafe extern "C" fn destroy_func<P: Fn(&Repo, &str, &gio::FileInfo) -> glib::Variant + 'static>(data: glib::ffi::gpointer) {
let _callback: Box_<P> = Box_::from_raw(data as *mut _);
}
let destroy_call2 = Some(destroy_func::<P> as _);
let super_callback0: Box_<P> = callback_data;
unsafe {
ffi::ostree_repo_commit_modifier_set_xattr_callback(self.to_glib_none().0, callback, destroy_call2, Box_::into_raw(super_callback0) as *mut _);
}
}
}
+31
View File
@@ -0,0 +1,31 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RepoDevInoCache(Shared<ffi::OstreeRepoDevInoCache>);
match fn {
ref => |ptr| ffi::ostree_repo_devino_cache_ref(ptr),
unref => |ptr| ffi::ostree_repo_devino_cache_unref(ptr),
type_ => || ffi::ostree_repo_devino_cache_get_type(),
}
}
impl RepoDevInoCache {
#[doc(alias = "ostree_repo_devino_cache_new")]
pub fn new() -> RepoDevInoCache {
unsafe {
from_glib_full(ffi::ostree_repo_devino_cache_new())
}
}
}
impl Default for RepoDevInoCache {
fn default() -> Self {
Self::new()
}
}
+127
View File
@@ -0,0 +1,127 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::mem;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeRepoFile")]
pub struct RepoFile(Object<ffi::OstreeRepoFile, ffi::OstreeRepoFileClass>) @implements gio::File;
match fn {
type_ => || ffi::ostree_repo_file_get_type(),
}
}
impl RepoFile {
#[doc(alias = "ostree_repo_file_ensure_resolved")]
pub fn ensure_resolved(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_file_ensure_resolved(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_repo_file_get_checksum")]
#[doc(alias = "get_checksum")]
pub fn checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_checksum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_get_repo")]
#[doc(alias = "get_repo")]
pub fn repo(&self) -> Option<Repo> {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_repo(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_get_root")]
#[doc(alias = "get_root")]
pub fn root(&self) -> Option<RepoFile> {
unsafe {
from_glib_none(ffi::ostree_repo_file_get_root(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_get_xattrs")]
#[doc(alias = "get_xattrs")]
pub fn xattrs<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<glib::Variant, glib::Error> {
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.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)) }
}
}
#[doc(alias = "ostree_repo_file_tree_find_child")]
pub fn tree_find_child(&self, name: &str) -> (i32, bool, glib::Variant) {
unsafe {
let mut is_dir = mem::MaybeUninit::uninit();
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, is_dir.as_mut_ptr(), &mut out_container);
let is_dir = is_dir.assume_init();
(ret, from_glib(is_dir), from_glib_full(out_container))
}
}
#[doc(alias = "ostree_repo_file_tree_get_contents")]
pub fn tree_get_contents(&self) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_repo_file_tree_get_contents(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_contents_checksum")]
pub fn tree_get_contents_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_repo_file_tree_get_contents_checksum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_metadata")]
pub fn tree_get_metadata(&self) -> Option<glib::Variant> {
unsafe {
from_glib_full(ffi::ostree_repo_file_tree_get_metadata(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_get_metadata_checksum")]
pub fn tree_get_metadata_checksum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_repo_file_tree_get_metadata_checksum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_file_tree_query_child")]
pub fn tree_query_child<P: IsA<gio::Cancellable>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: Option<&P>) -> Result<gio::FileInfo, glib::Error> {
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.into_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)) }
}
}
#[doc(alias = "ostree_repo_file_tree_set_metadata")]
pub 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);
}
}
}
impl fmt::Display for RepoFile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFile")
}
}
+32
View File
@@ -0,0 +1,32 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinderResult;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinder")]
pub struct RepoFinder(Interface<ffi::OstreeRepoFinder, ffi::OstreeRepoFinderInterface>);
match fn {
type_ => || ffi::ostree_repo_finder_get_type(),
}
}
impl RepoFinder {}
pub const NONE_REPO_FINDER: Option<&RepoFinder> = None;
pub trait RepoFinderExt: 'static {}
impl<O: IsA<RepoFinder>> RepoFinderExt for O {}
impl fmt::Display for RepoFinder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinder")
}
}
+48
View File
@@ -0,0 +1,48 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderAvahi")]
pub struct RepoFinderAvahi(Object<ffi::OstreeRepoFinderAvahi, ffi::OstreeRepoFinderAvahiClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_avahi_get_type(),
}
}
impl RepoFinderAvahi {
#[doc(alias = "ostree_repo_finder_avahi_new")]
pub fn new(context: Option<&glib::MainContext>) -> RepoFinderAvahi {
unsafe {
from_glib_full(ffi::ostree_repo_finder_avahi_new(context.to_glib_none().0))
}
}
#[doc(alias = "ostree_repo_finder_avahi_start")]
pub fn start(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_repo_finder_avahi_start(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_repo_finder_avahi_stop")]
pub fn stop(&self) {
unsafe {
ffi::ostree_repo_finder_avahi_stop(self.to_glib_none().0);
}
}
}
impl fmt::Display for RepoFinderAvahi {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderAvahi")
}
}
+39
View File
@@ -0,0 +1,39 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderConfig")]
pub struct RepoFinderConfig(Object<ffi::OstreeRepoFinderConfig, ffi::OstreeRepoFinderConfigClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_config_get_type(),
}
}
impl RepoFinderConfig {
#[doc(alias = "ostree_repo_finder_config_new")]
pub fn new() -> RepoFinderConfig {
unsafe {
from_glib_full(ffi::ostree_repo_finder_config_new())
}
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
impl Default for RepoFinderConfig {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for RepoFinderConfig {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderConfig")
}
}
+44
View File
@@ -0,0 +1,44 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderMount")]
pub struct RepoFinderMount(Object<ffi::OstreeRepoFinderMount, ffi::OstreeRepoFinderMountClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_mount_get_type(),
}
}
impl RepoFinderMount {
#[doc(alias = "ostree_repo_finder_mount_new")]
pub fn new<P: IsA<gio::VolumeMonitor>>(monitor: Option<&P>) -> RepoFinderMount {
unsafe {
from_glib_full(ffi::ostree_repo_finder_mount_new(monitor.map(|p| p.as_ref()).to_glib_none().0))
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
pub fn monitor(&self) -> Option<gio::VolumeMonitor> {
unsafe {
let mut value = glib::Value::from_type(<gio::VolumeMonitor as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"monitor\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `monitor` getter")
}
}
}
impl fmt::Display for RepoFinderMount {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderMount")
}
}
+46
View File
@@ -0,0 +1,46 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::RepoFinder;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "OstreeRepoFinderOverride")]
pub struct RepoFinderOverride(Object<ffi::OstreeRepoFinderOverride, ffi::OstreeRepoFinderOverrideClass>) @implements RepoFinder;
match fn {
type_ => || ffi::ostree_repo_finder_override_get_type(),
}
}
impl RepoFinderOverride {
#[doc(alias = "ostree_repo_finder_override_new")]
pub fn new() -> RepoFinderOverride {
unsafe {
from_glib_full(ffi::ostree_repo_finder_override_new())
}
}
#[doc(alias = "ostree_repo_finder_override_add_uri")]
pub fn add_uri(&self, uri: &str) {
unsafe {
ffi::ostree_repo_finder_override_add_uri(self.to_glib_none().0, uri.to_glib_none().0);
}
}
}
#[cfg(any(feature = "v2018_6", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
impl Default for RepoFinderOverride {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for RepoFinderOverride {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RepoFinderOverride")
}
}
+54
View File
@@ -0,0 +1,54 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use std::cmp;
use glib::translate::ToGlibPtr;
glib::wrapper! {
#[derive(Debug, Hash)]
pub struct RepoFinderResult(Boxed<ffi::OstreeRepoFinderResult>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::ostree_repo_finder_result_get_type(), ptr as *mut _) as *mut ffi::OstreeRepoFinderResult,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::ostree_repo_finder_result_get_type(), ptr as *mut _),
type_ => || ffi::ostree_repo_finder_result_get_type(),
}
}
impl RepoFinderResult {
//#[doc(alias = "ostree_repo_finder_result_new")]
//pub fn new<P: IsA<RepoFinder>>(remote: &Remote, finder: &P, priority: i32, ref_to_checksum: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 28 }, ref_to_timestamp: /*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 1, id: 0 }/TypeId { ns_id: 0, id: 9 }, summary_last_modified: u64) -> RepoFinderResult {
// unsafe { TODO: call ffi:ostree_repo_finder_result_new() }
//}
#[doc(alias = "ostree_repo_finder_result_compare")]
fn compare(&self, b: &RepoFinderResult) -> i32 {
unsafe {
ffi::ostree_repo_finder_result_compare(self.to_glib_none().0, b.to_glib_none().0)
}
}
}
impl PartialEq for RepoFinderResult {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.compare(other) == 0
}
}
impl Eq for RepoFinderResult {}
impl PartialOrd for RepoFinderResult {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
self.compare(other).partial_cmp(&0)
}
}
impl Ord for RepoFinderResult {
#[inline]
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.compare(other).cmp(&0)
}
}
+126
View File
@@ -0,0 +1,126 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use crate::SePolicyRestoreconFlags;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSePolicy")]
pub struct SePolicy(Object<ffi::OstreeSePolicy>);
match fn {
type_ => || ffi::ostree_sepolicy_get_type(),
}
}
impl SePolicy {
#[doc(alias = "ostree_sepolicy_new")]
pub fn new<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(path: &P, cancellable: Option<&Q>) -> Result<SePolicy, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::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"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
#[doc(alias = "ostree_sepolicy_new_at")]
pub fn new_at<P: IsA<gio::Cancellable>>(rootfs_dfd: i32, cancellable: Option<&P>) -> Result<SePolicy, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::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)) }
}
}
#[doc(alias = "ostree_sepolicy_new_from_commit")]
#[doc(alias = "new_from_commit")]
pub fn from_commit<P: IsA<gio::Cancellable>>(repo: &Repo, rev: &str, cancellable: Option<&P>) -> Result<SePolicy, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sepolicy_new_from_commit(repo.to_glib_none().0, rev.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_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_5")))]
#[doc(alias = "ostree_sepolicy_get_csum")]
#[doc(alias = "get_csum")]
pub fn csum(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_csum(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sepolicy_get_label")]
#[doc(alias = "get_label")]
pub fn label<P: IsA<gio::Cancellable>>(&self, relpath: &str, unix_mode: u32, cancellable: Option<&P>) -> Result<glib::GString, glib::Error> {
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.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)) }
}
}
#[doc(alias = "ostree_sepolicy_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_name(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sepolicy_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> Option<gio::File> {
unsafe {
from_glib_none(ffi::ostree_sepolicy_get_path(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sepolicy_restorecon")]
pub fn restorecon<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, path: &str, info: Option<&gio::FileInfo>, target: &P, flags: SePolicyRestoreconFlags, cancellable: Option<&Q>) -> Result<glib::GString, glib::Error> {
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.to_glib_none().0, target.as_ref().to_glib_none().0, flags.into_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)) }
}
}
#[doc(alias = "ostree_sepolicy_setfscreatecon")]
pub fn setfscreatecon(&self, path: &str, mode: u32) -> Result<(), glib::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);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "rootfs-dfd")]
pub fn rootfs_dfd(&self) -> i32 {
unsafe {
let mut value = glib::Value::from_type(<i32 as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"rootfs-dfd\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `rootfs-dfd` getter")
}
}
}
unsafe impl Send for SePolicy {}
impl fmt::Display for SePolicy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("SePolicy")
}
}
+191
View File
@@ -0,0 +1,191 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Repo;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSign")]
pub struct Sign(Interface<ffi::OstreeSign, ffi::OstreeSignInterface>);
match fn {
type_ => || ffi::ostree_sign_get_type(),
}
}
impl Sign {
#[doc(alias = "ostree_sign_get_all")]
#[doc(alias = "get_all")]
pub fn all() -> Vec<Sign> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::ostree_sign_get_all())
}
}
#[doc(alias = "ostree_sign_get_by_name")]
#[doc(alias = "get_by_name")]
pub fn by_name(name: &str) -> Result<Sign, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sign_get_by_name(name.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
}
pub const NONE_SIGN: Option<&Sign> = None;
pub trait SignExt: 'static {
#[doc(alias = "ostree_sign_add_pk")]
fn add_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_clear_keys")]
fn clear_keys(&self) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_commit")]
fn commit<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_commit_verify")]
fn commit_verify<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<Option<glib::GString>, glib::Error>;
#[doc(alias = "ostree_sign_data")]
fn data<P: IsA<gio::Cancellable>>(&self, data: &glib::Bytes, cancellable: Option<&P>) -> Result<glib::Bytes, glib::Error>;
#[doc(alias = "ostree_sign_data_verify")]
fn data_verify(&self, data: &glib::Bytes, signatures: &glib::Variant) -> Result<Option<glib::GString>, glib::Error>;
#[doc(alias = "ostree_sign_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> Option<glib::GString>;
#[doc(alias = "ostree_sign_load_pk")]
fn load_pk(&self, options: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_metadata_format")]
fn metadata_format(&self) -> Option<glib::GString>;
#[doc(alias = "ostree_sign_metadata_key")]
fn metadata_key(&self) -> Option<glib::GString>;
#[doc(alias = "ostree_sign_set_pk")]
fn set_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_set_sk")]
fn set_sk(&self, secret_key: &glib::Variant) -> Result<(), glib::Error>;
#[doc(alias = "ostree_sign_summary")]
fn summary<P: IsA<gio::Cancellable>>(&self, repo: &Repo, keys: &glib::Variant, cancellable: Option<&P>) -> Result<(), glib::Error>;
}
impl<O: IsA<Sign>> SignExt for O {
fn add_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_add_pk(self.as_ref().to_glib_none().0, public_key.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn clear_keys(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_clear_keys(self.as_ref().to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn commit<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_commit(self.as_ref().to_glib_none().0, repo.to_glib_none().0, commit_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)) }
}
}
fn commit_verify<P: IsA<gio::Cancellable>>(&self, repo: &Repo, commit_checksum: &str, cancellable: Option<&P>) -> Result<Option<glib::GString>, glib::Error> {
unsafe {
let mut out_success_message = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_commit_verify(self.as_ref().to_glib_none().0, repo.to_glib_none().0, commit_checksum.to_glib_none().0, &mut out_success_message, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_success_message)) } else { Err(from_glib_full(error)) }
}
}
fn data<P: IsA<gio::Cancellable>>(&self, data: &glib::Bytes, cancellable: Option<&P>) -> Result<glib::Bytes, glib::Error> {
unsafe {
let mut signature = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_data(self.as_ref().to_glib_none().0, data.to_glib_none().0, &mut signature, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(signature)) } else { Err(from_glib_full(error)) }
}
}
fn data_verify(&self, data: &glib::Bytes, signatures: &glib::Variant) -> Result<Option<glib::GString>, glib::Error> {
unsafe {
let mut out_success_message = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_data_verify(self.as_ref().to_glib_none().0, data.to_glib_none().0, signatures.to_glib_none().0, &mut out_success_message, &mut error);
if error.is_null() { Ok(from_glib_full(out_success_message)) } else { Err(from_glib_full(error)) }
}
}
fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sign_get_name(self.as_ref().to_glib_none().0))
}
}
fn load_pk(&self, options: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_load_pk(self.as_ref().to_glib_none().0, options.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn metadata_format(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sign_metadata_format(self.as_ref().to_glib_none().0))
}
}
fn metadata_key(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::ostree_sign_metadata_key(self.as_ref().to_glib_none().0))
}
}
fn set_pk(&self, public_key: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_set_pk(self.as_ref().to_glib_none().0, public_key.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn set_sk(&self, secret_key: &glib::Variant) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_set_sk(self.as_ref().to_glib_none().0, secret_key.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn summary<P: IsA<gio::Cancellable>>(&self, repo: &Repo, keys: &glib::Variant, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sign_summary(self.as_ref().to_glib_none().0, repo.to_glib_none().0, keys.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)) }
}
}
}
impl fmt::Display for Sign {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Sign")
}
}
+509
View File
@@ -0,0 +1,509 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::Deployment;
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
use crate::DeploymentUnlockedState;
#[cfg(any(feature = "v2017_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
use crate::Repo;
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
use crate::SysrootDeployTreeOpts;
use crate::SysrootSimpleWriteDeploymentFlags;
#[cfg(any(feature = "v2017_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
use crate::SysrootWriteDeploymentsOpts;
use glib::object::IsA;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use glib::object::ObjectType as ObjectType_;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use glib::signal::connect_raw;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use glib::signal::SignalHandlerId;
use glib::translate::*;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem;
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
use std::mem::transmute;
use std::pin::Pin;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSysroot")]
pub struct Sysroot(Object<ffi::OstreeSysroot>);
match fn {
type_ => || ffi::ostree_sysroot_get_type(),
}
}
impl Sysroot {
#[doc(alias = "ostree_sysroot_new")]
pub fn new<P: IsA<gio::File>>(path: Option<&P>) -> Sysroot {
unsafe {
from_glib_full(ffi::ostree_sysroot_new(path.map(|p| p.as_ref()).to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_new_default")]
pub fn new_default() -> Sysroot {
unsafe {
from_glib_full(ffi::ostree_sysroot_new_default())
}
}
#[doc(alias = "ostree_sysroot_cleanup")]
pub fn cleanup<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_6")))]
//#[doc(alias = "ostree_sysroot_cleanup_prune_repo")]
//pub fn cleanup_prune_repo<P: IsA<gio::Cancellable>>(&self, options: /*Ignored*/&mut RepoPruneOptions, cancellable: Option<&P>) -> Result<(i32, i32, u64), glib::Error> {
// unsafe { TODO: call ffi:ostree_sysroot_cleanup_prune_repo() }
//}
#[cfg(any(feature = "v2018_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_5")))]
#[doc(alias = "ostree_sysroot_deploy_tree")]
pub fn deploy_tree<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, provided_merge_deployment: Option<&Deployment>, override_kernel_argv: &[&str], cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
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.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)) }
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_sysroot_deploy_tree_with_options")]
pub fn deploy_tree_with_options<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, provided_merge_deployment: Option<&Deployment>, opts: Option<&SysrootDeployTreeOpts>, cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
unsafe {
let mut out_new_deployment = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_deploy_tree_with_options(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, mut_override(opts.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)) }
}
}
#[doc(alias = "ostree_sysroot_deployment_set_kargs")]
pub fn deployment_set_kargs<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, new_kargs: &[&str], cancellable: Option<&P>) -> Result<(), glib::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.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_deployment_set_mutable")]
pub fn deployment_set_mutable<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, is_mutable: bool, cancellable: Option<&P>) -> Result<(), glib::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.into_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"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_3")))]
#[doc(alias = "ostree_sysroot_deployment_set_pinned")]
pub fn deployment_set_pinned(&self, deployment: &Deployment, is_pinned: bool) -> Result<(), glib::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.into_glib(), &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_sysroot_deployment_unlock")]
pub fn deployment_unlock<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, unlocked_state: DeploymentUnlockedState, cancellable: Option<&P>) -> Result<(), glib::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.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_ensure_initialized")]
pub fn ensure_initialized<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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)) }
}
}
#[doc(alias = "ostree_sysroot_get_booted_deployment")]
#[doc(alias = "get_booted_deployment")]
pub fn booted_deployment(&self) -> Option<Deployment> {
unsafe {
from_glib_none(ffi::ostree_sysroot_get_booted_deployment(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_bootversion")]
#[doc(alias = "get_bootversion")]
pub fn bootversion(&self) -> i32 {
unsafe {
ffi::ostree_sysroot_get_bootversion(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_sysroot_get_deployment_directory")]
#[doc(alias = "get_deployment_directory")]
pub fn deployment_directory(&self, deployment: &Deployment) -> Option<gio::File> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_directory(self.to_glib_none().0, deployment.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_deployment_dirpath")]
#[doc(alias = "get_deployment_dirpath")]
pub fn deployment_dirpath(&self, deployment: &Deployment) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_dirpath(self.to_glib_none().0, deployment.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_deployments")]
#[doc(alias = "get_deployments")]
pub fn deployments(&self) -> Vec<Deployment> {
unsafe {
FromGlibPtrContainer::from_glib_container(ffi::ostree_sysroot_get_deployments(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_fd")]
#[doc(alias = "get_fd")]
pub fn fd(&self) -> i32 {
unsafe {
ffi::ostree_sysroot_get_fd(self.to_glib_none().0)
}
}
#[doc(alias = "ostree_sysroot_get_merge_deployment")]
#[doc(alias = "get_merge_deployment")]
pub fn merge_deployment(&self, osname: Option<&str>) -> Option<Deployment> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_merge_deployment(self.to_glib_none().0, osname.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> Option<gio::File> {
unsafe {
from_glib_none(ffi::ostree_sysroot_get_path(self.to_glib_none().0))
}
}
#[cfg(any(feature = "v2018_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_5")))]
#[doc(alias = "ostree_sysroot_get_staged_deployment")]
#[doc(alias = "get_staged_deployment")]
pub fn staged_deployment(&self) -> Option<Deployment> {
unsafe {
from_glib_none(ffi::ostree_sysroot_get_staged_deployment(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_get_subbootversion")]
#[doc(alias = "get_subbootversion")]
pub fn subbootversion(&self) -> i32 {
unsafe {
ffi::ostree_sysroot_get_subbootversion(self.to_glib_none().0)
}
}
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_sysroot_init_osname")]
pub fn init_osname<P: IsA<gio::Cancellable>>(&self, osname: &str, cancellable: Option<&P>) -> Result<(), glib::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.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 = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_sysroot_initialize")]
pub fn initialize(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_initialize(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_sysroot_is_booted")]
pub fn is_booted(&self) -> bool {
unsafe {
from_glib(ffi::ostree_sysroot_is_booted(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_load")]
pub fn load<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
#[doc(alias = "ostree_sysroot_load_if_changed")]
pub fn load_if_changed<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<bool, glib::Error> {
unsafe {
let mut out_changed = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_load_if_changed(self.to_glib_none().0, out_changed.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_changed = out_changed.assume_init();
if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_lock")]
pub fn lock(&self) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_lock(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_lock_async")]
pub fn lock_async<P: IsA<gio::Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, cancellable: Option<&P>, callback: Q) {
let user_data: Box_<Q> = Box_::new(callback);
unsafe extern "C" fn lock_async_trampoline<Q: FnOnce(Result<(), glib::Error>) + Send + 'static>(_source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer) {
let mut error = ptr::null_mut();
let _ = ffi::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_<Q> = Box_::from_raw(user_data as *mut _);
callback(result);
}
let callback = lock_async_trampoline::<Q>;
unsafe {
ffi::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 _);
}
}
pub fn lock_async_future(&self) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.lock_async(
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
#[doc(alias = "ostree_sysroot_origin_new_from_refspec")]
pub fn origin_new_from_refspec(&self, refspec: &str) -> Option<glib::KeyFile> {
unsafe {
from_glib_full(ffi::ostree_sysroot_origin_new_from_refspec(self.to_glib_none().0, refspec.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_prepare_cleanup")]
pub fn prepare_cleanup<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "ostree_sysroot_query_deployments_for")]
pub fn query_deployments_for(&self, osname: Option<&str>) -> (Option<Deployment>, Option<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.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"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_7")))]
#[doc(alias = "ostree_sysroot_repo")]
pub fn repo(&self) -> Option<Repo> {
unsafe {
from_glib_none(ffi::ostree_sysroot_repo(self.to_glib_none().0))
}
}
#[cfg(any(feature = "v2021_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2021_1")))]
#[doc(alias = "ostree_sysroot_require_booted_deployment")]
pub fn require_booted_deployment(&self) -> Result<Deployment, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sysroot_require_booted_deployment(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
#[doc(alias = "ostree_sysroot_set_mount_namespace_in_use")]
pub fn set_mount_namespace_in_use(&self) {
unsafe {
ffi::ostree_sysroot_set_mount_namespace_in_use(self.to_glib_none().0);
}
}
#[doc(alias = "ostree_sysroot_simple_write_deployment")]
pub fn simple_write_deployment<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, new_deployment: &Deployment, merge_deployment: Option<&Deployment>, flags: SysrootSimpleWriteDeploymentFlags, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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.into_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 = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_sysroot_stage_overlay_initrd")]
pub fn stage_overlay_initrd<P: IsA<gio::Cancellable>>(&self, fd: i32, cancellable: Option<&P>) -> Result<glib::GString, glib::Error> {
unsafe {
let mut out_checksum = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_stage_overlay_initrd(self.to_glib_none().0, fd, &mut out_checksum, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(out_checksum)) } else { Err(from_glib_full(error)) }
}
}
#[cfg(any(feature = "v2018_5", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2018_5")))]
#[doc(alias = "ostree_sysroot_stage_tree")]
pub fn stage_tree<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, merge_deployment: Option<&Deployment>, override_kernel_argv: &[&str], cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
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.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)) }
}
}
#[cfg(any(feature = "v2020_7", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_7")))]
#[doc(alias = "ostree_sysroot_stage_tree_with_options")]
pub fn stage_tree_with_options<P: IsA<gio::Cancellable>>(&self, osname: Option<&str>, revision: &str, origin: Option<&glib::KeyFile>, merge_deployment: Option<&Deployment>, opts: &SysrootDeployTreeOpts, cancellable: Option<&P>) -> Result<Deployment, glib::Error> {
unsafe {
let mut out_new_deployment = ptr::null_mut();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_stage_tree_with_options(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, mut_override(opts.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)) }
}
}
#[doc(alias = "ostree_sysroot_try_lock")]
pub fn try_lock(&self) -> Result<bool, glib::Error> {
unsafe {
let mut out_acquired = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_try_lock(self.to_glib_none().0, out_acquired.as_mut_ptr(), &mut error);
let out_acquired = out_acquired.assume_init();
if error.is_null() { Ok(from_glib(out_acquired)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_unload")]
pub fn unload(&self) {
unsafe {
ffi::ostree_sysroot_unload(self.to_glib_none().0);
}
}
#[doc(alias = "ostree_sysroot_unlock")]
pub fn unlock(&self) {
unsafe {
ffi::ostree_sysroot_unlock(self.to_glib_none().0);
}
}
#[doc(alias = "ostree_sysroot_write_deployments")]
pub fn write_deployments<P: IsA<gio::Cancellable>>(&self, new_deployments: &[Deployment], cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_write_deployments(self.to_glib_none().0, new_deployments.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_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_4")))]
#[doc(alias = "ostree_sysroot_write_deployments_with_options")]
pub fn write_deployments_with_options<P: IsA<gio::Cancellable>>(&self, new_deployments: &[Deployment], opts: &SysrootWriteDeploymentsOpts, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_write_deployments_with_options(self.to_glib_none().0, new_deployments.to_glib_none().0, mut_override(opts.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)) }
}
}
#[doc(alias = "ostree_sysroot_write_origin_file")]
pub fn write_origin_file<P: IsA<gio::Cancellable>>(&self, deployment: &Deployment, new_origin: Option<&glib::KeyFile>, cancellable: Option<&P>) -> Result<(), glib::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.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)) }
}
}
#[doc(alias = "ostree_sysroot_get_deployment_origin_path")]
#[doc(alias = "get_deployment_origin_path")]
pub fn deployment_origin_path<P: IsA<gio::File>>(deployment_path: &P) -> Option<gio::File> {
unsafe {
from_glib_full(ffi::ostree_sysroot_get_deployment_origin_path(deployment_path.as_ref().to_glib_none().0))
}
}
#[cfg(any(feature = "v2017_10", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2017_10")))]
#[doc(alias = "journal-msg")]
pub fn connect_journal_msg<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn journal_msg_trampoline<F: Fn(&Sysroot, &str) + 'static>(this: *mut ffi::OstreeSysroot, msg: *mut libc::c_char, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &glib::GString::from_glib_borrow(msg))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"journal-msg\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(journal_msg_trampoline::<F> as *const ())), Box_::into_raw(f))
}
}
}
impl fmt::Display for Sysroot {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Sysroot")
}
}
+159
View File
@@ -0,0 +1,159 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT
use crate::AsyncProgress;
use crate::Repo;
use crate::RepoPullFlags;
use crate::Sysroot;
use crate::SysrootUpgraderFlags;
use crate::SysrootUpgraderPullFlags;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use std::fmt;
use std::mem;
use std::ptr;
glib::wrapper! {
#[doc(alias = "OstreeSysrootUpgrader")]
pub struct SysrootUpgrader(Object<ffi::OstreeSysrootUpgrader>);
match fn {
type_ => || ffi::ostree_sysroot_upgrader_get_type(),
}
}
impl SysrootUpgrader {
#[doc(alias = "ostree_sysroot_upgrader_new")]
pub fn new<P: IsA<gio::Cancellable>>(sysroot: &Sysroot, cancellable: Option<&P>) -> Result<SysrootUpgrader, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::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)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_new_for_os")]
#[doc(alias = "new_for_os")]
pub fn for_os<P: IsA<gio::Cancellable>>(sysroot: &Sysroot, osname: Option<&str>, cancellable: Option<&P>) -> Result<SysrootUpgrader, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::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)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_new_for_os_with_flags")]
#[doc(alias = "new_for_os_with_flags")]
pub fn for_os_with_flags<P: IsA<gio::Cancellable>>(sysroot: &Sysroot, osname: Option<&str>, flags: SysrootUpgraderFlags, cancellable: Option<&P>) -> Result<SysrootUpgrader, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::ostree_sysroot_upgrader_new_for_os_with_flags(sysroot.to_glib_none().0, osname.to_glib_none().0, flags.into_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)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_deploy")]
pub fn deploy<P: IsA<gio::Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_dup_origin")]
pub fn dup_origin(&self) -> Option<glib::KeyFile> {
unsafe {
from_glib_full(ffi::ostree_sysroot_upgrader_dup_origin(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_upgrader_get_origin")]
#[doc(alias = "get_origin")]
pub fn origin(&self) -> Option<glib::KeyFile> {
unsafe {
from_glib_none(ffi::ostree_sysroot_upgrader_get_origin(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_upgrader_get_origin_description")]
#[doc(alias = "get_origin_description")]
pub fn origin_description(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::ostree_sysroot_upgrader_get_origin_description(self.to_glib_none().0))
}
}
#[doc(alias = "ostree_sysroot_upgrader_pull")]
pub fn pull<P: IsA<gio::Cancellable>>(&self, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: Option<&AsyncProgress>, cancellable: Option<&P>) -> Result<bool, glib::Error> {
unsafe {
let mut out_changed = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let _ = ffi::ostree_sysroot_upgrader_pull(self.to_glib_none().0, flags.into_glib(), upgrader_flags.into_glib(), progress.to_glib_none().0, out_changed.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_changed = out_changed.assume_init();
if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_pull_one_dir")]
pub fn pull_one_dir<P: IsA<gio::Cancellable>>(&self, dir_to_pull: &str, flags: RepoPullFlags, upgrader_flags: SysrootUpgraderPullFlags, progress: Option<&AsyncProgress>, cancellable: Option<&P>) -> Result<bool, glib::Error> {
unsafe {
let mut out_changed = mem::MaybeUninit::uninit();
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.into_glib(), upgrader_flags.into_glib(), progress.to_glib_none().0, out_changed.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
let out_changed = out_changed.assume_init();
if error.is_null() { Ok(from_glib(out_changed)) } else { Err(from_glib_full(error)) }
}
}
#[doc(alias = "ostree_sysroot_upgrader_set_origin")]
pub fn set_origin<P: IsA<gio::Cancellable>>(&self, origin: Option<&glib::KeyFile>, cancellable: Option<&P>) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::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 flags(&self) -> SysrootUpgraderFlags {
unsafe {
let mut value = glib::Value::from_type(<SysrootUpgraderFlags as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"flags\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `flags` getter")
}
}
pub fn osname(&self) -> Option<glib::GString> {
unsafe {
let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"osname\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `osname` getter")
}
}
pub fn sysroot(&self) -> Option<Sysroot> {
unsafe {
let mut value = glib::Value::from_type(<Sysroot as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(self.as_ptr() as *mut glib::gobject_ffi::GObject, b"sysroot\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().expect("Return Value for property `sysroot` getter")
}
}
#[doc(alias = "ostree_sysroot_upgrader_check_timestamps")]
pub fn check_timestamps(repo: &Repo, from_rev: &str, to_rev: &str) -> Result<(), glib::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);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}
impl fmt::Display for SysrootUpgrader {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("SysrootUpgrader")
}
}
+2
View File
@@ -0,0 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e8f82cf6)
from gir-files
+245
View File
@@ -0,0 +1,245 @@
use glib::ffi::{g_free, g_malloc0, gpointer};
use glib::translate::{FromGlibPtrFull, FromGlibPtrNone};
use once_cell::sync::OnceCell;
use std::ptr::copy_nonoverlapping;
const BYTES_LEN: usize = ffi::OSTREE_SHA256_DIGEST_LEN as usize;
static BASE64_CONFIG: OnceCell<radix64::CustomConfig> = OnceCell::new();
fn base64_config() -> &'static radix64::CustomConfig {
BASE64_CONFIG.get_or_init(|| {
radix64::configs::CustomConfigBuilder::with_alphabet(
// modified base64 alphabet used by ostree (uses _ instead of /)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_",
)
.no_padding()
.build()
.unwrap()
})
}
/// Error returned from parsing a checksum.
#[derive(Debug, thiserror::Error)]
pub enum ChecksumError {
/// Invalid hex checksum string.
#[error("invalid hex checksum string")]
InvalidHexString,
/// Invalid base64 checksum string
#[error("invalid base64 checksum string")]
InvalidBase64String,
}
/// A binary SHA256 checksum.
#[derive(Debug)]
pub struct Checksum {
bytes: *mut [u8; BYTES_LEN],
}
// Safety: just a pointer to some memory owned by the type itself.
unsafe impl Send for Checksum {}
impl Checksum {
/// Create a `Checksum` from a byte array.
///
/// This copies the array.
pub fn from_bytes(bytes: &[u8; BYTES_LEN]) -> Checksum {
let mut checksum = Checksum::zeroed();
checksum.as_mut().copy_from_slice(bytes);
checksum
}
/// Create a `Checksum` from a hexadecimal SHA256 string.
pub fn from_hex(hex_checksum: &str) -> Result<Checksum, ChecksumError> {
let mut checksum = Checksum::zeroed();
match hex::decode_to_slice(hex_checksum, checksum.as_mut()) {
Ok(_) => Ok(checksum),
Err(_) => Err(ChecksumError::InvalidHexString),
}
}
/// Create a `Checksum` from a base64-encoded String.
pub fn from_base64(b64_checksum: &str) -> Result<Checksum, ChecksumError> {
let mut checksum = Checksum::zeroed();
match base64_config().decode_slice(b64_checksum, checksum.as_mut()) {
Ok(BYTES_LEN) => Ok(checksum),
Ok(_) => Err(ChecksumError::InvalidBase64String),
Err(_) => Err(ChecksumError::InvalidBase64String),
}
}
/// Convert checksum to hex-encoded string.
pub fn to_hex(&self) -> String {
hex::encode(self.as_slice())
}
/// Convert checksum to base64 string.
pub fn to_base64(&self) -> String {
base64_config().encode(self.as_slice())
}
/// Create a `Checksum` value, taking ownership of the given memory location.
///
/// # Safety
/// `bytes` must point to an initialized 32-byte memory location that is freeable with
/// `g_free` (this is e.g. the case if the memory was allocated with `g_malloc`). The returned
/// value takes ownership of the memory and frees it on drop.
unsafe fn new(bytes: *mut [u8; BYTES_LEN]) -> Checksum {
assert!(!bytes.is_null());
Checksum { bytes }
}
/// Create a `Checksum` value initialized to 0.
fn zeroed() -> Checksum {
let bytes = unsafe { g_malloc0(BYTES_LEN) as *mut [u8; BYTES_LEN] };
Checksum { bytes }
}
/// Get a shared reference to the inner array.
fn as_slice(&self) -> &[u8; BYTES_LEN] {
unsafe { &(*self.bytes) }
}
/// Get a mutable reference to the inner array.
fn as_mut(&mut self) -> &mut [u8; BYTES_LEN] {
unsafe { &mut (*self.bytes) }
}
}
impl Drop for Checksum {
fn drop(&mut self) {
unsafe {
g_free(self.bytes as gpointer);
}
}
}
impl Clone for Checksum {
fn clone(&self) -> Self {
unsafe { Checksum::from_glib_none(self.bytes) }
}
}
impl PartialEq for Checksum {
fn eq(&self, other: &Self) -> bool {
unsafe {
let ret =
ffi::ostree_cmp_checksum_bytes(self.bytes as *const u8, other.bytes as *const u8);
ret == 0
}
}
}
impl Eq for Checksum {}
impl std::fmt::Display for Checksum {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.to_hex())
}
}
impl FromGlibPtrFull<*mut [u8; BYTES_LEN]> for Checksum {
unsafe fn from_glib_full(ptr: *mut [u8; BYTES_LEN]) -> Self {
Checksum::new(ptr)
}
}
impl FromGlibPtrFull<*mut [*mut u8; BYTES_LEN]> for Checksum {
unsafe fn from_glib_full(ptr: *mut [*mut u8; BYTES_LEN]) -> Self {
Checksum::new(ptr as *mut u8 as *mut [u8; BYTES_LEN])
}
}
impl FromGlibPtrFull<*mut u8> for Checksum {
unsafe fn from_glib_full(ptr: *mut u8) -> Self {
Checksum::new(ptr as *mut [u8; BYTES_LEN])
}
}
impl FromGlibPtrNone<*mut [u8; BYTES_LEN]> for Checksum {
unsafe fn from_glib_none(ptr: *mut [u8; BYTES_LEN]) -> Self {
let checksum = Checksum::zeroed();
// copy one array of BYTES_LEN elements
copy_nonoverlapping(ptr, checksum.bytes, 1);
checksum
}
}
#[cfg(test)]
mod tests {
use super::*;
use glib::ffi::g_malloc0;
use glib::translate::from_glib_full;
const CHECKSUM_BYTES: &[u8; BYTES_LEN] = b"\xbf\x87S\x06x>\xfd\xc5\xbc\xab7\xea\x10\xb6\xcaN\x9bj\xea\x8b\x94X\r\x0c\xa9J\xf1 V\\\x0e\x8a";
const CHECKSUM_HEX: &str = "bf875306783efdc5bcab37ea10b6ca4e9b6aea8b94580d0ca94af120565c0e8a";
const CHECKSUM_BASE64: &str = "v4dTBng+_cW8qzfqELbKTptq6ouUWA0MqUrxIFZcDoo";
#[test]
fn should_create_checksum_from_bytes_taking_ownership() {
let bytes = unsafe { g_malloc0(BYTES_LEN) } as *mut u8;
let checksum: Checksum = unsafe { from_glib_full(bytes) };
assert_eq!(checksum.to_string(), "00".repeat(BYTES_LEN));
}
#[test]
fn should_create_checksum_from_bytes() {
let checksum = Checksum::from_bytes(CHECKSUM_BYTES);
assert_eq!(checksum.to_hex(), CHECKSUM_HEX);
}
#[test]
fn should_parse_checksum_string_to_bytes() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum.to_string(), CHECKSUM_HEX);
}
#[test]
fn should_fail_for_too_short_hex_string() {
let result = Checksum::from_hex(&"FF".repeat(31));
assert!(result.is_err());
}
#[test]
fn should_convert_checksum_to_base64() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum.to_base64(), CHECKSUM_BASE64);
}
#[test]
fn should_convert_base64_string_to_checksum() {
let csum = Checksum::from_base64(CHECKSUM_BASE64).unwrap();
assert_eq!(csum.to_base64(), CHECKSUM_BASE64);
assert_eq!(csum.to_string(), CHECKSUM_HEX);
}
#[test]
fn should_fail_for_too_short_b64_string() {
let result = Checksum::from_base64("abcdefghi");
assert!(result.is_err());
}
#[test]
fn should_fail_for_invalid_base64_string() {
let result = Checksum::from_base64(&"\n".repeat(43));
assert!(result.is_err());
}
#[test]
fn should_compare_checksums() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum, csum);
let csum2 = Checksum::from_hex(CHECKSUM_HEX).unwrap();
assert_eq!(csum2, csum);
}
#[test]
fn should_clone_value() {
let csum = Checksum::from_hex(CHECKSUM_HEX).unwrap();
let csum2 = csum.clone();
assert_eq!(csum2, csum);
let csum3 = csum2.clone();
assert_eq!(csum3, csum);
assert_eq!(csum3, csum2);
}
}
+78
View File
@@ -0,0 +1,78 @@
use crate::CollectionRef;
use glib::translate::ToGlibPtr;
use std::ffi::CStr;
trait AsNonnullPtr
where
Self: Sized,
{
fn as_nonnull_ptr(&self) -> Option<Self>;
}
impl<T> AsNonnullPtr for *mut T {
fn as_nonnull_ptr(&self) -> Option<Self> {
if self.is_null() {
None
} else {
Some(*self)
}
}
}
impl CollectionRef {
/// Get the collection ID from this `CollectionRef`.
///
/// # Returns
/// Since the value may not be valid UTF-8, `&CStr` is returned. You can safely turn it into a
/// `&str` using the `as_str` method.
///
/// If no collection ID was set in the `CollectionRef`, `None` is returned.
pub fn collection_id(&self) -> Option<&CStr> {
let inner = self.to_glib_none();
unsafe {
(*inner.0)
.collection_id
.as_nonnull_ptr()
.map(|ptr| CStr::from_ptr(ptr))
}
}
/// Get the ref name from this `CollectionRef`.
///
/// # Returns
/// Since the value may not be valid UTF-8, `&CStr` is returned. You can safely turn it into a
/// `&str` using the `as_str` method.
pub fn ref_name(&self) -> &CStr {
let inner = self.to_glib_none();
unsafe { CStr::from_ptr((*inner.0).ref_name) }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn should_get_collection_id() {
let collection_ref = CollectionRef::new(Some("collection.id"), "ref").unwrap();
let id = collection_ref.collection_id().unwrap().to_str().unwrap();
assert_eq!(id, "collection.id");
}
#[test]
fn should_get_none_collection_id() {
let collection_ref = CollectionRef::new(None, "ref").unwrap();
let id = collection_ref.collection_id();
assert_eq!(id, None);
}
#[test]
fn should_get_ref_name() {
let collection_ref = CollectionRef::new(Some("collection.id"), "ref-name").unwrap();
let ref_name = collection_ref.ref_name().to_str().unwrap();
assert_eq!(ref_name, "ref-name");
}
}
+48
View File
@@ -0,0 +1,48 @@
use crate::{auto::CommitSizesEntry, auto::ObjectType};
use glib::{
translate::{FromGlib, FromGlibPtrNone, ToGlibPtr},
GString,
};
impl CommitSizesEntry {
/// Object checksum as hex string.
pub fn checksum(&self) -> GString {
let underlying = self.to_glib_none();
unsafe { GString::from_glib_none((*underlying.0).checksum) }
}
/// The object type.
pub fn objtype(&self) -> ObjectType {
let underlying = self.to_glib_none();
unsafe { ObjectType::from_glib((*underlying.0).objtype) }
}
/// Unpacked object size.
pub fn unpacked(&self) -> u64 {
let underlying = self.to_glib_none();
unsafe { (*underlying.0).unpacked }
}
/// Compressed object size.
pub fn archived(&self) -> u64 {
let underlying = self.to_glib_none();
unsafe { (*underlying.0).archived }
}
}
#[cfg(test)]
mod tests {
use super::*;
const CHECKSUM_STRING: &str =
"bf875306783efdc5bcab37ea10b6ca4e9b6aea8b94580d0ca94af120565c0e8a";
#[test]
fn should_get_values_from_commit_sizes_entry() {
let entry = CommitSizesEntry::new(CHECKSUM_STRING, ObjectType::Commit, 15, 16).unwrap();
assert_eq!(entry.checksum(), CHECKSUM_STRING);
assert_eq!(entry.objtype(), ObjectType::Commit);
assert_eq!(entry.unpacked(), 15);
assert_eq!(entry.archived(), 16);
}
}
+3
View File
@@ -0,0 +1,3 @@
/// Metadata key corresponding to the Docker/OCI `CMD` verb.
/// <https://github.com/opencontainers/image-spec/blob/main/config.md>
pub const COMMIT_META_CONTAINER_CMD: &str = "ostree.container-cmd";
+48
View File
@@ -0,0 +1,48 @@
//! Hand written bindings for ostree-core.h
use glib::VariantDict;
/// The type of a commit object: `(a{sv}aya(say)sstayay)`
pub type CommitVariantType = (
VariantDict,
Vec<u8>,
Vec<(String, Vec<u8>)>,
String,
String,
u64,
Vec<u8>,
Vec<u8>,
);
/// The type of a dirtree object: `(a(say)a(sayay))`
pub type TreeVariantType = (Vec<(String, Vec<u8>)>, Vec<(String, Vec<u8>, Vec<u8>)>);
/// The type of a directory metadata object: `(uuua(ayay))`
pub type DirmetaVariantType = (u32, u32, u32, Vec<(Vec<u8>, Vec<u8>)>);
/// Parsed representation of directory metadata.
pub struct DirMetaParsed {
/// The user ID.
pub uid: u32,
/// The group ID.
pub gid: u32,
/// The Unix mode, including file type flag.
pub mode: u32,
/// Extended attributes.
pub xattrs: Vec<(Vec<u8>, Vec<u8>)>,
}
impl DirMetaParsed {
/// Parse a directory metadata variant; must be of type `(uuua(ayay))`.
pub fn from_variant(
v: &glib::Variant,
) -> Result<DirMetaParsed, glib::variant::VariantTypeMismatchError> {
let (uid, gid, mode, xattrs) = v.try_get::<crate::DirmetaVariantType>()?;
Ok(DirMetaParsed {
uid: u32::from_be(uid),
gid: u32::from_be(gid),
mode: u32::from_be(mode),
xattrs,
})
}
}
+158
View File
@@ -0,0 +1,158 @@
#[cfg(any(feature = "v2017_13", feature = "dox"))]
use crate::ChecksumFlags;
use crate::{Checksum, ObjectType};
use glib::ffi::GFALSE;
use glib::{prelude::*, translate::*};
use std::{future::Future, mem::MaybeUninit, pin::Pin, ptr};
/// Compute the SHA-256 checksum of a file.
pub fn checksum_file<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(
f: &P,
objtype: ObjectType,
cancellable: Option<&Q>,
) -> Result<Checksum, Box<dyn std::error::Error>> {
unsafe {
let mut out_csum = ptr::null_mut();
let mut error = ptr::null_mut();
let ret = ffi::ostree_checksum_file(
f.as_ref().to_glib_none().0,
objtype.into_glib(),
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
checksum_file_error(out_csum, error, ret)
}
}
/// Asynchronously compute the SHA-256 checksum of a file.
pub fn checksum_file_async<
P: IsA<gio::File>,
Q: IsA<gio::Cancellable>,
R: FnOnce(Result<Checksum, Box<dyn std::error::Error>>) + Send + 'static,
>(
f: &P,
objtype: ObjectType,
io_priority: i32,
cancellable: Option<&Q>,
callback: R,
) {
let user_data: Box<R> = Box::new(callback);
unsafe extern "C" fn checksum_file_async_trampoline<
R: FnOnce(Result<Checksum, Box<dyn std::error::Error>>) + Send + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = ptr::null_mut();
let mut out_csum = MaybeUninit::uninit();
let ret = ffi::ostree_checksum_file_async_finish(
_source_object as *mut _,
res,
out_csum.as_mut_ptr(),
&mut error,
);
let out_csum = out_csum.assume_init();
let result = checksum_file_error(out_csum, error, ret);
let callback: Box<R> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = checksum_file_async_trampoline::<R>;
unsafe {
ffi::ostree_checksum_file_async(
f.as_ref().to_glib_none().0,
objtype.into_glib(),
io_priority,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box::into_raw(user_data) as *mut _,
);
}
}
/// Asynchronously compute the SHA-256 checksum of a file.
#[allow(clippy::type_complexity)]
pub fn checksum_file_async_future<P: IsA<gio::File> + Clone + 'static>(
f: &P,
objtype: ObjectType,
io_priority: i32,
) -> Pin<Box<dyn Future<Output = Result<Checksum, Box<dyn std::error::Error>>> + 'static>> {
let f = f.clone();
Box::pin(gio::GioFuture::new(&f, move |f, cancellable, send| {
checksum_file_async(f, objtype, io_priority, Some(cancellable), move |res| {
send.resolve(res);
});
}))
}
/// Compute the OSTree checksum of a content object.
pub fn checksum_file_from_input<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
file_info: &gio::FileInfo,
xattrs: Option<&glib::Variant>,
in_: Option<&P>,
objtype: ObjectType,
cancellable: Option<&Q>,
) -> Result<Checksum, Box<dyn std::error::Error>> {
unsafe {
let mut out_csum = ptr::null_mut();
let mut error = ptr::null_mut();
let ret = ffi::ostree_checksum_file_from_input(
file_info.to_glib_none().0,
xattrs.to_glib_none().0,
in_.map(|p| p.as_ref()).to_glib_none().0,
objtype.into_glib(),
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
checksum_file_error(out_csum, error, ret)
}
}
/// Compute the OSTree checksum of a file.
#[cfg(any(feature = "v2017_13", feature = "dox"))]
pub fn checksum_file_at<P: IsA<gio::Cancellable>>(
dfd: i32,
path: &std::path::Path,
stbuf: Option<&libc::stat>,
objtype: ObjectType,
flags: ChecksumFlags,
cancellable: Option<&P>,
) -> Result<glib::GString, glib::Error> {
unsafe {
let mut out_checksum = ptr::null_mut();
let mut error = ptr::null_mut();
ffi::ostree_checksum_file_at(
dfd,
path.to_glib_none().0,
stbuf
.map(|p| p as *const libc::stat as *mut libc::stat)
.unwrap_or(ptr::null_mut()),
objtype.into_glib(),
flags.into_glib(),
&mut out_checksum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(out_checksum))
} else {
Err(from_glib_full(error))
}
}
}
unsafe fn checksum_file_error(
out_csum: *mut [*mut u8; 32],
error: *mut glib::ffi::GError,
ret: i32,
) -> Result<Checksum, Box<dyn std::error::Error>> {
if !error.is_null() {
Err(Box::<glib::Error>::new(from_glib_full(error)))
} else if ret == GFALSE {
Err(Box::new(glib::bool_error!("unknown error")))
} else {
Ok(Checksum::from_glib_full(out_csum))
}
}
+228
View File
@@ -0,0 +1,228 @@
use ffi::OstreeKernelArgs;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
use glib::object::IsA;
use glib::translate::*;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
use glib::GString;
use std::fmt;
use std::ptr;
glib::wrapper! {
/// Kernel arguments.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct KernelArgs(Boxed<ffi::OstreeKernelArgs>);
match fn {
copy => |_ptr| unimplemented!(),
free => |ptr| ffi::ostree_kernel_args_free(ptr),
}
}
impl KernelArgs {
/// Add a kernel argument.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append(&mut self, arg: &str) {
unsafe {
ffi::ostree_kernel_args_append(self.to_glib_none_mut().0, arg.to_glib_none().0);
}
}
/// Add multiple kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append_argv(&mut self, argv: &[&str]) {
unsafe {
ffi::ostree_kernel_args_append_argv(self.to_glib_none_mut().0, argv.to_glib_none().0);
}
}
/// Appends each argument that does not have one of `prefixes`.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append_argv_filtered(&mut self, argv: &[&str], prefixes: &[&str]) {
unsafe {
ffi::ostree_kernel_args_append_argv_filtered(
self.to_glib_none_mut().0,
argv.to_glib_none().0,
prefixes.to_glib_none().0,
);
}
}
/// Append the entire contents of the currently booted kernel commandline.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn append_proc_cmdline<P: IsA<gio::Cancellable>>(
&mut self,
cancellable: Option<&P>,
) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_append_proc_cmdline(
self.to_glib_none_mut().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Remove a kernel argument.
pub fn delete(&mut self, arg: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_delete(
self.to_glib_none_mut().0,
arg.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Remove a kernel argument.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn delete_key_entry(&mut self, key: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_delete_key_entry(
self.to_glib_none_mut().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Given `foo`, return the last the value of a `foo=bar` key as `bar`.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn get_last_value(&self, key: &str) -> Option<GString> {
unsafe {
from_glib_none(ffi::ostree_kernel_args_get_last_value(
self.to_glib_none().0 as *mut OstreeKernelArgs,
key.to_glib_none().0,
))
}
}
/// Replace any existing `foo=bar` with `foo=other` e.g.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn new_replace(&mut self, arg: &str) -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_kernel_args_new_replace(
self.to_glib_none_mut().0,
arg.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Append from a whitespace-separated string.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn parse_append(&mut self, options: &str) {
unsafe {
ffi::ostree_kernel_args_parse_append(
self.to_glib_none_mut().0,
options.to_glib_none().0,
);
}
}
/// Replace a kernel argument.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn replace(&mut self, arg: &str) {
unsafe {
ffi::ostree_kernel_args_replace(self.to_glib_none_mut().0, arg.to_glib_none().0);
}
}
/// Replace multiple kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn replace_argv(&mut self, argv: &[&str]) {
unsafe {
ffi::ostree_kernel_args_replace_argv(self.to_glib_none_mut().0, argv.to_glib_none().0);
}
}
/// A duplicate of `replace`.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn replace_take(&mut self, arg: &str) {
unsafe {
ffi::ostree_kernel_args_replace_take(self.to_glib_none_mut().0, arg.to_glib_full());
}
}
/// Convert the kernel arguments to a string.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
fn to_gstring(&self) -> GString {
unsafe {
from_glib_full(ffi::ostree_kernel_args_to_string(
self.to_glib_none().0 as *mut OstreeKernelArgs,
))
}
}
/// Convert the kernel arguments to a string array.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn to_strv(&self) -> Vec<GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::ostree_kernel_args_to_strv(
self.to_glib_none().0 as *mut OstreeKernelArgs,
))
}
}
// Not needed
//pub fn cleanup(loc: /*Unimplemented*/Option<Fundamental: Pointer>)
/// Parse the given string as kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn from_string(options: &str) -> KernelArgs {
unsafe {
from_glib_full(ffi::ostree_kernel_args_from_string(
options.to_glib_none().0,
))
}
}
/// Create new empty kernel arguments.
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub fn new() -> KernelArgs {
unsafe { from_glib_full(ffi::ostree_kernel_args_new()) }
}
}
#[cfg(any(feature = "v2019_3", feature = "dox"))]
impl Default for KernelArgs {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for KernelArgs {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.to_gstring())
}
}
impl<T: AsRef<str>> From<T> for KernelArgs {
fn from(v: T) -> Self {
KernelArgs::from_string(v.as_ref())
}
}
+95
View File
@@ -0,0 +1,95 @@
//! # Rust bindings for **libostree**
//!
//! [libostree](https://ostree.readthedocs.io) is both a shared library and suite of command line
//! tools that combines a "git-like" model for committing and downloading bootable filesystem trees,
//! along with a layer for deploying them and managing the bootloader configuration.
#![cfg_attr(feature = "dox", feature(doc_cfg))]
#![deny(unused_must_use)]
#![warn(missing_docs)]
#![warn(rustdoc::broken_intra_doc_links)]
// Re-export our dependencies. See https://gtk-rs.org/blog/2021/06/22/new-release.html
// "Dependencies are re-exported". Users will need e.g. `gio::File`, so this avoids
// them needing to update matching versions.
#[cfg(feature = "cap-std-apis")]
pub use cap_std;
pub use ffi;
pub use gio;
pub use glib;
/// Useful with `Repo::open_at()`.
pub use libc::AT_FDCWD;
// code generated by gir
#[rustfmt::skip]
#[allow(clippy::all)]
#[allow(unused_imports)]
#[allow(missing_docs)]
mod auto;
pub use crate::auto::functions::*;
pub use crate::auto::*;
// handwritten code
mod checksum;
pub use crate::checksum::*;
mod core;
pub use crate::core::*;
mod sysroot;
pub use crate::sysroot::*;
mod constants;
pub use constants::*;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
mod collection_ref;
#[cfg(any(feature = "v2018_6", feature = "dox"))]
pub use crate::collection_ref::*;
mod functions;
pub use crate::functions::*;
mod mutable_tree;
pub use crate::mutable_tree::*;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
mod kernel_args;
#[cfg(any(feature = "v2019_3", feature = "dox"))]
pub use crate::kernel_args::*;
mod object_name;
pub use crate::object_name::*;
mod object_details;
pub use crate::object_details::*;
mod repo;
pub use crate::repo::*;
#[cfg(any(feature = "v2016_8", feature = "dox"))]
mod repo_checkout_at_options;
#[cfg(any(feature = "v2016_8", feature = "dox"))]
pub use crate::repo_checkout_at_options::*;
mod repo_transaction_stats;
pub use repo_transaction_stats::RepoTransactionStats;
mod se_policy;
pub use crate::se_policy::*;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
mod commit_sizes_entry;
#[cfg(any(feature = "v2020_1", feature = "dox"))]
pub use crate::commit_sizes_entry::*;
#[cfg(any(feature = "v2017_4", feature = "dox"))]
mod sysroot_write_deployments_opts;
#[cfg(any(feature = "v2017_4", feature = "dox"))]
pub use crate::sysroot_write_deployments_opts::*;
#[cfg(any(feature = "v2020_7", feature = "dox"))]
mod sysroot_deploy_tree_opts;
#[cfg(any(feature = "v2020_7", feature = "dox"))]
pub use crate::sysroot_deploy_tree_opts::SysrootDeployTreeOpts;
// tests
#[cfg(test)]
mod tests;
/// Prelude, intended for glob imports.
pub mod prelude {
pub use crate::auto::traits::*;
// See "Re-export dependencies above".
#[doc(hidden)]
pub use gio::prelude::*;
#[doc(hidden)]
pub use glib::prelude::*;
}
+46
View File
@@ -0,0 +1,46 @@
use crate::MutableTree;
use glib::{self, translate::*};
use std::collections::HashMap;
impl MutableTree {
#[doc(alias = "ostree_mutable_tree_get_files")]
/// Create a copy of the files in this mutable tree.
/// Unlike the C version of this function, a copy is made because providing
/// read-write access would introduce the potential for use-after-free bugs.
pub fn copy_files(&self) -> HashMap<String, String> {
unsafe {
let v = ffi::ostree_mutable_tree_get_files(self.to_glib_none().0);
HashMap::from_glib_none_num(v, 1)
}
}
#[doc(alias = "ostree_mutable_tree_get_subdirs")]
/// Create a copy of the directories in this mutable tree.
/// Unlike the C version of this function, a copy is made because providing
/// read-write access would introduce the potential for use-after-free bugs.
pub fn copy_subdirs(&self) -> HashMap<String, Self> {
use glib::ffi::gpointer;
unsafe {
let v = ffi::ostree_mutable_tree_get_subdirs(self.to_glib_none().0);
unsafe extern "C" fn visit_hash_table(
key: gpointer,
value: gpointer,
hash_map: gpointer,
) {
let key: String = from_glib_none(key as *const libc::c_char);
let value: MutableTree = from_glib_none(value as *const ffi::OstreeMutableTree);
let hash_map: &mut HashMap<String, MutableTree> =
&mut *(hash_map as *mut HashMap<String, MutableTree>);
hash_map.insert(key, value);
}
let mut map = HashMap::with_capacity(glib::ffi::g_hash_table_size(v) as usize);
glib::ffi::g_hash_table_foreach(
v,
Some(visit_hash_table),
&mut map as *mut HashMap<String, MutableTree> as *mut _,
);
map
}
}
}
+44
View File
@@ -0,0 +1,44 @@
use std::fmt::Display;
use std::fmt::Error;
use std::fmt::Formatter;
/// Details of an object in an OSTree repo. It contains information about if
/// the object is "loose", and contains a list of pack file checksums in which
/// this object appears.
#[derive(Debug)]
pub struct ObjectDetails {
loose: bool,
object_appearances: Vec<String>,
}
impl ObjectDetails {
/// Create a new `ObjectDetails` from a serialized representation.
pub fn new_from_variant(variant: glib::Variant) -> Option<ObjectDetails> {
let deserialize = variant.get::<(bool, Vec<String>)>()?;
Some(ObjectDetails {
loose: deserialize.0,
object_appearances: deserialize.1,
})
}
/// is object available "loose"
pub fn is_loose(&self) -> bool {
self.loose
}
/// Provide list of pack file checksums in which the object appears
pub fn appearances(&self) -> &Vec<String> {
&self.object_appearances
}
}
impl Display for ObjectDetails {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
write!(
f,
"Object is {} and appears in {} checksums",
if self.loose { "loose" } else { "not loose" },
self.object_appearances.len()
)
}
}
+115
View File
@@ -0,0 +1,115 @@
use crate::ObjectType;
use crate::{object_name_deserialize, object_name_serialize, object_to_string};
use glib::translate::*;
use glib::GString;
use std::fmt::Display;
use std::fmt::Error;
use std::fmt::Formatter;
use std::hash::Hash;
use std::hash::Hasher;
fn hash_object_name(v: &glib::Variant) -> u32 {
unsafe { ffi::ostree_hash_object_name(v.to_glib_none().0 as glib::ffi::gconstpointer) }
}
/// A reference to an object in an OSTree repo. It contains both a checksum and an
/// [ObjectType](enum.ObjectType.html) which together identify an object in a repository.
#[derive(Eq, Debug)]
pub struct ObjectName {
variant: glib::Variant,
checksum: GString,
object_type: ObjectType,
}
impl ObjectName {
/// Create a new `ObjectName` from a serialized representation.
pub fn new_from_variant(variant: glib::Variant) -> ObjectName {
let deserialize = object_name_deserialize(&variant);
ObjectName {
variant,
checksum: deserialize.0,
object_type: deserialize.1,
}
}
/// Create a new `ObjectName` with the given checksum and `ObjectType`.
pub fn new<S: Into<GString>>(checksum: S, object_type: ObjectType) -> ObjectName {
let checksum = checksum.into();
let variant = object_name_serialize(checksum.as_str(), object_type)
.expect("type checks should make this safe");
ObjectName {
variant,
checksum,
object_type,
}
}
/// Return a reference to this `ObjectName`'s checksum string.
pub fn checksum(&self) -> &str {
self.checksum.as_str()
}
/// Return this `ObjectName`'s `ObjectType`.
pub fn object_type(&self) -> ObjectType {
self.object_type
}
/// Format this `ObjectName` as a string.
fn to_string(&self) -> GString {
object_to_string(self.checksum(), self.object_type())
.expect("type checks should make this safe")
}
}
impl Display for ObjectName {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
write!(f, "{}", self.to_string())
}
}
impl Hash for ObjectName {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write_u32(hash_object_name(&self.variant));
}
}
impl PartialEq for ObjectName {
fn eq(&self, other: &ObjectName) -> bool {
self.checksum == other.checksum && self.object_type == other.object_type
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn should_stringify_object_name() {
let object_name = ObjectName::new("abcdef123456", ObjectType::DirTree);
let stringified = format!("{}", object_name);
assert_eq!(stringified, "abcdef123456.dirtree");
}
#[test]
fn same_values_should_be_equal() {
let a = ObjectName::new("abc123", ObjectType::File);
let b = ObjectName::new("abc123", ObjectType::File);
assert_eq!(a, b);
}
#[test]
fn different_values_should_not_be_equal() {
let a = ObjectName::new("abc123", ObjectType::Commit);
let b = ObjectName::new("abc123", ObjectType::File);
assert_ne!(a, b);
}
#[test]
fn should_create_object_name_from_variant() {
let object_name = ObjectName::new("123456", ObjectType::CommitMeta);
let from_variant = ObjectName::new_from_variant(object_name.variant.clone());
assert_eq!(object_name, from_variant);
assert_eq!("123456", from_variant.checksum());
assert_eq!(ObjectType::CommitMeta, from_variant.object_type());
}
}
+518
View File
@@ -0,0 +1,518 @@
#[cfg(any(feature = "v2016_4", feature = "dox"))]
use crate::RepoListRefsExtFlags;
#[cfg(feature = "cap-std-apis")]
use crate::RepoMode;
use crate::{Checksum, ObjectDetails, ObjectName, ObjectType, Repo, RepoTransactionStats};
use ffi::OstreeRepoListObjectsFlags;
use glib::ffi as glib_sys;
use glib::{self, translate::*, Error, IsA};
use std::{
collections::{HashMap, HashSet},
future::Future,
mem::MaybeUninit,
path::Path,
pin::Pin,
ptr,
};
unsafe extern "C" fn read_variant_table(
_key: glib_sys::gpointer,
value: glib_sys::gpointer,
hash_set: glib_sys::gpointer,
) {
let value: glib::Variant = from_glib_none(value as *const glib_sys::GVariant);
let set: &mut HashSet<ObjectName> = &mut *(hash_set as *mut HashSet<ObjectName>);
set.insert(ObjectName::new_from_variant(value));
}
unsafe extern "C" fn read_variant_object_map(
key: glib_sys::gpointer,
value: glib_sys::gpointer,
hash_set: glib_sys::gpointer,
) {
let key: glib::Variant = from_glib_none(key as *const glib_sys::GVariant);
let value: glib::Variant = from_glib_none(value as *const glib_sys::GVariant);
let set: &mut HashMap<ObjectName, ObjectDetails> =
&mut *(hash_set as *mut HashMap<ObjectName, ObjectDetails>);
if let Some(details) = ObjectDetails::new_from_variant(value) {
set.insert(ObjectName::new_from_variant(key), details);
}
}
unsafe fn from_glib_container_variant_set(ptr: *mut glib_sys::GHashTable) -> HashSet<ObjectName> {
let mut set = HashSet::new();
glib_sys::g_hash_table_foreach(
ptr,
Some(read_variant_table),
&mut set as *mut HashSet<ObjectName> as *mut _,
);
glib_sys::g_hash_table_unref(ptr);
set
}
unsafe fn from_glib_container_variant_map(
ptr: *mut glib_sys::GHashTable,
) -> HashMap<ObjectName, ObjectDetails> {
let mut set = HashMap::new();
glib_sys::g_hash_table_foreach(
ptr,
Some(read_variant_object_map),
&mut set as *mut HashMap<ObjectName, ObjectDetails> as *mut _,
);
glib_sys::g_hash_table_unref(ptr);
set
}
/// An open transaction in the repository.
///
/// This will automatically invoke [`ostree::Repo::abort_transaction`] when the value is dropped.
pub struct TransactionGuard<'a> {
/// Reference to the repository for this transaction.
repo: Option<&'a Repo>,
}
impl<'a> TransactionGuard<'a> {
/// Commit this transaction.
pub fn commit<P: IsA<gio::Cancellable>>(
mut self,
cancellable: Option<&P>,
) -> Result<RepoTransactionStats, glib::Error> {
// Safety: This is the only function which mutates this option
let repo = self.repo.take().unwrap();
repo.commit_transaction(cancellable)
}
}
impl<'a> Drop for TransactionGuard<'a> {
fn drop(&mut self) {
if let Some(repo) = self.repo {
// TODO: better logging in ostree?
// See also https://github.com/ostreedev/ostree/issues/2413
let _ = repo.abort_transaction(gio::NONE_CANCELLABLE);
}
}
}
impl Repo {
/// Create a new `Repo` object for working with an OSTree repo at the given path.
pub fn new_for_path<P: AsRef<Path>>(path: P) -> Repo {
Repo::new(&gio::File::for_path(path.as_ref()))
}
#[cfg(feature = "cap-std-apis")]
/// A version of [`open_at`] which uses cap-std.
pub fn open_at_dir(dir: &cap_std::fs::Dir, path: &str) -> Result<Repo, glib::Error> {
use std::os::unix::io::AsRawFd;
crate::Repo::open_at(dir.as_raw_fd(), path, gio::NONE_CANCELLABLE)
}
#[cfg(feature = "cap-std-apis")]
/// A version of [`create_at`] which uses cap-std, and also returns the opened repo.
pub fn create_at_dir(
dir: &cap_std::fs::Dir,
path: &str,
mode: RepoMode,
options: Option<&glib::Variant>,
) -> Result<Repo, glib::Error> {
use std::os::unix::io::AsRawFd;
crate::Repo::create_at(dir.as_raw_fd(), path, mode, options, gio::NONE_CANCELLABLE)?;
Repo::open_at_dir(dir, path)
}
/// A wrapper for [`prepare_transaction`] which ensures the transaction will be aborted when the guard goes out of scope.
pub fn auto_transaction<P: IsA<gio::Cancellable>>(
&self,
cancellable: Option<&P>,
) -> Result<TransactionGuard, glib::Error> {
let _ = self.prepare_transaction(cancellable)?;
Ok(TransactionGuard { repo: Some(self) })
}
/// Return a copy of the directory file descriptor for this repository.
#[cfg(any(feature = "v2016_4", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2016_4")))]
pub fn dfd_as_file(&self) -> std::io::Result<std::fs::File> {
use std::os::unix::prelude::FromRawFd;
use std::os::unix::prelude::IntoRawFd;
unsafe {
// A temporary owned file instance
let dfd = std::fs::File::from_raw_fd(self.dfd());
// So we can call dup() on it
let copy = dfd.try_clone();
// Now release our temporary ownership of the original
let _ = dfd.into_raw_fd();
copy
}
}
/// Borrow the directory file descriptor for this repository.
#[cfg(feature = "cap-std-apis")]
pub fn dfd_borrow<'a>(&'a self) -> io_lifetimes::BorrowedFd<'a> {
unsafe { io_lifetimes::BorrowedFd::borrow_raw_fd(self.dfd()) }
}
/// Return a new `cap-std` directory reference for this repository.
#[cfg(feature = "cap-std-apis")]
pub fn dfd_as_dir(&self) -> std::io::Result<cap_std::fs::Dir> {
cap_std::fs::Dir::reopen_dir(&self.dfd_borrow())
}
/// Find all objects reachable from a commit.
pub fn traverse_commit<P: IsA<gio::Cancellable>>(
&self,
commit_checksum: &str,
maxdepth: i32,
cancellable: Option<&P>,
) -> Result<HashSet<ObjectName>, 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,
commit_checksum.to_glib_none().0,
maxdepth,
&mut hashtable,
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_container_variant_set(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// List all branch names (refs).
pub fn list_refs<P: IsA<gio::Cancellable>>(
&self,
refspec_prefix: Option<&str>,
cancellable: Option<&P>,
) -> Result<HashMap<String, String>, 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.to_glib_none().0,
&mut hashtable,
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(FromGlibPtrContainer::from_glib_container(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// List all repo objects
pub fn list_objects<P: IsA<gio::Cancellable>>(
&self,
flags: OstreeRepoListObjectsFlags,
cancellable: Option<&P>,
) -> Result<HashMap<ObjectName, ObjectDetails>, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut hashtable = ptr::null_mut();
ffi::ostree_repo_list_objects(
self.to_glib_none().0,
flags,
&mut hashtable,
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_container_variant_map(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// List refs with extended options.
#[cfg(any(feature = "v2016_4", feature = "dox"))]
pub fn list_refs_ext<P: IsA<gio::Cancellable>>(
&self,
refspec_prefix: Option<&str>,
flags: RepoListRefsExtFlags,
cancellable: Option<&P>,
) -> Result<HashMap<String, String>, 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.to_glib_none().0,
&mut hashtable,
flags.into_glib(),
cancellable.map(AsRef::as_ref).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(FromGlibPtrContainer::from_glib_container(hashtable))
} else {
Err(from_glib_full(error))
}
}
}
/// Resolve a refspec to a commit SHA256.
/// Returns an error if the refspec does not exist.
pub fn require_rev(&self, refspec: &str) -> Result<glib::GString, Error> {
// SAFETY: Since we said `false` for "allow_noent", this function must return a value
Ok(self.resolve_rev(refspec, false)?.unwrap())
}
/// Query metadata for a content object.
///
/// This is similar to [`load_file`], but is more efficient if reading the file content is not needed.
pub fn query_file<P: IsA<gio::Cancellable>>(
&self,
checksum: &str,
cancellable: Option<&P>,
) -> Result<(gio::FileInfo, glib::Variant), glib::Error> {
unsafe {
let mut out_file_info = ptr::null_mut();
let mut out_xattrs = ptr::null_mut();
let mut error = ptr::null_mut();
let r = ffi::ostree_repo_load_file(
self.to_glib_none().0,
checksum.to_glib_none().0,
ptr::null_mut(),
&mut out_file_info,
&mut out_xattrs,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
debug_assert!(r != 0);
Ok((from_glib_full(out_file_info), from_glib_full(out_xattrs)))
} else {
debug_assert_eq!(r, 0);
Err(from_glib_full(error))
}
}
}
/// Write a content object from provided input.
pub fn write_content<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
&self,
expected_checksum: Option<&str>,
object_input: &P,
length: u64,
cancellable: Option<&Q>,
) -> Result<Checksum, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut out_csum = ptr::null_mut();
let _ = ffi::ostree_repo_write_content(
self.to_glib_none().0,
expected_checksum.to_glib_none().0,
object_input.as_ref().to_glib_none().0,
length,
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
}
}
}
/// Write a metadata object.
pub fn write_metadata<P: IsA<gio::Cancellable>>(
&self,
objtype: ObjectType,
expected_checksum: Option<&str>,
object: &glib::Variant,
cancellable: Option<&P>,
) -> Result<Checksum, Error> {
unsafe {
let mut error = ptr::null_mut();
let mut out_csum = ptr::null_mut();
let _ = ffi::ostree_repo_write_metadata(
self.to_glib_none().0,
objtype.into_glib(),
expected_checksum.to_glib_none().0,
object.to_glib_none().0,
&mut out_csum,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
}
}
}
/// Asynchronously write a content object.
pub fn write_content_async<
P: IsA<gio::InputStream>,
Q: IsA<gio::Cancellable>,
R: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
&self,
expected_checksum: Option<&str>,
object: &P,
length: u64,
cancellable: Option<&Q>,
callback: R,
) {
let user_data: Box<R> = Box::new(callback);
unsafe extern "C" fn write_content_async_trampoline<
R: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib::ffi::gpointer,
) {
let mut error = ptr::null_mut();
let mut out_csum = MaybeUninit::uninit();
let _ = ffi::ostree_repo_write_content_finish(
_source_object as *mut _,
res,
out_csum.as_mut_ptr(),
&mut error,
);
let out_csum = out_csum.assume_init();
let result = if error.is_null() {
Ok(Checksum::from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
};
let callback: Box<R> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = write_content_async_trampoline::<R>;
unsafe {
ffi::ostree_repo_write_content_async(
self.to_glib_none().0,
expected_checksum.to_glib_none().0,
object.as_ref().to_glib_none().0,
length,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box::into_raw(user_data) as *mut _,
);
}
}
/// Asynchronously write a content object.
pub fn write_content_async_future<P: IsA<gio::InputStream> + Clone + 'static>(
&self,
expected_checksum: Option<&str>,
object: &P,
length: u64,
) -> Pin<Box<dyn Future<Output = Result<Checksum, Error>> + 'static>> {
let expected_checksum = expected_checksum.map(ToOwned::to_owned);
let object = object.clone();
Box::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.write_content_async(
expected_checksum
.as_ref()
.map(::std::borrow::Borrow::borrow),
&object,
length,
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
/// Asynchronously write a metadata object.
pub fn write_metadata_async<
P: IsA<gio::Cancellable>,
Q: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
&self,
objtype: ObjectType,
expected_checksum: Option<&str>,
object: &glib::Variant,
cancellable: Option<&P>,
callback: Q,
) {
let user_data: Box<Q> = Box::new(callback);
unsafe extern "C" fn write_metadata_async_trampoline<
Q: FnOnce(Result<Checksum, Error>) + Send + 'static,
>(
_source_object: *mut glib::gobject_ffi::GObject,
res: *mut gio::ffi::GAsyncResult,
user_data: glib_sys::gpointer,
) {
let mut error = ptr::null_mut();
let mut out_csum = MaybeUninit::uninit();
let _ = ffi::ostree_repo_write_metadata_finish(
_source_object as *mut _,
res,
out_csum.as_mut_ptr(),
&mut error,
);
let out_csum = out_csum.assume_init();
let result = if error.is_null() {
Ok(Checksum::from_glib_full(out_csum))
} else {
Err(from_glib_full(error))
};
let callback: Box<Q> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = write_metadata_async_trampoline::<Q>;
unsafe {
ffi::ostree_repo_write_metadata_async(
self.to_glib_none().0,
objtype.into_glib(),
expected_checksum.to_glib_none().0,
object.to_glib_none().0,
cancellable.map(|p| p.as_ref()).to_glib_none().0,
Some(callback),
Box::into_raw(user_data) as *mut _,
);
}
}
/// Asynchronously write a metadata object.
pub fn write_metadata_async_future(
&self,
objtype: ObjectType,
expected_checksum: Option<&str>,
object: &glib::Variant,
) -> Pin<Box<dyn Future<Output = Result<Checksum, Error>> + 'static>> {
let expected_checksum = expected_checksum.map(ToOwned::to_owned);
let object = object.clone();
Box::pin(gio::GioFuture::new(self, move |obj, cancellable, send| {
obj.write_metadata_async(
objtype,
expected_checksum
.as_ref()
.map(::std::borrow::Borrow::borrow),
&object,
Some(cancellable),
move |res| {
send.resolve(res);
},
);
}))
}
/// Load and parse directory metadata.
/// In particular, uid/gid/mode are stored in big-endian format; this function
/// converts them to host native endianness.
pub fn read_dirmeta(&self, checksum: &str) -> Result<crate::DirMetaParsed, glib::Error> {
let v = self.load_variant(crate::ObjectType::DirMeta, checksum)?;
// Safety: We know the variant type will match since we just passed it above
Ok(crate::DirMetaParsed::from_variant(&v).unwrap())
}
}
@@ -0,0 +1,280 @@
use crate::{RepoCheckoutMode, RepoCheckoutOverwriteMode, RepoDevInoCache, SePolicy};
use glib::translate::*;
use libc::c_char;
use std::path::PathBuf;
#[cfg(any(feature = "v2018_2", feature = "dox"))]
mod repo_checkout_filter;
#[cfg(any(feature = "v2018_2", feature = "dox"))]
pub use self::repo_checkout_filter::RepoCheckoutFilter;
/// Options for checking out an OSTree commit.
pub struct RepoCheckoutAtOptions {
/// Checkout mode.
pub mode: RepoCheckoutMode,
/// Overwrite mode.
pub overwrite_mode: RepoCheckoutOverwriteMode,
/// Deprecated, do not use.
pub enable_uncompressed_cache: bool,
/// Perform `fsync()` on checked out files and directories.
pub enable_fsync: bool,
/// Handle OCI/Docker style whiteout files.
pub process_whiteouts: bool,
/// Require hardlinking.
pub no_copy_fallback: bool,
/// Never hardlink; reflink if possible, otherwise full physical copy.
#[cfg(any(feature = "v2017_6", feature = "dox"))]
pub force_copy: bool,
/// Suppress mode bits outside of 0775 for directories.
#[cfg(any(feature = "v2017_7", feature = "dox"))]
pub bareuseronly_dirs: bool,
/// Copy zero-sized files rather than hardlinking.
#[cfg(any(feature = "v2018_9", feature = "dox"))]
pub force_copy_zerosized: bool,
/// Only check out this subpath.
pub subpath: Option<PathBuf>,
/// A cache from device, inode pairs to checksums.
pub devino_to_csum_cache: Option<RepoDevInoCache>,
/// A callback function to decide which files and directories will be checked out from the
/// repo. See the documentation on [RepoCheckoutFilter](struct.RepoCheckoutFilter.html) for more
/// information on the signature.
///
/// # Panics
/// This callback may not panic. If it does, `abort()` will be called to avoid unwinding across
/// an FFI boundary and into the libostree C code (which is Undefined Behavior). If you prefer to
/// swallow the panic rather than aborting, you can use `std::panic::catch_unwind` inside your
/// callback to catch and silence any panics that occur.
#[cfg(any(feature = "v2018_2", feature = "dox"))]
pub filter: Option<RepoCheckoutFilter>,
/// SELinux policy.
#[cfg(any(feature = "v2017_6", feature = "dox"))]
pub sepolicy: Option<SePolicy>,
/// When computing security contexts, prefix the path with this value.
pub sepolicy_prefix: Option<String>,
}
impl Default for RepoCheckoutAtOptions {
fn default() -> Self {
RepoCheckoutAtOptions {
mode: RepoCheckoutMode::None,
overwrite_mode: RepoCheckoutOverwriteMode::None,
enable_uncompressed_cache: false,
enable_fsync: false,
process_whiteouts: false,
no_copy_fallback: false,
#[cfg(feature = "v2017_6")]
force_copy: false,
#[cfg(feature = "v2017_7")]
bareuseronly_dirs: false,
#[cfg(feature = "v2018_9")]
force_copy_zerosized: false,
subpath: None,
devino_to_csum_cache: None,
#[cfg(feature = "v2018_2")]
filter: None,
#[cfg(feature = "v2017_6")]
sepolicy: None,
sepolicy_prefix: None,
}
}
}
type StringStash<'a, T> = Stash<'a, *const c_char, Option<T>>;
type WrapperStash<'a, GlibT, WrappedT> = Stash<'a, *mut GlibT, Option<WrappedT>>;
impl<'a> ToGlibPtr<'a, *const ffi::OstreeRepoCheckoutAtOptions> for RepoCheckoutAtOptions {
#[allow(clippy::type_complexity)]
type Storage = (
Box<ffi::OstreeRepoCheckoutAtOptions>,
StringStash<'a, PathBuf>,
StringStash<'a, String>,
WrapperStash<'a, ffi::OstreeRepoDevInoCache, RepoDevInoCache>,
WrapperStash<'a, ffi::OstreeSePolicy, SePolicy>,
);
// We need to make sure that all memory pointed to by the returned pointer is kept alive by
// either the `self` reference or the returned Stash.
fn to_glib_none(&'a self) -> Stash<*const ffi::OstreeRepoCheckoutAtOptions, Self> {
// Creating this struct from zeroed memory is fine since it's `repr(C)` and only contains
// primitive types. In fact, the libostree docs say to zero the struct. This means we handle
// the unused bytes correctly.
// The struct needs to be boxed so the pointer we return remains valid even as the Stash is
// moved around.
let mut options =
Box::new(unsafe { std::mem::zeroed::<ffi::OstreeRepoCheckoutAtOptions>() });
options.mode = self.mode.into_glib();
options.overwrite_mode = self.overwrite_mode.into_glib();
options.enable_uncompressed_cache = self.enable_uncompressed_cache.into_glib();
options.enable_fsync = self.enable_fsync.into_glib();
options.process_whiteouts = self.process_whiteouts.into_glib();
options.no_copy_fallback = self.no_copy_fallback.into_glib();
#[cfg(feature = "v2017_6")]
{
options.force_copy = self.force_copy.into_glib();
}
#[cfg(feature = "v2017_7")]
{
options.bareuseronly_dirs = self.bareuseronly_dirs.into_glib();
}
#[cfg(feature = "v2018_9")]
{
options.force_copy_zerosized = self.force_copy_zerosized.into_glib();
}
// We keep these complex values alive by returning them in our Stash. Technically, some of
// these are being kept alive by `self` already, but it's better to be consistent here.
let subpath = self.subpath.to_glib_none();
options.subpath = subpath.0;
let sepolicy_prefix = self.sepolicy_prefix.to_glib_none();
options.sepolicy_prefix = sepolicy_prefix.0;
let devino_to_csum_cache = self.devino_to_csum_cache.to_glib_none();
options.devino_to_csum_cache = devino_to_csum_cache.0;
#[cfg(feature = "v2017_6")]
let sepolicy = {
let sepolicy = self.sepolicy.to_glib_none();
options.sepolicy = sepolicy.0;
sepolicy
};
#[cfg(not(feature = "v2017_6"))]
let sepolicy = None.to_glib_none();
#[cfg(feature = "v2018_2")]
{
if let Some(filter) = &self.filter {
options.filter_user_data = filter.to_glib_none().0;
options.filter = Some(repo_checkout_filter::filter_trampoline_unwindsafe);
}
}
Stash(
options.as_ref(),
(
options,
subpath,
sepolicy_prefix,
devino_to_csum_cache,
sepolicy,
),
)
}
}
#[cfg(test)]
mod tests {
use super::*;
use glib::ffi::{GFALSE, GTRUE};
use std::ffi::{CStr, CString};
use std::ptr;
#[test]
fn should_convert_default_options() {
let options = RepoCheckoutAtOptions::default();
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).mode, ffi::OSTREE_REPO_CHECKOUT_MODE_NONE);
assert_eq!(
(*ptr).overwrite_mode,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_NONE
);
assert_eq!((*ptr).enable_uncompressed_cache, GFALSE);
assert_eq!((*ptr).enable_fsync, GFALSE);
assert_eq!((*ptr).process_whiteouts, GFALSE);
assert_eq!((*ptr).no_copy_fallback, GFALSE);
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).force_copy, GFALSE);
#[cfg(feature = "v2017_7")]
assert_eq!((*ptr).bareuseronly_dirs, GFALSE);
#[cfg(feature = "v2018_9")]
assert_eq!((*ptr).force_copy_zerosized, GFALSE);
assert_eq!((*ptr).unused_bools, [GFALSE; 4]);
assert_eq!((*ptr).subpath, ptr::null());
assert_eq!((*ptr).devino_to_csum_cache, ptr::null_mut());
assert_eq!((*ptr).unused_ints, [0; 6]);
assert_eq!((*ptr).unused_ptrs, [ptr::null_mut(); 3]);
#[cfg(feature = "v2018_2")]
assert_eq!((*ptr).filter, None);
#[cfg(feature = "v2018_2")]
assert_eq!((*ptr).filter_user_data, ptr::null_mut());
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).sepolicy, ptr::null_mut());
assert_eq!((*ptr).sepolicy_prefix, ptr::null());
}
}
#[test]
fn should_convert_non_default_options() {
let options = RepoCheckoutAtOptions {
mode: RepoCheckoutMode::User,
overwrite_mode: RepoCheckoutOverwriteMode::UnionIdentical,
enable_uncompressed_cache: true,
enable_fsync: true,
process_whiteouts: true,
no_copy_fallback: true,
#[cfg(feature = "v2017_6")]
force_copy: true,
#[cfg(feature = "v2017_7")]
bareuseronly_dirs: true,
#[cfg(feature = "v2018_9")]
force_copy_zerosized: true,
subpath: Some("sub/path".into()),
devino_to_csum_cache: Some(RepoDevInoCache::new()),
#[cfg(feature = "v2018_2")]
filter: RepoCheckoutFilter::new(|_repo, _path, _stat| {
crate::RepoCheckoutFilterResult::Skip
}),
#[cfg(feature = "v2017_6")]
sepolicy: Some(
SePolicy::new(&gio::File::for_path("a/b"), gio::NONE_CANCELLABLE).unwrap(),
),
sepolicy_prefix: Some("prefix".into()),
};
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).mode, ffi::OSTREE_REPO_CHECKOUT_MODE_USER);
assert_eq!(
(*ptr).overwrite_mode,
ffi::OSTREE_REPO_CHECKOUT_OVERWRITE_UNION_IDENTICAL
);
assert_eq!((*ptr).enable_uncompressed_cache, GTRUE);
assert_eq!((*ptr).enable_fsync, GTRUE);
assert_eq!((*ptr).process_whiteouts, GTRUE);
assert_eq!((*ptr).no_copy_fallback, GTRUE);
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).force_copy, GTRUE);
#[cfg(feature = "v2017_7")]
assert_eq!((*ptr).bareuseronly_dirs, GTRUE);
#[cfg(feature = "v2018_9")]
assert_eq!((*ptr).force_copy_zerosized, GTRUE);
assert_eq!((*ptr).unused_bools, [GFALSE; 4]);
assert_eq!(
CStr::from_ptr((*ptr).subpath),
CString::new("sub/path").unwrap().as_c_str()
);
assert_eq!(
(*ptr).devino_to_csum_cache,
options.devino_to_csum_cache.to_glib_none().0
);
assert_eq!((*ptr).unused_ints, [0; 6]);
assert_eq!((*ptr).unused_ptrs, [ptr::null_mut(); 3]);
#[cfg(feature = "v2018_2")]
assert!((*ptr).filter == Some(repo_checkout_filter::filter_trampoline_unwindsafe));
#[cfg(feature = "v2018_2")]
assert_eq!(
(*ptr).filter_user_data,
options.filter.as_ref().unwrap().to_glib_none().0,
);
#[cfg(feature = "v2017_6")]
assert_eq!((*ptr).sepolicy, options.sepolicy.to_glib_none().0);
assert_eq!(
CStr::from_ptr((*ptr).sepolicy_prefix),
CString::new("prefix").unwrap().as_c_str()
);
}
}
}
@@ -0,0 +1,217 @@
use crate::{Repo, RepoCheckoutFilterResult};
use glib::ffi::gpointer;
use glib::translate::*;
use libc::c_char;
use std::any::Any;
use std::panic::catch_unwind;
use std::path::{Path, PathBuf};
use std::process::abort;
/// A filter callback to decide which files to checkout from a [Repo](struct.Repo.html). The
/// function is called for every directory and file in the dirtree.
///
/// # Arguments
/// * `repo` - the `Repo` that is being checked out
/// * `path` - the path of the current file, as an absolute path rooted at the commit's root. The
/// root directory is '/', a subdir would be '/subdir' etc.
/// * `stat` - the metadata of the current file
///
/// # Return Value
/// The return value determines whether the current file is checked out or skipped.
pub struct RepoCheckoutFilter(Box<dyn Fn(&Repo, &Path, &libc::stat) -> RepoCheckoutFilterResult>);
impl RepoCheckoutFilter {
/// Wrap a closure for use as a filter function.
///
/// # Return Value
/// The return value is always `Some` containing the value. It simply comes pre-wrapped for your
/// convenience.
pub fn new<F>(closure: F) -> Option<RepoCheckoutFilter>
where
F: (Fn(&Repo, &Path, &libc::stat) -> RepoCheckoutFilterResult) + 'static,
{
Some(RepoCheckoutFilter(Box::new(closure)))
}
/// Call the contained closure.
fn call(&self, repo: &Repo, path: &Path, stat: &libc::stat) -> RepoCheckoutFilterResult {
self.0(repo, path, stat)
}
}
impl<'a> ToGlibPtr<'a, gpointer> for RepoCheckoutFilter {
type Storage = ();
fn to_glib_none(&'a self) -> Stash<gpointer, Self> {
Stash(self as *const RepoCheckoutFilter as gpointer, ())
}
}
impl FromGlibPtrNone<gpointer> for &RepoCheckoutFilter {
// `ptr` must be valid for the lifetime of the returned reference.
unsafe fn from_glib_none(ptr: gpointer) -> Self {
assert!(!ptr.is_null());
&*(ptr as *const RepoCheckoutFilter)
}
}
/// Trampoline to be called by libostree that calls the Rust closure in the `user_data` parameter.
///
/// # Safety
/// All parameters must be valid pointers for the runtime of the function. In particular,
/// `user_data` must point to a [RepoCheckoutFilter](struct.RepoCheckoutFilter.html) value.
///
/// # Panics
/// If any parameter is a null pointer, the function panics.
unsafe fn filter_trampoline(
repo: *mut ffi::OstreeRepo,
path: *const c_char,
stat: *mut libc::stat,
user_data: gpointer,
) -> ffi::OstreeRepoCheckoutFilterResult {
// We can't guarantee it's a valid pointer, but we can make sure it's not null.
assert!(!stat.is_null());
let stat = &*stat;
// This reference is valid until the end of this function, which is shorter than the lifetime
// of `user_data` so we're fine.
let closure: &RepoCheckoutFilter = from_glib_none(user_data);
// `repo` lives at least until the end of this function. This means we can just borrow the
// reference so long as our `repo` is not moved out of this function.
let repo = from_glib_borrow(repo);
// This is a copy so no problems here.
let path: PathBuf = from_glib_none(path);
let result = closure.call(&repo, &path, stat);
result.into_glib()
}
/// Unwind-safe trampoline to call the Rust filter callback. See [filter_trampoline](fn.filter_trampoline.html).
/// This function additionally catches panics and aborts to avoid unwinding into C code.
pub(super) unsafe extern "C" fn filter_trampoline_unwindsafe(
repo: *mut ffi::OstreeRepo,
path: *const c_char,
stat: *mut libc::stat,
user_data: gpointer,
) -> ffi::OstreeRepoCheckoutFilterResult {
// Unwinding across an FFI boundary is Undefined Behavior and we have no other way to communicate
// the error. We abort() safely to avoid further problems.
let result = catch_unwind(move || filter_trampoline(repo, path, stat, user_data));
result.unwrap_or_else(|panic| {
print_panic(panic);
abort()
})
}
/// Print a panic message and the value to stderr, if we can.
///
/// If the panic value is either `&str` or `String`, we print it. Otherwise, we don't.
fn print_panic(panic: Box<dyn Any>) {
eprintln!("A Rust callback invoked by C code panicked.");
eprintln!("Unwinding across FFI boundaries is Undefined Behavior so abort() will be called.");
let msg = {
if let Some(s) = panic.as_ref().downcast_ref::<&str>() {
s
} else if let Some(s) = panic.as_ref().downcast_ref::<String>() {
s
} else {
"UNABLE TO SHOW VALUE OF PANIC"
}
};
eprintln!("Panic value: {}", msg);
}
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::CString;
use std::ptr;
#[test]
#[should_panic]
fn trampoline_should_panic_if_repo_is_nullptr() {
let path = CString::new("/a/b/c").unwrap();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
let filter = RepoCheckoutFilter(Box::new(|_, _, _| RepoCheckoutFilterResult::Allow));
unsafe {
filter_trampoline(
ptr::null_mut(),
path.as_ptr(),
&mut stat,
filter.to_glib_none().0,
);
}
}
#[test]
#[should_panic]
fn trampoline_should_panic_if_path_is_nullptr() {
let repo = Repo::new_default();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
let filter = RepoCheckoutFilter(Box::new(|_, _, _| RepoCheckoutFilterResult::Allow));
unsafe {
filter_trampoline(
repo.to_glib_none().0,
ptr::null(),
&mut stat,
filter.to_glib_none().0,
);
}
}
#[test]
#[should_panic]
fn trampoline_should_panic_if_stat_is_nullptr() {
let repo = Repo::new_default();
let path = CString::new("/a/b/c").unwrap();
let filter = RepoCheckoutFilter(Box::new(|_, _, _| RepoCheckoutFilterResult::Allow));
unsafe {
filter_trampoline(
repo.to_glib_none().0,
path.as_ptr(),
ptr::null_mut(),
filter.to_glib_none().0,
);
}
}
#[test]
#[should_panic]
fn trampoline_should_panic_if_user_data_is_nullptr() {
let repo = Repo::new_default();
let path = CString::new("/a/b/c").unwrap();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
unsafe {
filter_trampoline(
repo.to_glib_none().0,
path.as_ptr(),
&mut stat,
ptr::null_mut(),
);
}
}
#[test]
fn trampoline_should_call_the_closure() {
let repo = Repo::new_default();
let path = CString::new("/a/b/c").unwrap();
let mut stat: libc::stat = unsafe { std::mem::zeroed() };
let filter = {
let repo = repo.clone();
let path = path.clone();
RepoCheckoutFilter(Box::new(move |arg_repo, arg_path, _| {
assert_eq!(arg_repo, &repo);
assert_eq!(&CString::new(arg_path.to_str().unwrap()).unwrap(), &path);
RepoCheckoutFilterResult::Skip
}))
};
let result = unsafe {
filter_trampoline(
repo.to_glib_none().0,
path.as_ptr(),
&mut stat,
filter.to_glib_none().0,
)
};
assert_eq!(result, ffi::OSTREE_REPO_CHECKOUT_FILTER_SKIP);
}
}
@@ -0,0 +1,45 @@
glib::wrapper! {
/// A list of statistics for each transaction that may be interesting for reporting purposes.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RepoTransactionStats(Boxed<ffi::OstreeRepoTransactionStats>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::ostree_repo_transaction_stats_get_type(), ptr as *mut _) as *mut ffi::OstreeRepoTransactionStats,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::ostree_repo_transaction_stats_get_type(), ptr as *mut _),
init => |_ptr| (),
clear => |_ptr| (),
type_ => || ffi::ostree_repo_transaction_stats_get_type(),
}
}
impl RepoTransactionStats {
/// The total number of metadata objects in the repository after this transaction has completed.
pub fn get_metadata_objects_total(&self) -> usize {
self.0.metadata_objects_total as usize
}
/// The number of metadata objects that were written to the repository in this transaction.
pub fn get_metadata_objects_written(&self) -> usize {
self.0.metadata_objects_written as usize
}
/// The total number of content objects in the repository after this transaction has completed.
pub fn get_content_objects_total(&self) -> usize {
self.0.content_objects_total as usize
}
/// The number of content objects that were written to the repository in this transaction.
pub fn get_content_objects_written(&self) -> usize {
self.0.content_objects_written as usize
}
/// The amount of data added to the repository, in bytes, counting only content objects.
pub fn get_content_bytes_written(&self) -> u64 {
self.0.content_bytes_written
}
/// The amount of cache hits during this transaction.
pub fn get_devino_cache_hits(&self) -> usize {
self.0.devino_cache_hits as usize
}
}
+11
View File
@@ -0,0 +1,11 @@
use crate::SePolicy;
use std::ptr;
impl SePolicy {
/// Reset the SELinux filesystem creation context.
pub fn fscreatecon_cleanup() {
unsafe {
ffi::ostree_sepolicy_fscreatecon_cleanup(ptr::null_mut());
}
}
}
+107
View File
@@ -0,0 +1,107 @@
use crate::gio;
use crate::Sysroot;
use std::path::PathBuf;
#[derive(Clone, Debug, Default)]
/// Builder object for `Sysroot`.
pub struct SysrootBuilder {
path: Option<PathBuf>,
mount_namespace_in_use: bool,
}
impl SysrootBuilder {
/// Create a new builder for `Sysroot`.
pub fn new() -> Self {
Self::default()
}
/// Set the path to the sysroot location.
pub fn path(mut self, path: Option<PathBuf>) -> Self {
self.path = path;
self
}
#[cfg(any(feature = "v2020_1", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2020_1")))]
/// Set whether the logic is running in its own mount namespace.
pub fn mount_namespace_in_use(mut self, mount_namespace_in_use: bool) -> Self {
self.mount_namespace_in_use = mount_namespace_in_use;
self
}
/// Load an existing `Sysroot` from disk, finalizing this builder.
pub fn load(self, cancellable: Option<&gio::Cancellable>) -> Result<Sysroot, glib::Error> {
let sysroot = self.configure_common();
sysroot.load(cancellable)?;
Ok(sysroot)
}
/// Create a new `Sysroot` on disk, finalizing this builder.
pub fn create(self, cancellable: Option<&gio::Cancellable>) -> Result<Sysroot, glib::Error> {
let sysroot = self.configure_common();
sysroot.ensure_initialized(cancellable)?;
sysroot.load(cancellable)?;
Ok(sysroot)
}
/// Perform common configuration steps, returning a not-yet-fully-loaded `Sysroot`.
fn configure_common(self) -> Sysroot {
let sysroot = {
let opt_file = self.path.map(gio::File::for_path);
Sysroot::new(opt_file.as_ref())
};
#[cfg(feature = "v2020_1")]
if self.mount_namespace_in_use {
sysroot.set_mount_namespace_in_use();
}
sysroot
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_sysroot_create_load_empty() {
// Create and load an empty sysroot. Make sure it can be properly
// inspected as empty, without panics.
let tmpdir = tempfile::tempdir().unwrap();
let path_created = {
let tmp_path = Some(tmpdir.path().to_path_buf());
let builder = SysrootBuilder::new().path(tmp_path);
let sysroot = builder.create(gio::NONE_CANCELLABLE).unwrap();
assert!(sysroot.fd() >= 0);
assert_eq!(sysroot.deployments().len(), 0);
assert_eq!(sysroot.booted_deployment(), None);
assert_eq!(sysroot.bootversion(), 0);
assert_eq!(sysroot.subbootversion(), 0);
sysroot.cleanup(gio::NONE_CANCELLABLE).unwrap();
sysroot.path().unwrap()
};
let path_loaded = {
let tmp_path = Some(tmpdir.path().to_path_buf());
let builder = SysrootBuilder::new().path(tmp_path);
let sysroot = builder.create(gio::NONE_CANCELLABLE).unwrap();
assert!(sysroot.fd() >= 0);
assert_eq!(sysroot.deployments().len(), 0);
assert_eq!(sysroot.booted_deployment(), None);
assert_eq!(sysroot.bootversion(), 0);
assert_eq!(sysroot.subbootversion(), 0);
sysroot.cleanup(gio::NONE_CANCELLABLE).unwrap();
sysroot.path().unwrap()
};
assert_eq!(path_created.to_string(), path_loaded.to_string());
}
}
@@ -0,0 +1,101 @@
use ffi::OstreeSysrootDeployTreeOpts;
use glib::translate::*;
use libc::c_char;
/// Options for deploying an ostree commit.
pub struct SysrootDeployTreeOpts<'a> {
/// Use these kernel arguments.
pub override_kernel_argv: Option<&'a [&'a str]>,
/// Paths to initramfs files to overlay.
pub overlay_initrds: Option<&'a [&'a str]>,
}
impl<'a> Default for SysrootDeployTreeOpts<'a> {
fn default() -> Self {
SysrootDeployTreeOpts {
override_kernel_argv: None,
overlay_initrds: None,
}
}
}
type OptionStrSliceStorage<'a> =
<Option<&'a [&'a str]> as ToGlibPtr<'a, *mut *mut c_char>>::Storage;
impl<'a, 'b: 'a> ToGlibPtr<'a, *const OstreeSysrootDeployTreeOpts> for SysrootDeployTreeOpts<'b> {
type Storage = (
Box<OstreeSysrootDeployTreeOpts>,
OptionStrSliceStorage<'a>,
OptionStrSliceStorage<'a>,
);
fn to_glib_none(&'a self) -> Stash<*const OstreeSysrootDeployTreeOpts, Self> {
// Creating this struct from zeroed memory is fine since it's `repr(C)` and only contains
// primitive types. Zeroing it ensures we handle the unused bytes correctly.
// The struct needs to be boxed so the pointer we return remains valid even as the Stash is
// moved around.
let mut options = Box::new(unsafe { std::mem::zeroed::<OstreeSysrootDeployTreeOpts>() });
let override_kernel_argv = self.override_kernel_argv.to_glib_none();
let overlay_initrds = self.overlay_initrds.to_glib_none();
options.override_kernel_argv = override_kernel_argv.0;
options.overlay_initrds = overlay_initrds.0;
Stash(
options.as_ref(),
(options, override_kernel_argv.1, overlay_initrds.1),
)
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::{ffi::CStr, ptr::null_mut};
unsafe fn ptr_array_to_slice<'a, T>(ptr: *mut *mut T) -> &'a [*mut T] {
let mut len = 0;
while !(*ptr.offset(len)).is_null() {
len += 1;
}
std::slice::from_raw_parts(ptr, len as usize)
}
unsafe fn str_ptr_array_to_vec<'a>(ptr: *mut *mut c_char) -> Vec<&'a str> {
ptr_array_to_slice(ptr)
.iter()
.map(|x| CStr::from_ptr(*x).to_str().unwrap())
.collect()
}
#[test]
fn should_convert_default_options() {
let options = SysrootDeployTreeOpts::default();
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).override_kernel_argv, null_mut());
assert_eq!((*ptr).overlay_initrds, null_mut());
}
}
#[test]
fn should_convert_non_default_options() {
let override_kernel_argv = vec!["quiet", "splash", "ro"];
let overlay_initrds = vec!["overlay1", "overlay2"];
let options = SysrootDeployTreeOpts {
override_kernel_argv: Some(&override_kernel_argv),
overlay_initrds: Some(&overlay_initrds),
};
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!(
str_ptr_array_to_vec((*ptr).override_kernel_argv),
vec!["quiet", "splash", "ro"]
);
assert_eq!(
str_ptr_array_to_vec((*ptr).overlay_initrds),
vec!["overlay1", "overlay2"]
);
}
}
}
@@ -0,0 +1,57 @@
use ffi::OstreeSysrootWriteDeploymentsOpts;
use glib::translate::*;
/// Options for writing a deployment.
pub struct SysrootWriteDeploymentsOpts {
/// Perform cleanup after writing the deployment.
pub do_postclean: bool,
}
impl Default for SysrootWriteDeploymentsOpts {
fn default() -> Self {
SysrootWriteDeploymentsOpts {
do_postclean: false,
}
}
}
impl<'a> ToGlibPtr<'a, *const OstreeSysrootWriteDeploymentsOpts> for SysrootWriteDeploymentsOpts {
type Storage = Box<OstreeSysrootWriteDeploymentsOpts>;
fn to_glib_none(&'a self) -> Stash<*const OstreeSysrootWriteDeploymentsOpts, Self> {
// Creating this struct from zeroed memory is fine since it's `repr(C)` and only contains
// primitive types.
// The struct needs to be boxed so the pointer we return remains valid even as the Stash is
// moved around.
let mut options =
Box::new(unsafe { std::mem::zeroed::<OstreeSysrootWriteDeploymentsOpts>() });
options.do_postclean = self.do_postclean.into_glib();
Stash(options.as_ref(), options)
}
}
#[cfg(test)]
mod tests {
use super::*;
use glib::ffi::{GFALSE, GTRUE};
#[test]
fn should_convert_default_options() {
let options = SysrootWriteDeploymentsOpts::default();
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).do_postclean, GFALSE);
}
}
#[test]
fn should_convert_non_default_options() {
let options = SysrootWriteDeploymentsOpts { do_postclean: true };
let stash = options.to_glib_none();
let ptr = stash.0;
unsafe {
assert_eq!((*ptr).do_postclean, GTRUE);
}
}
}
+79
View File
@@ -0,0 +1,79 @@
#![cfg(feature = "v2018_6")]
use crate::CollectionRef;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
fn hash(v: &impl Hash) -> u64 {
let mut s = DefaultHasher::new();
v.hash(&mut s);
s.finish()
}
#[test]
fn same_value_should_be_equal() {
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(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(a, b);
}
#[test]
fn equal_values_without_collection_id_should_be_equal() {
let a = CollectionRef::new(None, "ref-name").unwrap();
let b = CollectionRef::new(None, "ref-name").unwrap();
assert_eq!(a, b);
}
#[test]
fn different_values_should_not_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref2").unwrap();
assert_ne!(a, b);
}
#[test]
fn new_with_invalid_collection_id_should_return_none() {
let r = CollectionRef::new(Some(".abc"), "ref");
assert_eq!(r, None);
}
#[test]
fn hash_for_equal_values_should_be_equal() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
assert_eq!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_collection_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull1"), "ref").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull2"), "ref").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_for_values_with_different_ref_id_should_be_different() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-1").unwrap();
let b = CollectionRef::new(Some("io.gitlab.fkrull"), "ref-2").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn hash_should_be_different_if_collection_id_is_absent() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = CollectionRef::new(None, "ref").unwrap();
assert_ne!(hash(&a), hash(&b));
}
#[test]
fn clone_should_be_equal_to_original_value() {
let a = CollectionRef::new(Some("io.gitlab.fkrull"), "ref").unwrap();
let b = a.clone();
assert_eq!(a, b);
}
+64
View File
@@ -0,0 +1,64 @@
#![cfg(feature = "v2019_3")]
use crate::KernelArgs;
#[test]
fn should_create_and_fill_kernel_args() {
let mut args = KernelArgs::new();
args.append("key=value");
args.append("arg1");
args.append("key2=value2");
assert_eq!(args.to_string(), "key=value arg1 key2=value2");
}
#[test]
fn should_convert_to_string_vec() {
let mut args = KernelArgs::new();
args.parse_append("key=value arg1 key2=value2");
assert_eq!(
args.to_strv()
.iter()
.map(|s| s.as_str())
.collect::<Vec<_>>(),
vec!["key=value", "arg1", "key2=value2"]
);
}
#[test]
fn should_get_last_value() {
let mut args = KernelArgs::new();
args.append("key=value1");
args.append("key=value2");
args.append("key=value3");
assert_eq!(args.get_last_value("key").unwrap(), "value3");
}
#[test]
fn should_convert_from_string() {
let args = KernelArgs::from(String::from("arg1 arg2 arg3=value"));
assert_eq!(args.to_strv(), vec!["arg1", "arg2", "arg3=value"]);
}
#[test]
fn should_append_argv() {
let mut args = KernelArgs::new();
args.append_argv(&["arg1", "arg2=value", "arg3", "arg4=value"]);
assert_eq!(args.to_string(), "arg1 arg2=value arg3 arg4=value");
}
#[test]
fn should_append_argv_filtered() {
let mut args = KernelArgs::new();
args.append_argv_filtered(
&["prefix.arg1", "arg2", "prefix.arg3", "arg4=value"],
&["prefix"],
);
assert_eq!(args.to_string(), "arg2 arg4=value");
}
#[test]
fn should_replace_argv() {
let mut args = KernelArgs::from_string("arg1=value1 arg2=value2 arg3");
args.replace_argv(&["arg1=value3", "arg3=value4", "arg4"]);
assert_eq!(args.to_string(), "arg1=value3 arg2=value2 arg3=value4 arg4");
}
+3
View File
@@ -0,0 +1,3 @@
mod collection_ref;
mod kernel_args;
mod repo;
+14
View File
@@ -0,0 +1,14 @@
use crate::Repo;
use crate::RepoMode;
#[test]
fn should_get_repo_mode_from_string() {
let mode = Repo::mode_from_string("archive").unwrap();
assert_eq!(RepoMode::Archive, mode);
}
#[test]
fn should_return_error_for_invalid_repo_mode_string() {
let result = Repo::mode_from_string("invalid-repo-mode");
assert!(result.is_err());
}