ostree/rust-bindings/rust/src/auto/bootconfig_parser.rs

112 lines
4.0 KiB
Rust

// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use Error;
use ffi;
use gio;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct BootconfigParser(Object<ffi::OstreeBootconfigParser>);
match fn {
get_type => || ffi::ostree_bootconfig_parser_get_type(),
}
}
impl BootconfigParser {
pub fn new() -> BootconfigParser {
unsafe {
from_glib_full(ffi::ostree_bootconfig_parser_new())
}
}
}
impl Default for BootconfigParser {
fn default() -> Self {
Self::new()
}
}
pub trait BootconfigParserExt {
fn clone(&self) -> Option<BootconfigParser>;
fn get(&self, key: &str) -> Option<String>;
fn parse<'a, P: IsA<gio::File>, Q: Into<Option<&'a gio::Cancellable>>>(&self, path: &P, cancellable: Q) -> Result<(), Error>;
fn parse_at<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error>;
fn set(&self, key: &str, value: &str);
fn write<'a, P: IsA<gio::File>, Q: Into<Option<&'a gio::Cancellable>>>(&self, output: &P, cancellable: Q) -> Result<(), Error>;
fn write_at<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error>;
}
impl<O: IsA<BootconfigParser>> BootconfigParserExt for O {
fn clone(&self) -> Option<BootconfigParser> {
unsafe {
from_glib_full(ffi::ostree_bootconfig_parser_clone(self.to_glib_none().0))
}
}
fn get(&self, key: &str) -> Option<String> {
unsafe {
from_glib_none(ffi::ostree_bootconfig_parser_get(self.to_glib_none().0, key.to_glib_none().0))
}
}
fn parse<'a, P: IsA<gio::File>, Q: Into<Option<&'a gio::Cancellable>>>(&self, path: &P, cancellable: Q) -> Result<(), Error> {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_parse(self.to_glib_none().0, path.to_glib_none().0, cancellable.0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn parse_at<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error> {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_parse_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn set(&self, key: &str, value: &str) {
unsafe {
ffi::ostree_bootconfig_parser_set(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0);
}
}
fn write<'a, P: IsA<gio::File>, Q: Into<Option<&'a gio::Cancellable>>>(&self, output: &P, cancellable: Q) -> Result<(), Error> {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_write(self.to_glib_none().0, output.to_glib_none().0, cancellable.0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn write_at<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, dfd: i32, path: &str, cancellable: P) -> Result<(), Error> {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::ostree_bootconfig_parser_write_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}