google_maps2/distance_matrix/request/
with_travel_mode.rs

1use crate::directions::travel_mode::TravelMode;
2use crate::distance_matrix::request::Request;
3
4impl<'a> Request<'a> {
5    /// Specify the mode of transportation.
6    ///
7    /// ## Arguments
8    ///
9    /// * `travel_mode` ‧ The mode of transportation that distance matrix should
10    /// be calculated for. For example, _transit_ distances or car _driving_
11    /// distances.
12    ///
13    /// ## Description
14    ///
15    /// [Travel Modes](https://developers.google.com/maps/documentation/distance-matrix/intro#travel_modes)
16    ///
17    /// For the calculation of distances, you may specify the transportation
18    /// mode to use. By default, distances are calculated for driving mode.
19    ///
20    /// * `TravelMode::Driving` (default) indicates distance calculation using
21    /// the road network.
22    ///
23    /// * `TravelMode::Walking` requests distance calculation for walking via
24    /// pedestrian paths & sidewalks (where available).
25    ///
26    /// * `TravelMode::Bicycling` requests distance calculation for bicycling
27    /// via bicycle paths & preferred streets (where available).
28    ///
29    /// * `TravelMode::Transit` requests distance calculation via public transit
30    /// routes (where available). If you set the travel mode to
31    /// `TravelMode::Transit`, you can optionally use either
32    /// `with_departure_time()` or `with_arrival_time()` methods. If neither
33    /// time is specified, the departure time defaults to now (that is, the
34    /// departure time defaults to the current time). You can also optionally
35    /// use `with_transit_mode()` and/or `with_transit_route_preference()`
36    /// methods.
37    ///
38    /// _Note_: Both walking and bicycling routes may sometimes not include
39    /// clear pedestrian or bicycling paths, so these responses will return
40    /// `warnings` in the returned result which you must display to the user.
41    ///
42    /// ## Example
43    ///
44    /// * Set travel mode to transit:
45    /// ```rust
46    /// .with_travel_mode(TravelMode::Transit)
47    /// ```
48
49    pub fn with_travel_mode(&'a mut self, travel_mode: TravelMode) -> &'a mut Self {
50        self.travel_mode = Some(travel_mode);
51        self
52    } // fn
53} // impl