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