#![allow(clippy::ref_option, reason = "for the getset crate")]
pub mod photo_uri;
pub use crate::places_new::place_photos::uri::response::photo_uri::PhotoUri;
use url::Url;
#[derive(
// std
Clone,
Debug,
// serde
serde::Deserialize,
serde::Serialize,
// getset
getset::Getters,
getset::MutGetters,
getset::Setters,
)]
#[serde(rename_all = "camelCase")]
pub struct Response {
#[getset(get = "pub")]
pub(crate) name: String,
#[getset(get = "pub")]
pub(crate) photo_uri: Url,
#[serde(default)]
#[getset(get = "pub")]
pub(crate) error: Option<crate::places_new::GoogleApiError>,
}
impl std::ops::Deref for Response {
type Target = Url;
fn deref(&self) -> &Self::Target {
&self.photo_uri
}
}
impl std::ops::DerefMut for Response {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.photo_uri
}
}
impl AsRef<Url> for Response {
fn as_ref(&self) -> &Url {
&self.photo_uri
}
}
impl AsMut<Url> for Response {
fn as_mut(&mut self) -> &mut Url {
&mut self.photo_uri
}
}
impl std::convert::From<Response> for Result<Response, crate::Error> {
fn from(response: Response) -> Self {
match response.error {
Some(error) => Err(crate::places_new::Error::from(error).into()),
None => Ok(response),
}
}
}