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
use crate::geocoding::{ error::Error, forward::ForwardRequest, }; impl<'a> ForwardRequest<'a> { /// Ensures the built query is valid. This function checks the combination /// of parameters to ensure that they make sense together and that Google /// Maps Geocoding API will accept them - i.e. require an address or /// components to be specified. This function does not check parameter /// values for validity - i.e. it will not Latitudes/Longitudes are valid /// and well-formed. /// /// ## Arguments: /// /// This method accepts no arguments. pub fn validate(&mut self) -> Result<&'a mut ForwardRequest, Error> { // If a positional request has been set... if self.address == None && self.components == None { return Err(Error::AddressOrComponentsRequired) } // if // Indicate that the request passed validation. self.validated = true; // Return modified Request struct to caller. Ok(self) } // fn } // impl