use crate::places::place_autocomplete::response::{
matched_substring::MatchedSubstring, structured_format::StructuredFormat, term::Term,
};
use crate::types::PlaceType;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct Prediction {
#[serde(alias = "description")]
pub description: String,
#[serde(alias = "matched_substrings")]
#[serde(default)]
pub matched_substrings: Vec<MatchedSubstring>,
#[serde(alias = "structured_formatting")]
pub structured_formatting: StructuredFormat,
#[serde(default)]
pub distance_meters: Option<u64>,
#[serde(alias = "terms")]
#[serde(default)]
pub terms: Vec<Term>,
#[serde(alias = "place_id")]
#[serde(default)]
pub place_id: Option<String>,
#[serde(alias = "types")]
#[serde(default)]
pub types: Vec<PlaceType>,
}
impl std::str::FromStr for Prediction {
type Err = serde_json::Error;
fn from_str(s: &str) -> Result<Self, serde_json::Error> {
let bytes = s.to_string().into_bytes();
serde_json::from_slice(&bytes)
} }