// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files
// DO NOT EDIT

use crate::RepoFinder;
use glib::translate::*;
use std::fmt;
use std::ptr;

glib::wrapper! {
    #[doc(alias = "OstreeRepoFinderAvahi")]
    pub struct RepoFinderAvahi(Object<ffi::OstreeRepoFinderAvahi, ffi::OstreeRepoFinderAvahiClass>) @implements RepoFinder;

    match fn {
        type_ => || ffi::ostree_repo_finder_avahi_get_type(),
    }
}

impl RepoFinderAvahi {
    #[doc(alias = "ostree_repo_finder_avahi_new")]
    pub fn new(context: Option<&glib::MainContext>) -> RepoFinderAvahi {
        unsafe {
            from_glib_full(ffi::ostree_repo_finder_avahi_new(context.to_glib_none().0))
        }
    }

    #[doc(alias = "ostree_repo_finder_avahi_start")]
    pub fn start(&self) -> Result<(), glib::Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ffi::ostree_repo_finder_avahi_start(self.to_glib_none().0, &mut error);
            if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
        }
    }

    #[doc(alias = "ostree_repo_finder_avahi_stop")]
    pub fn stop(&self) {
        unsafe {
            ffi::ostree_repo_finder_avahi_stop(self.to_glib_none().0);
        }
    }
}

impl fmt::Display for RepoFinderAvahi {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.write_str("RepoFinderAvahi")
    }
}
