// 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")
    }
}
