google-maps-roads-v1op 1.0.0

Google Cloud Client Libraries for Rust - Roads API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::bare_urls)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::invalid_html_tags)]
#![allow(rustdoc::redundant_explicit_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gaxi;
extern crate google_cloud_gax;
extern crate google_cloud_type;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A request to the SnapToRoads method, requesting that a sequence of points be
/// snapped to road segments.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SnapToRoadsRequest {
    /// The path to be snapped as a series of lat, lng points. Specified as
    /// a string of the format: lat,lng|lat,lng|...
    pub path: std::string::String,

    /// Whether to interpolate the points to return full road geometry.
    pub interpolate: bool,

    /// The asset ID of the asset to which this path relates. This is used for
    /// abuse detection purposes for clients with asset-based SKUs.
    pub asset_id: std::string::String,

    /// The type of travel being tracked. This will constrain the paths we snap to.
    pub travel_mode: crate::model::TravelMode,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SnapToRoadsRequest {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [path][crate::model::SnapToRoadsRequest::path].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnapToRoadsRequest;
    /// let x = SnapToRoadsRequest::new().set_path("example");
    /// ```
    pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.path = v.into();
        self
    }

    /// Sets the value of [interpolate][crate::model::SnapToRoadsRequest::interpolate].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnapToRoadsRequest;
    /// let x = SnapToRoadsRequest::new().set_interpolate(true);
    /// ```
    pub fn set_interpolate<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.interpolate = v.into();
        self
    }

    /// Sets the value of [asset_id][crate::model::SnapToRoadsRequest::asset_id].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnapToRoadsRequest;
    /// let x = SnapToRoadsRequest::new().set_asset_id("example");
    /// ```
    pub fn set_asset_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.asset_id = v.into();
        self
    }

    /// Sets the value of [travel_mode][crate::model::SnapToRoadsRequest::travel_mode].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnapToRoadsRequest;
    /// use google_maps_roads_v1op::model::TravelMode;
    /// let x0 = SnapToRoadsRequest::new().set_travel_mode(TravelMode::Driving);
    /// let x1 = SnapToRoadsRequest::new().set_travel_mode(TravelMode::Cycling);
    /// let x2 = SnapToRoadsRequest::new().set_travel_mode(TravelMode::Walking);
    /// ```
    pub fn set_travel_mode<T: std::convert::Into<crate::model::TravelMode>>(
        mut self,
        v: T,
    ) -> Self {
        self.travel_mode = v.into();
        self
    }
}

impl wkt::message::Message for SnapToRoadsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.maps.roads.v1op.SnapToRoadsRequest"
    }
}

/// A snapped point object, representing the result of snapping.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SnappedPoint {
    /// The lat,lng of the snapped location.
    pub location: std::option::Option<google_cloud_type::model::LatLng>,

    /// The index into the original path of the equivalent pre-snapped point.
    /// This allows for identification of points which have been interpolated if
    /// this index is missing.
    pub original_index: std::option::Option<wkt::UInt32Value>,

    /// The place ID for this snapped location (road segment). These are the same
    /// as are currently used by the Places API.
    pub place_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SnappedPoint {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [location][crate::model::SnappedPoint::location].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnappedPoint;
    /// use google_cloud_type::model::LatLng;
    /// let x = SnappedPoint::new().set_location(LatLng::default()/* use setters */);
    /// ```
    pub fn set_location<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_type::model::LatLng>,
    {
        self.location = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [location][crate::model::SnappedPoint::location].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnappedPoint;
    /// use google_cloud_type::model::LatLng;
    /// let x = SnappedPoint::new().set_or_clear_location(Some(LatLng::default()/* use setters */));
    /// let x = SnappedPoint::new().set_or_clear_location(None::<LatLng>);
    /// ```
    pub fn set_or_clear_location<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_type::model::LatLng>,
    {
        self.location = v.map(|x| x.into());
        self
    }

    /// Sets the value of [original_index][crate::model::SnappedPoint::original_index].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnappedPoint;
    /// use wkt::UInt32Value;
    /// let x = SnappedPoint::new().set_original_index(UInt32Value::default()/* use setters */);
    /// ```
    pub fn set_original_index<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::UInt32Value>,
    {
        self.original_index = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [original_index][crate::model::SnappedPoint::original_index].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnappedPoint;
    /// use wkt::UInt32Value;
    /// let x = SnappedPoint::new().set_or_clear_original_index(Some(UInt32Value::default()/* use setters */));
    /// let x = SnappedPoint::new().set_or_clear_original_index(None::<UInt32Value>);
    /// ```
    pub fn set_or_clear_original_index<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::UInt32Value>,
    {
        self.original_index = v.map(|x| x.into());
        self
    }

    /// Sets the value of [place_id][crate::model::SnappedPoint::place_id].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnappedPoint;
    /// let x = SnappedPoint::new().set_place_id("example");
    /// ```
    pub fn set_place_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.place_id = v.into();
        self
    }
}

impl wkt::message::Message for SnappedPoint {
    fn typename() -> &'static str {
        "type.googleapis.com/google.maps.roads.v1op.SnappedPoint"
    }
}

/// The response from the SnapToRoads method, returning a sequence of snapped
/// points.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SnapToRoadsResponse {
    /// A list of snapped points.
    pub snapped_points: std::vec::Vec<crate::model::SnappedPoint>,

    /// User-visible warning message, if any, which can be shown alongside a valid
    /// result.
    pub warning_message: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SnapToRoadsResponse {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [snapped_points][crate::model::SnapToRoadsResponse::snapped_points].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnapToRoadsResponse;
    /// use google_maps_roads_v1op::model::SnappedPoint;
    /// let x = SnapToRoadsResponse::new()
    ///     .set_snapped_points([
    ///         SnappedPoint::default()/* use setters */,
    ///         SnappedPoint::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_snapped_points<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::SnappedPoint>,
    {
        use std::iter::Iterator;
        self.snapped_points = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [warning_message][crate::model::SnapToRoadsResponse::warning_message].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::SnapToRoadsResponse;
    /// let x = SnapToRoadsResponse::new().set_warning_message("example");
    /// ```
    pub fn set_warning_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.warning_message = v.into();
        self
    }
}

impl wkt::message::Message for SnapToRoadsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.maps.roads.v1op.SnapToRoadsResponse"
    }
}

/// A request to the ListNearestRoads method, requesting that a sequence of
/// points be snapped individually to the road segment that each is closest to.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListNearestRoadsRequest {
    /// The points to be snapped as a series of lat, lng points. Specified as
    /// a string of the format: lat,lng|lat,lng|...
    pub points: std::string::String,

    /// The type of travel being tracked. This will constrain the roads we snap to.
    pub travel_mode: crate::model::TravelMode,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListNearestRoadsRequest {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [points][crate::model::ListNearestRoadsRequest::points].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::ListNearestRoadsRequest;
    /// let x = ListNearestRoadsRequest::new().set_points("example");
    /// ```
    pub fn set_points<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.points = v.into();
        self
    }

    /// Sets the value of [travel_mode][crate::model::ListNearestRoadsRequest::travel_mode].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::ListNearestRoadsRequest;
    /// use google_maps_roads_v1op::model::TravelMode;
    /// let x0 = ListNearestRoadsRequest::new().set_travel_mode(TravelMode::Driving);
    /// let x1 = ListNearestRoadsRequest::new().set_travel_mode(TravelMode::Cycling);
    /// let x2 = ListNearestRoadsRequest::new().set_travel_mode(TravelMode::Walking);
    /// ```
    pub fn set_travel_mode<T: std::convert::Into<crate::model::TravelMode>>(
        mut self,
        v: T,
    ) -> Self {
        self.travel_mode = v.into();
        self
    }
}

impl wkt::message::Message for ListNearestRoadsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.maps.roads.v1op.ListNearestRoadsRequest"
    }
}

/// The response from the ListNearestRoads method, returning a list of snapped
/// points.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListNearestRoadsResponse {
    /// A list of snapped points.
    pub snapped_points: std::vec::Vec<crate::model::SnappedPoint>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListNearestRoadsResponse {
    /// Creates a new default instance.
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [snapped_points][crate::model::ListNearestRoadsResponse::snapped_points].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_maps_roads_v1op::model::ListNearestRoadsResponse;
    /// use google_maps_roads_v1op::model::SnappedPoint;
    /// let x = ListNearestRoadsResponse::new()
    ///     .set_snapped_points([
    ///         SnappedPoint::default()/* use setters */,
    ///         SnappedPoint::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_snapped_points<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::SnappedPoint>,
    {
        use std::iter::Iterator;
        self.snapped_points = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListNearestRoadsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.maps.roads.v1op.ListNearestRoadsResponse"
    }
}

/// An enum representing the mode of travel used for snapping.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum TravelMode {
    #[allow(missing_docs)]
    Unspecified,
    #[allow(missing_docs)]
    Driving,
    #[allow(missing_docs)]
    Cycling,
    #[allow(missing_docs)]
    Walking,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [TravelMode::value] or
    /// [TravelMode::name].
    UnknownValue(travel_mode::UnknownValue),
}

#[doc(hidden)]
pub mod travel_mode {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl TravelMode {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Driving => std::option::Option::Some(1),
            Self::Cycling => std::option::Option::Some(2),
            Self::Walking => std::option::Option::Some(3),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("TRAVEL_MODE_UNSPECIFIED"),
            Self::Driving => std::option::Option::Some("DRIVING"),
            Self::Cycling => std::option::Option::Some("CYCLING"),
            Self::Walking => std::option::Option::Some("WALKING"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for TravelMode {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for TravelMode {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for TravelMode {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Driving,
            2 => Self::Cycling,
            3 => Self::Walking,
            _ => Self::UnknownValue(travel_mode::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for TravelMode {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "TRAVEL_MODE_UNSPECIFIED" => Self::Unspecified,
            "DRIVING" => Self::Driving,
            "CYCLING" => Self::Cycling,
            "WALKING" => Self::Walking,
            _ => Self::UnknownValue(travel_mode::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for TravelMode {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Driving => serializer.serialize_i32(1),
            Self::Cycling => serializer.serialize_i32(2),
            Self::Walking => serializer.serialize_i32(3),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for TravelMode {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<TravelMode>::new(
            ".google.maps.roads.v1op.TravelMode",
        ))
    }
}