libshumate 0.2.0

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

use crate::DataSource;
use crate::MapProjection;
use crate::MapSource;
use glib::object::Cast;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::fmt;

glib::wrapper! {
    #[doc(alias = "ShumateRasterRenderer")]
    pub struct RasterRenderer(Object<ffi::ShumateRasterRenderer, ffi::ShumateRasterRendererClass>) @extends MapSource;

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

impl RasterRenderer {
    #[doc(alias = "shumate_raster_renderer_new")]
    pub fn new(data_source: &impl IsA<DataSource>) -> RasterRenderer {
        skip_assert_initialized!();
        unsafe {
            from_glib_full(ffi::shumate_raster_renderer_new(
                data_source.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_raster_renderer_new_from_url")]
    #[doc(alias = "new_from_url")]
    pub fn from_url(url_template: &str) -> RasterRenderer {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::shumate_raster_renderer_new_from_url(
                url_template.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_raster_renderer_new_full")]
    pub fn new_full(
        id: &str,
        name: &str,
        license: &str,
        license_uri: &str,
        min_zoom: u32,
        max_zoom: u32,
        tile_size: u32,
        projection: MapProjection,
        data_source: &impl IsA<DataSource>,
    ) -> RasterRenderer {
        skip_assert_initialized!();
        unsafe {
            from_glib_full(ffi::shumate_raster_renderer_new_full(
                id.to_glib_none().0,
                name.to_glib_none().0,
                license.to_glib_none().0,
                license_uri.to_glib_none().0,
                min_zoom,
                max_zoom,
                tile_size,
                projection.into_glib(),
                data_source.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "shumate_raster_renderer_new_full_from_url")]
    pub fn new_full_from_url(
        id: &str,
        name: &str,
        license: &str,
        license_uri: &str,
        min_zoom: u32,
        max_zoom: u32,
        tile_size: u32,
        projection: MapProjection,
        url_template: &str,
    ) -> RasterRenderer {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::shumate_raster_renderer_new_full_from_url(
                id.to_glib_none().0,
                name.to_glib_none().0,
                license.to_glib_none().0,
                license_uri.to_glib_none().0,
                min_zoom,
                max_zoom,
                tile_size,
                projection.into_glib(),
                url_template.to_glib_none().0,
            ))
        }
    }

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

    #[doc(alias = "data-source")]
    pub fn data_source(&self) -> Option<DataSource> {
        glib::ObjectExt::property(self, "data-source")
    }
}

impl Default for RasterRenderer {
    fn default() -> Self {
        glib::object::Object::new::<Self>(&[])
    }
}

#[derive(Clone, Default)]
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`RasterRenderer`] 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 RasterRendererBuilder {
    data_source: Option<DataSource>,
    id: Option<String>,
    license: Option<String>,
    license_uri: Option<String>,
    max_zoom_level: Option<u32>,
    min_zoom_level: Option<u32>,
    name: Option<String>,
    projection: Option<MapProjection>,
    tile_size: Option<u32>,
}

impl RasterRendererBuilder {
    // rustdoc-stripper-ignore-next
    /// Create a new [`RasterRendererBuilder`].
    pub fn new() -> Self {
        Self::default()
    }

    // rustdoc-stripper-ignore-next
    /// Build the [`RasterRenderer`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> RasterRenderer {
        let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
        if let Some(ref data_source) = self.data_source {
            properties.push(("data-source", data_source));
        }
        if let Some(ref id) = self.id {
            properties.push(("id", id));
        }
        if let Some(ref license) = self.license {
            properties.push(("license", license));
        }
        if let Some(ref license_uri) = self.license_uri {
            properties.push(("license-uri", license_uri));
        }
        if let Some(ref max_zoom_level) = self.max_zoom_level {
            properties.push(("max-zoom-level", max_zoom_level));
        }
        if let Some(ref min_zoom_level) = self.min_zoom_level {
            properties.push(("min-zoom-level", min_zoom_level));
        }
        if let Some(ref name) = self.name {
            properties.push(("name", name));
        }
        if let Some(ref projection) = self.projection {
            properties.push(("projection", projection));
        }
        if let Some(ref tile_size) = self.tile_size {
            properties.push(("tile-size", tile_size));
        }
        glib::Object::new::<RasterRenderer>(&properties)
    }

    pub fn data_source(mut self, data_source: &impl IsA<DataSource>) -> Self {
        self.data_source = Some(data_source.clone().upcast());
        self
    }

    pub fn id(mut self, id: &str) -> Self {
        self.id = Some(id.to_string());
        self
    }

    pub fn license(mut self, license: &str) -> Self {
        self.license = Some(license.to_string());
        self
    }

    pub fn license_uri(mut self, license_uri: &str) -> Self {
        self.license_uri = Some(license_uri.to_string());
        self
    }

    pub fn max_zoom_level(mut self, max_zoom_level: u32) -> Self {
        self.max_zoom_level = Some(max_zoom_level);
        self
    }

    pub fn min_zoom_level(mut self, min_zoom_level: u32) -> Self {
        self.min_zoom_level = Some(min_zoom_level);
        self
    }

    pub fn name(mut self, name: &str) -> Self {
        self.name = Some(name.to_string());
        self
    }

    pub fn projection(mut self, projection: MapProjection) -> Self {
        self.projection = Some(projection);
        self
    }

    pub fn tile_size(mut self, tile_size: u32) -> Self {
        self.tile_size = Some(tile_size);
        self
    }
}

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