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