libmirage 0.1.1

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

use crate::ffi;
use glib::{prelude::*, translate::*};

glib::wrapper! {
    #[doc(alias = "MiragePlugin")]
    pub struct Plugin(Object<ffi::MiragePlugin, ffi::MiragePluginClass>) @extends glib::TypeModule, @implements glib::TypePlugin;

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

impl Plugin {
    pub const NONE: Option<&'static Plugin> = None;

    #[doc(alias = "mirage_plugin_new")]
    pub fn new(filename: &str) -> Plugin {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::mirage_plugin_new(filename.to_glib_none().0)) }
    }

    // rustdoc-stripper-ignore-next
    /// Creates a new builder-pattern struct instance to construct [`Plugin`] objects.
    ///
    /// This method returns an instance of [`PluginBuilder`](crate::builders::PluginBuilder) which can be used to create [`Plugin`] objects.
    pub fn builder() -> PluginBuilder {
        PluginBuilder::new()
    }
}

impl Default for Plugin {
    fn default() -> Self {
        glib::object::Object::new::<Self>()
    }
}

// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`Plugin`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct PluginBuilder {
    builder: glib::object::ObjectBuilder<'static, Plugin>,
}

impl PluginBuilder {
    fn new() -> Self {
        Self {
            builder: glib::object::Object::builder(),
        }
    }

    pub fn filename(self, filename: impl Into<glib::GString>) -> Self {
        Self {
            builder: self.builder.property("filename", filename.into()),
        }
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`Plugin`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> Plugin {
        assert_initialized_main_thread!();
        self.builder.build()
    }
}

pub trait PluginExt: IsA<Plugin> + 'static {
    fn filename(&self) -> Option<glib::GString> {
        ObjectExt::property(self.as_ref(), "filename")
    }
}

impl<O: IsA<Plugin>> PluginExt for O {}