Skip to main content

libshumate/auto/
coordinate.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{Location, ffi};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// A simple object implementing [`Location`][crate::Location].
11    ///
12    /// # Implements
13    ///
14    /// [`trait@glib::ObjectExt`], [`LocationExt`][trait@crate::prelude::LocationExt]
15    #[doc(alias = "ShumateCoordinate")]
16    pub struct Coordinate(Object<ffi::ShumateCoordinate, ffi::ShumateCoordinateClass>) @implements Location;
17
18    match fn {
19        type_ => || ffi::shumate_coordinate_get_type(),
20    }
21}
22
23impl Coordinate {
24    pub const NONE: Option<&'static Coordinate> = None;
25
26    /// Creates a new instance of #ShumateCoordinate.
27    ///
28    /// # Returns
29    ///
30    /// the created instance.
31    #[doc(alias = "shumate_coordinate_new")]
32    pub fn new() -> Coordinate {
33        assert_initialized_main_thread!();
34        unsafe { from_glib_none(ffi::shumate_coordinate_new()) }
35    }
36
37    /// Creates a new instance of #ShumateCoordinate initialized with the given
38    /// coordinates.
39    /// ## `latitude`
40    /// the latitude coordinate
41    /// ## `longitude`
42    /// the longitude coordinate
43    ///
44    /// # Returns
45    ///
46    /// the created instance.
47    #[doc(alias = "shumate_coordinate_new_full")]
48    pub fn new_full(latitude: f64, longitude: f64) -> Coordinate {
49        assert_initialized_main_thread!();
50        unsafe { from_glib_none(ffi::shumate_coordinate_new_full(latitude, longitude)) }
51    }
52
53    // rustdoc-stripper-ignore-next
54    /// Creates a new builder-pattern struct instance to construct [`Coordinate`] objects.
55    ///
56    /// This method returns an instance of [`CoordinateBuilder`](crate::builders::CoordinateBuilder) which can be used to create [`Coordinate`] objects.
57    pub fn builder() -> CoordinateBuilder {
58        CoordinateBuilder::new()
59    }
60}
61
62impl Default for Coordinate {
63    fn default() -> Self {
64        Self::new()
65    }
66}
67
68// rustdoc-stripper-ignore-next
69/// A [builder-pattern] type to construct [`Coordinate`] objects.
70///
71/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
72#[must_use = "The builder must be built to be used"]
73pub struct CoordinateBuilder {
74    builder: glib::object::ObjectBuilder<'static, Coordinate>,
75}
76
77impl CoordinateBuilder {
78    fn new() -> Self {
79        Self {
80            builder: glib::object::Object::builder(),
81        }
82    }
83
84    /// The latitude coordonate in degrees
85    pub fn latitude(self, latitude: f64) -> Self {
86        Self {
87            builder: self.builder.property("latitude", latitude),
88        }
89    }
90
91    /// The longitude coordonate in degrees
92    pub fn longitude(self, longitude: f64) -> Self {
93        Self {
94            builder: self.builder.property("longitude", longitude),
95        }
96    }
97
98    // rustdoc-stripper-ignore-next
99    /// Build the [`Coordinate`].
100    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
101    pub fn build(self) -> Coordinate {
102        assert_initialized_main_thread!();
103        self.builder.build()
104    }
105}