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

91 lines
3.3 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 gio;
use glib::GString;
use glib::object::IsA;
use glib::translate::*;
use ostree_sys;
use std::fmt;
use std::ptr;
glib_wrapper! {
pub struct BootconfigParser(Object<ostree_sys::OstreeBootconfigParser, BootconfigParserClass>);
match fn {
get_type => || ostree_sys::ostree_bootconfig_parser_get_type(),
}
}
impl BootconfigParser {
pub fn new() -> BootconfigParser {
unsafe {
from_glib_full(ostree_sys::ostree_bootconfig_parser_new())
}
}
pub fn clone(&self) -> Option<BootconfigParser> {
unsafe {
from_glib_full(ostree_sys::ostree_bootconfig_parser_clone(self.to_glib_none().0))
}
}
pub fn get(&self, key: &str) -> Option<GString> {
unsafe {
from_glib_none(ostree_sys::ostree_bootconfig_parser_get(self.to_glib_none().0, key.to_glib_none().0))
}
}
pub fn parse<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, path: &P, cancellable: Option<&Q>) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ostree_sys::ostree_bootconfig_parser_parse(self.to_glib_none().0, path.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
pub fn parse_at<P: IsA<gio::Cancellable>>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ostree_sys::ostree_bootconfig_parser_parse_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
pub fn set(&self, key: &str, value: &str) {
unsafe {
ostree_sys::ostree_bootconfig_parser_set(self.to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0);
}
}
pub fn write<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(&self, output: &P, cancellable: Option<&Q>) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ostree_sys::ostree_bootconfig_parser_write(self.to_glib_none().0, output.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
pub fn write_at<P: IsA<gio::Cancellable>>(&self, dfd: i32, path: &str, cancellable: Option<&P>) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ostree_sys::ostree_bootconfig_parser_write_at(self.to_glib_none().0, dfd, path.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}
impl Default for BootconfigParser {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for BootconfigParser {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "BootconfigParser")
}
}