aws_sdk_location/operation/calculate_route/_calculate_route_output.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2
3/// <p>Returns the result of the route calculation. Metadata includes legs and route summary.</p>
4#[non_exhaustive]
5#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::fmt::Debug)]
6pub struct CalculateRouteOutput {
7 /// <p>Contains details about each path between a pair of positions included along a route such as: <code>StartPosition</code>, <code>EndPosition</code>, <code>Distance</code>, <code>DurationSeconds</code>, <code>Geometry</code>, and <code>Steps</code>. The number of legs returned corresponds to one fewer than the total number of positions in the request.</p>
8 /// <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>
9 /// <ul>
10 /// <li>
11 /// <p>The <code>StartPosition</code> is the departure position.</p></li>
12 /// <li>
13 /// <p>The <code>EndPosition</code> is the destination position.</p></li>
14 /// </ul>
15 /// <p>A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:</p>
16 /// <ul>
17 /// <li>
18 /// <p>Leg 1: The <code>StartPosition</code> is the departure position . The <code>EndPosition</code> is the waypoint positon.</p></li>
19 /// <li>
20 /// <p>Leg 2: The <code>StartPosition</code> is the waypoint position. The <code>EndPosition</code> is the destination position.</p></li>
21 /// </ul>
22 pub legs: ::std::vec::Vec<crate::types::Leg>,
23 /// <p>Contains information about the whole route, such as: <code>RouteBBox</code>, <code>DataSource</code>, <code>Distance</code>, <code>DistanceUnit</code>, and <code>DurationSeconds</code>.</p>
24 pub summary: ::std::option::Option<crate::types::CalculateRouteSummary>,
25 _request_id: Option<String>,
26}
27impl CalculateRouteOutput {
28 /// <p>Contains details about each path between a pair of positions included along a route such as: <code>StartPosition</code>, <code>EndPosition</code>, <code>Distance</code>, <code>DurationSeconds</code>, <code>Geometry</code>, and <code>Steps</code>. The number of legs returned corresponds to one fewer than the total number of positions in the request.</p>
29 /// <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>
30 /// <ul>
31 /// <li>
32 /// <p>The <code>StartPosition</code> is the departure position.</p></li>
33 /// <li>
34 /// <p>The <code>EndPosition</code> is the destination position.</p></li>
35 /// </ul>
36 /// <p>A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:</p>
37 /// <ul>
38 /// <li>
39 /// <p>Leg 1: The <code>StartPosition</code> is the departure position . The <code>EndPosition</code> is the waypoint positon.</p></li>
40 /// <li>
41 /// <p>Leg 2: The <code>StartPosition</code> is the waypoint position. The <code>EndPosition</code> is the destination position.</p></li>
42 /// </ul>
43 pub fn legs(&self) -> &[crate::types::Leg] {
44 use std::ops::Deref;
45 self.legs.deref()
46 }
47 /// <p>Contains information about the whole route, such as: <code>RouteBBox</code>, <code>DataSource</code>, <code>Distance</code>, <code>DistanceUnit</code>, and <code>DurationSeconds</code>.</p>
48 pub fn summary(&self) -> ::std::option::Option<&crate::types::CalculateRouteSummary> {
49 self.summary.as_ref()
50 }
51}
52impl ::aws_types::request_id::RequestId for CalculateRouteOutput {
53 fn request_id(&self) -> Option<&str> {
54 self._request_id.as_deref()
55 }
56}
57impl CalculateRouteOutput {
58 /// Creates a new builder-style object to manufacture [`CalculateRouteOutput`](crate::operation::calculate_route::CalculateRouteOutput).
59 pub fn builder() -> crate::operation::calculate_route::builders::CalculateRouteOutputBuilder {
60 crate::operation::calculate_route::builders::CalculateRouteOutputBuilder::default()
61 }
62}
63
64/// A builder for [`CalculateRouteOutput`](crate::operation::calculate_route::CalculateRouteOutput).
65#[derive(::std::clone::Clone, ::std::cmp::PartialEq, ::std::default::Default, ::std::fmt::Debug)]
66#[non_exhaustive]
67pub struct CalculateRouteOutputBuilder {
68 pub(crate) legs: ::std::option::Option<::std::vec::Vec<crate::types::Leg>>,
69 pub(crate) summary: ::std::option::Option<crate::types::CalculateRouteSummary>,
70 _request_id: Option<String>,
71}
72impl CalculateRouteOutputBuilder {
73 /// Appends an item to `legs`.
74 ///
75 /// To override the contents of this collection use [`set_legs`](Self::set_legs).
76 ///
77 /// <p>Contains details about each path between a pair of positions included along a route such as: <code>StartPosition</code>, <code>EndPosition</code>, <code>Distance</code>, <code>DurationSeconds</code>, <code>Geometry</code>, and <code>Steps</code>. The number of legs returned corresponds to one fewer than the total number of positions in the request.</p>
78 /// <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>
79 /// <ul>
80 /// <li>
81 /// <p>The <code>StartPosition</code> is the departure position.</p></li>
82 /// <li>
83 /// <p>The <code>EndPosition</code> is the destination position.</p></li>
84 /// </ul>
85 /// <p>A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:</p>
86 /// <ul>
87 /// <li>
88 /// <p>Leg 1: The <code>StartPosition</code> is the departure position . The <code>EndPosition</code> is the waypoint positon.</p></li>
89 /// <li>
90 /// <p>Leg 2: The <code>StartPosition</code> is the waypoint position. The <code>EndPosition</code> is the destination position.</p></li>
91 /// </ul>
92 pub fn legs(mut self, input: crate::types::Leg) -> Self {
93 let mut v = self.legs.unwrap_or_default();
94 v.push(input);
95 self.legs = ::std::option::Option::Some(v);
96 self
97 }
98 /// <p>Contains details about each path between a pair of positions included along a route such as: <code>StartPosition</code>, <code>EndPosition</code>, <code>Distance</code>, <code>DurationSeconds</code>, <code>Geometry</code>, and <code>Steps</code>. The number of legs returned corresponds to one fewer than the total number of positions in the request.</p>
99 /// <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>
100 /// <ul>
101 /// <li>
102 /// <p>The <code>StartPosition</code> is the departure position.</p></li>
103 /// <li>
104 /// <p>The <code>EndPosition</code> is the destination position.</p></li>
105 /// </ul>
106 /// <p>A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:</p>
107 /// <ul>
108 /// <li>
109 /// <p>Leg 1: The <code>StartPosition</code> is the departure position . The <code>EndPosition</code> is the waypoint positon.</p></li>
110 /// <li>
111 /// <p>Leg 2: The <code>StartPosition</code> is the waypoint position. The <code>EndPosition</code> is the destination position.</p></li>
112 /// </ul>
113 pub fn set_legs(mut self, input: ::std::option::Option<::std::vec::Vec<crate::types::Leg>>) -> Self {
114 self.legs = input;
115 self
116 }
117 /// <p>Contains details about each path between a pair of positions included along a route such as: <code>StartPosition</code>, <code>EndPosition</code>, <code>Distance</code>, <code>DurationSeconds</code>, <code>Geometry</code>, and <code>Steps</code>. The number of legs returned corresponds to one fewer than the total number of positions in the request.</p>
118 /// <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>
119 /// <ul>
120 /// <li>
121 /// <p>The <code>StartPosition</code> is the departure position.</p></li>
122 /// <li>
123 /// <p>The <code>EndPosition</code> is the destination position.</p></li>
124 /// </ul>
125 /// <p>A route with a waypoint between the departure and destination position returns two legs with the positions snapped to a nearby road:</p>
126 /// <ul>
127 /// <li>
128 /// <p>Leg 1: The <code>StartPosition</code> is the departure position . The <code>EndPosition</code> is the waypoint positon.</p></li>
129 /// <li>
130 /// <p>Leg 2: The <code>StartPosition</code> is the waypoint position. The <code>EndPosition</code> is the destination position.</p></li>
131 /// </ul>
132 pub fn get_legs(&self) -> &::std::option::Option<::std::vec::Vec<crate::types::Leg>> {
133 &self.legs
134 }
135 /// <p>Contains information about the whole route, such as: <code>RouteBBox</code>, <code>DataSource</code>, <code>Distance</code>, <code>DistanceUnit</code>, and <code>DurationSeconds</code>.</p>
136 /// This field is required.
137 pub fn summary(mut self, input: crate::types::CalculateRouteSummary) -> Self {
138 self.summary = ::std::option::Option::Some(input);
139 self
140 }
141 /// <p>Contains information about the whole route, such as: <code>RouteBBox</code>, <code>DataSource</code>, <code>Distance</code>, <code>DistanceUnit</code>, and <code>DurationSeconds</code>.</p>
142 pub fn set_summary(mut self, input: ::std::option::Option<crate::types::CalculateRouteSummary>) -> Self {
143 self.summary = input;
144 self
145 }
146 /// <p>Contains information about the whole route, such as: <code>RouteBBox</code>, <code>DataSource</code>, <code>Distance</code>, <code>DistanceUnit</code>, and <code>DurationSeconds</code>.</p>
147 pub fn get_summary(&self) -> &::std::option::Option<crate::types::CalculateRouteSummary> {
148 &self.summary
149 }
150 pub(crate) fn _request_id(mut self, request_id: impl Into<String>) -> Self {
151 self._request_id = Some(request_id.into());
152 self
153 }
154
155 pub(crate) fn _set_request_id(&mut self, request_id: Option<String>) -> &mut Self {
156 self._request_id = request_id;
157 self
158 }
159 /// Consumes the builder and constructs a [`CalculateRouteOutput`](crate::operation::calculate_route::CalculateRouteOutput).
160 /// This method will fail if any of the following fields are not set:
161 /// - [`legs`](crate::operation::calculate_route::builders::CalculateRouteOutputBuilder::legs)
162 pub fn build(
163 self,
164 ) -> ::std::result::Result<crate::operation::calculate_route::CalculateRouteOutput, ::aws_smithy_types::error::operation::BuildError> {
165 ::std::result::Result::Ok(crate::operation::calculate_route::CalculateRouteOutput {
166 legs: self.legs.ok_or_else(|| {
167 ::aws_smithy_types::error::operation::BuildError::missing_field(
168 "legs",
169 "legs was not specified but it is required when building CalculateRouteOutput",
170 )
171 })?,
172 summary: self.summary,
173 _request_id: self._request_id,
174 })
175 }
176}