aws_sdk_location/types/_leg.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Contains the calculated route's details for each path between a pair of positions. The number of legs returned corresponds to one fewer than the total number of positions in the request.</p>
4/// <p>For example, a route with a departure position and destination position returns one leg with the positions <a href="https://docs.aws.amazon.com/location/previous/developerguide/snap-to-nearby-road.html">snapped to a nearby road</a>:</p>
5/// <ul>
6/// <li>
7/// <p>The <code>StartPosition</code> is the departure position.</p></li>
8/// <li>
9/// <p>The <code>EndPosition</code> is the destination position.</p></li>
10/// </ul>
11/// <p>A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:</p>
12/// <ul>
13/// <li>
14/// <p>Leg 1: The <code>StartPosition</code> is the departure position . The <code>EndPosition</code> is the waypoint positon.</p></li>
15/// <li>
16/// <p>Leg 2: The <code>StartPosition</code> is the waypoint position. The <code>EndPosition</code> is the destination position.</p></li>
17/// </ul>
18#[non_exhaustive]
19#[derive(::std::clone::Clone, ::std::cmp::PartialEq)]
20pub struct Leg {
21 /// <p>The starting position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
22 /// <p>If the <code>StartPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/snap-to-nearby-road.html">snapped to a nearby road</a>.</p>
23 /// </note>
24 pub start_position: ::std::vec::Vec<f64>,
25 /// <p>The terminating position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
26 /// <p>If the <code>EndPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/nap-to-nearby-road.html">snapped to a nearby road</a>.</p>
27 /// </note>
28 pub end_position: ::std::vec::Vec<f64>,
29 /// <p>The distance between the leg's <code>StartPosition</code> and <code>EndPosition</code> along a calculated route.</p>
30 /// <ul>
31 /// <li>
32 /// <p>The default measurement is <code>Kilometers</code> unless the request specifies a <code>DistanceUnit</code> of <code>Miles</code>.</p></li>
33 /// </ul>
34 pub distance: f64,
35 /// <p>The estimated travel time between the leg's <code>StartPosition</code> and <code>EndPosition</code>. The travel mode and departure time that you specify in the request determines the calculated time.</p>
36 pub duration_seconds: f64,
37 /// <p>Contains the calculated route's path as a linestring geometry.</p>
38 pub geometry: ::std::option::Option<crate::types::LegGeometry>,
39 /// <p>Contains a list of steps, which represent subsections of a leg. Each step provides instructions for how to move to the next step in the leg such as the step's start position, end position, travel distance, travel duration, and geometry offset.</p>
40 pub steps: ::std::vec::Vec<crate::types::Step>,
41}
42impl Leg {
43 /// <p>The starting position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
44 /// <p>If the <code>StartPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/snap-to-nearby-road.html">snapped to a nearby road</a>.</p>
45 /// </note>
46 pub fn start_position(&self) -> &[f64] {
47 use std::ops::Deref;
48 self.start_position.deref()
49 }
50 /// <p>The terminating position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
51 /// <p>If the <code>EndPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/nap-to-nearby-road.html">snapped to a nearby road</a>.</p>
52 /// </note>
53 pub fn end_position(&self) -> &[f64] {
54 use std::ops::Deref;
55 self.end_position.deref()
56 }
57 /// <p>The distance between the leg's <code>StartPosition</code> and <code>EndPosition</code> along a calculated route.</p>
58 /// <ul>
59 /// <li>
60 /// <p>The default measurement is <code>Kilometers</code> unless the request specifies a <code>DistanceUnit</code> of <code>Miles</code>.</p></li>
61 /// </ul>
62 pub fn distance(&self) -> f64 {
63 self.distance
64 }
65 /// <p>The estimated travel time between the leg's <code>StartPosition</code> and <code>EndPosition</code>. The travel mode and departure time that you specify in the request determines the calculated time.</p>
66 pub fn duration_seconds(&self) -> f64 {
67 self.duration_seconds
68 }
69 /// <p>Contains the calculated route's path as a linestring geometry.</p>
70 pub fn geometry(&self) -> ::std::option::Option<&crate::types::LegGeometry> {
71 self.geometry.as_ref()
72 }
73 /// <p>Contains a list of steps, which represent subsections of a leg. Each step provides instructions for how to move to the next step in the leg such as the step's start position, end position, travel distance, travel duration, and geometry offset.</p>
74 pub fn steps(&self) -> &[crate::types::Step] {
75 use std::ops::Deref;
76 self.steps.deref()
77 }
78}
79impl ::std::fmt::Debug for Leg {
80 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
81 let mut formatter = f.debug_struct("Leg");
82 formatter.field("start_position", &"*** Sensitive Data Redacted ***");
83 formatter.field("end_position", &"*** Sensitive Data Redacted ***");
84 formatter.field("distance", &"*** Sensitive Data Redacted ***");
85 formatter.field("duration_seconds", &"*** Sensitive Data Redacted ***");
86 formatter.field("geometry", &self.geometry);
87 formatter.field("steps", &self.steps);
88 formatter.finish()
89 }
90}
91impl Leg {
92 /// Creates a new builder-style object to manufacture [`Leg`](crate::types::Leg).
93 pub fn builder() -> crate::types::builders::LegBuilder {
94 crate::types::builders::LegBuilder::default()
95 }
96}
97
98/// A builder for [`Leg`](crate::types::Leg).
99#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default)]
100#[non_exhaustive]
101pub struct LegBuilder {
102 pub(crate) start_position: ::std::option::Option<::std::vec::Vec<f64>>,
103 pub(crate) end_position: ::std::option::Option<::std::vec::Vec<f64>>,
104 pub(crate) distance: ::std::option::Option<f64>,
105 pub(crate) duration_seconds: ::std::option::Option<f64>,
106 pub(crate) geometry: ::std::option::Option<crate::types::LegGeometry>,
107 pub(crate) steps: ::std::option::Option<::std::vec::Vec<crate::types::Step>>,
108}
109impl LegBuilder {
110 /// Appends an item to `start_position`.
111 ///
112 /// To override the contents of this collection use [`set_start_position`](Self::set_start_position).
113 ///
114 /// <p>The starting position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
115 /// <p>If the <code>StartPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/snap-to-nearby-road.html">snapped to a nearby road</a>.</p>
116 /// </note>
117 pub fn start_position(mut self, input: f64) -> Self {
118 let mut v = self.start_position.unwrap_or_default();
119 v.push(input);
120 self.start_position = ::std::option::Option::Some(v);
121 self
122 }
123 /// <p>The starting position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
124 /// <p>If the <code>StartPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/snap-to-nearby-road.html">snapped to a nearby road</a>.</p>
125 /// </note>
126 pub fn set_start_position(mut self, input: ::std::option::Option<::std::vec::Vec<f64>>) -> Self {
127 self.start_position = input;
128 self
129 }
130 /// <p>The starting position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
131 /// <p>If the <code>StartPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/snap-to-nearby-road.html">snapped to a nearby road</a>.</p>
132 /// </note>
133 pub fn get_start_position(&self) -> &::std::option::Option<::std::vec::Vec<f64>> {
134 &self.start_position
135 }
136 /// Appends an item to `end_position`.
137 ///
138 /// To override the contents of this collection use [`set_end_position`](Self::set_end_position).
139 ///
140 /// <p>The terminating position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
141 /// <p>If the <code>EndPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/nap-to-nearby-road.html">snapped to a nearby road</a>.</p>
142 /// </note>
143 pub fn end_position(mut self, input: f64) -> Self {
144 let mut v = self.end_position.unwrap_or_default();
145 v.push(input);
146 self.end_position = ::std::option::Option::Some(v);
147 self
148 }
149 /// <p>The terminating position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
150 /// <p>If the <code>EndPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/nap-to-nearby-road.html">snapped to a nearby road</a>.</p>
151 /// </note>
152 pub fn set_end_position(mut self, input: ::std::option::Option<::std::vec::Vec<f64>>) -> Self {
153 self.end_position = input;
154 self
155 }
156 /// <p>The terminating position of the leg. Follows the format <code>\[longitude,latitude\]</code>.</p><note>
157 /// <p>If the <code>EndPosition</code> isn't located on a road, it's <a href="https://docs.aws.amazon.com/location/previous/developerguide/nap-to-nearby-road.html">snapped to a nearby road</a>.</p>
158 /// </note>
159 pub fn get_end_position(&self) -> &::std::option::Option<::std::vec::Vec<f64>> {
160 &self.end_position
161 }
162 /// <p>The distance between the leg's <code>StartPosition</code> and <code>EndPosition</code> along a calculated route.</p>
163 /// <ul>
164 /// <li>
165 /// <p>The default measurement is <code>Kilometers</code> unless the request specifies a <code>DistanceUnit</code> of <code>Miles</code>.</p></li>
166 /// </ul>
167 /// This field is required.
168 pub fn distance(mut self, input: f64) -> Self {
169 self.distance = ::std::option::Option::Some(input);
170 self
171 }
172 /// <p>The distance between the leg's <code>StartPosition</code> and <code>EndPosition</code> along a calculated route.</p>
173 /// <ul>
174 /// <li>
175 /// <p>The default measurement is <code>Kilometers</code> unless the request specifies a <code>DistanceUnit</code> of <code>Miles</code>.</p></li>
176 /// </ul>
177 pub fn set_distance(mut self, input: ::std::option::Option<f64>) -> Self {
178 self.distance = input;
179 self
180 }
181 /// <p>The distance between the leg's <code>StartPosition</code> and <code>EndPosition</code> along a calculated route.</p>
182 /// <ul>
183 /// <li>
184 /// <p>The default measurement is <code>Kilometers</code> unless the request specifies a <code>DistanceUnit</code> of <code>Miles</code>.</p></li>
185 /// </ul>
186 pub fn get_distance(&self) -> &::std::option::Option<f64> {
187 &self.distance
188 }
189 /// <p>The estimated travel time between the leg's <code>StartPosition</code> and <code>EndPosition</code>. The travel mode and departure time that you specify in the request determines the calculated time.</p>
190 /// This field is required.
191 pub fn duration_seconds(mut self, input: f64) -> Self {
192 self.duration_seconds = ::std::option::Option::Some(input);
193 self
194 }
195 /// <p>The estimated travel time between the leg's <code>StartPosition</code> and <code>EndPosition</code>. The travel mode and departure time that you specify in the request determines the calculated time.</p>
196 pub fn set_duration_seconds(mut self, input: ::std::option::Option<f64>) -> Self {
197 self.duration_seconds = input;
198 self
199 }
200 /// <p>The estimated travel time between the leg's <code>StartPosition</code> and <code>EndPosition</code>. The travel mode and departure time that you specify in the request determines the calculated time.</p>
201 pub fn get_duration_seconds(&self) -> &::std::option::Option<f64> {
202 &self.duration_seconds
203 }
204 /// <p>Contains the calculated route's path as a linestring geometry.</p>
205 pub fn geometry(mut self, input: crate::types::LegGeometry) -> Self {
206 self.geometry = ::std::option::Option::Some(input);
207 self
208 }
209 /// <p>Contains the calculated route's path as a linestring geometry.</p>
210 pub fn set_geometry(mut self, input: ::std::option::Option<crate::types::LegGeometry>) -> Self {
211 self.geometry = input;
212 self
213 }
214 /// <p>Contains the calculated route's path as a linestring geometry.</p>
215 pub fn get_geometry(&self) -> &::std::option::Option<crate::types::LegGeometry> {
216 &self.geometry
217 }
218 /// Appends an item to `steps`.
219 ///
220 /// To override the contents of this collection use [`set_steps`](Self::set_steps).
221 ///
222 /// <p>Contains a list of steps, which represent subsections of a leg. Each step provides instructions for how to move to the next step in the leg such as the step's start position, end position, travel distance, travel duration, and geometry offset.</p>
223 pub fn steps(mut self, input: crate::types::Step) -> Self {
224 let mut v = self.steps.unwrap_or_default();
225 v.push(input);
226 self.steps = ::std::option::Option::Some(v);
227 self
228 }
229 /// <p>Contains a list of steps, which represent subsections of a leg. Each step provides instructions for how to move to the next step in the leg such as the step's start position, end position, travel distance, travel duration, and geometry offset.</p>
230 pub fn set_steps(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Step>>) -> Self {
231 self.steps = input;
232 self
233 }
234 /// <p>Contains a list of steps, which represent subsections of a leg. Each step provides instructions for how to move to the next step in the leg such as the step's start position, end position, travel distance, travel duration, and geometry offset.</p>
235 pub fn get_steps(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Step>> {
236 &self.steps
237 }
238 /// Consumes the builder and constructs a [`Leg`](crate::types::Leg).
239 /// This method will fail if any of the following fields are not set:
240 /// - [`start_position`](crate::types::builders::LegBuilder::start_position)
241 /// - [`end_position`](crate::types::builders::LegBuilder::end_position)
242 /// - [`distance`](crate::types::builders::LegBuilder::distance)
243 /// - [`duration_seconds`](crate::types::builders::LegBuilder::duration_seconds)
244 /// - [`steps`](crate::types::builders::LegBuilder::steps)
245 pub fn build(self) -> ::std::result::Result<crate::types::Leg, ::aws_smithy_types::error::operation::BuildError> {
246 ::std::result::Result::Ok(crate::types::Leg {
247 start_position: self.start_position.ok_or_else(|| {
248 ::aws_smithy_types::error::operation::BuildError::missing_field(
249 "start_position",
250 "start_position was not specified but it is required when building Leg",
251 )
252 })?,
253 end_position: self.end_position.ok_or_else(|| {
254 ::aws_smithy_types::error::operation::BuildError::missing_field(
255 "end_position",
256 "end_position was not specified but it is required when building Leg",
257 )
258 })?,
259 distance: self.distance.ok_or_else(|| {
260 ::aws_smithy_types::error::operation::BuildError::missing_field(
261 "distance",
262 "distance was not specified but it is required when building Leg",
263 )
264 })?,
265 duration_seconds: self.duration_seconds.ok_or_else(|| {
266 ::aws_smithy_types::error::operation::BuildError::missing_field(
267 "duration_seconds",
268 "duration_seconds was not specified but it is required when building Leg",
269 )
270 })?,
271 geometry: self.geometry,
272 steps: self.steps.ok_or_else(|| {
273 ::aws_smithy_types::error::operation::BuildError::missing_field(
274 "steps",
275 "steps was not specified but it is required when building Leg",
276 )
277 })?,
278 })
279 }
280}
281impl ::std::fmt::Debug for LegBuilder {
282 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
283 let mut formatter = f.debug_struct("LegBuilder");
284 formatter.field("start_position", &"*** Sensitive Data Redacted ***");
285 formatter.field("end_position", &"*** Sensitive Data Redacted ***");
286 formatter.field("distance", &"*** Sensitive Data Redacted ***");
287 formatter.field("duration_seconds", &"*** Sensitive Data Redacted ***");
288 formatter.field("geometry", &self.geometry);
289 formatter.field("steps", &self.steps);
290 formatter.finish()
291 }
292}