Skip to main content

google_geo_type/
model.rs

1// Copyright 2026 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21#![no_implicit_prelude]
22extern crate bytes;
23extern crate google_cloud_type;
24extern crate serde;
25extern crate serde_json;
26extern crate serde_with;
27extern crate std;
28extern crate wkt;
29
30mod debug;
31mod deserialize;
32mod serialize;
33
34/// A latitude-longitude viewport, represented as two diagonally opposite `low`
35/// and `high` points. A viewport is considered a closed region, i.e. it includes
36/// its boundary. The latitude bounds must range between -90 to 90 degrees
37/// inclusive, and the longitude bounds must range between -180 to 180 degrees
38/// inclusive. Various cases include:
39///
40/// - If `low` = `high`, the viewport consists of that single point.
41///
42/// - If `low.longitude` > `high.longitude`, the longitude range is inverted
43///   (the viewport crosses the 180 degree longitude line).
44///
45/// - If `low.longitude` = -180 degrees and `high.longitude` = 180 degrees,
46///   the viewport includes all longitudes.
47///
48/// - If `low.longitude` = 180 degrees and `high.longitude` = -180 degrees,
49///   the longitude range is empty.
50///
51/// - If `low.latitude` > `high.latitude`, the latitude range is empty.
52///
53///
54/// Both `low` and `high` must be populated, and the represented box cannot be
55/// empty (as specified by the definitions above). An empty viewport will result
56/// in an error.
57///
58/// For example, this viewport fully encloses New York City:
59///
60/// {
61/// "low": {
62/// "latitude": 40.477398,
63/// "longitude": -74.259087
64/// },
65/// "high": {
66/// "latitude": 40.91618,
67/// "longitude": -73.70018
68/// }
69/// }
70#[derive(Clone, Default, PartialEq)]
71#[non_exhaustive]
72pub struct Viewport {
73    /// Required. The low point of the viewport.
74    pub low: std::option::Option<google_cloud_type::model::LatLng>,
75
76    /// Required. The high point of the viewport.
77    pub high: std::option::Option<google_cloud_type::model::LatLng>,
78
79    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
80}
81
82impl Viewport {
83    /// Creates a new default instance.
84    pub fn new() -> Self {
85        std::default::Default::default()
86    }
87
88    /// Sets the value of [low][crate::model::Viewport::low].
89    ///
90    /// # Example
91    /// ```ignore,no_run
92    /// # use google_geo_type::model::Viewport;
93    /// use google_cloud_type::model::LatLng;
94    /// let x = Viewport::new().set_low(LatLng::default()/* use setters */);
95    /// ```
96    pub fn set_low<T>(mut self, v: T) -> Self
97    where
98        T: std::convert::Into<google_cloud_type::model::LatLng>,
99    {
100        self.low = std::option::Option::Some(v.into());
101        self
102    }
103
104    /// Sets or clears the value of [low][crate::model::Viewport::low].
105    ///
106    /// # Example
107    /// ```ignore,no_run
108    /// # use google_geo_type::model::Viewport;
109    /// use google_cloud_type::model::LatLng;
110    /// let x = Viewport::new().set_or_clear_low(Some(LatLng::default()/* use setters */));
111    /// let x = Viewport::new().set_or_clear_low(None::<LatLng>);
112    /// ```
113    pub fn set_or_clear_low<T>(mut self, v: std::option::Option<T>) -> Self
114    where
115        T: std::convert::Into<google_cloud_type::model::LatLng>,
116    {
117        self.low = v.map(|x| x.into());
118        self
119    }
120
121    /// Sets the value of [high][crate::model::Viewport::high].
122    ///
123    /// # Example
124    /// ```ignore,no_run
125    /// # use google_geo_type::model::Viewport;
126    /// use google_cloud_type::model::LatLng;
127    /// let x = Viewport::new().set_high(LatLng::default()/* use setters */);
128    /// ```
129    pub fn set_high<T>(mut self, v: T) -> Self
130    where
131        T: std::convert::Into<google_cloud_type::model::LatLng>,
132    {
133        self.high = std::option::Option::Some(v.into());
134        self
135    }
136
137    /// Sets or clears the value of [high][crate::model::Viewport::high].
138    ///
139    /// # Example
140    /// ```ignore,no_run
141    /// # use google_geo_type::model::Viewport;
142    /// use google_cloud_type::model::LatLng;
143    /// let x = Viewport::new().set_or_clear_high(Some(LatLng::default()/* use setters */));
144    /// let x = Viewport::new().set_or_clear_high(None::<LatLng>);
145    /// ```
146    pub fn set_or_clear_high<T>(mut self, v: std::option::Option<T>) -> Self
147    where
148        T: std::convert::Into<google_cloud_type::model::LatLng>,
149    {
150        self.high = v.map(|x| x.into());
151        self
152    }
153}
154
155impl wkt::message::Message for Viewport {
156    fn typename() -> &'static str {
157        "type.googleapis.com/google.geo.type.Viewport"
158    }
159}