#![allow(rustdoc::bare_urls)]
#![allow(rustdoc::broken_intra_doc_links)]
#![allow(rustdoc::invalid_html_tags)]
#![allow(rustdoc::redundant_explicit_links)]
#[derive(Clone, Debug)]
pub struct Places {
inner: std::sync::Arc<dyn super::stub::dynamic::Places>,
}
impl Places {
pub fn builder() -> super::builder::places::ClientBuilder {
crate::new_client_builder(super::builder::places::client::Factory)
}
pub fn from_stub<T>(stub: impl Into<std::sync::Arc<T>>) -> Self
where
T: super::stub::Places + 'static,
{
Self { inner: stub.into() }
}
pub(crate) async fn new(
config: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<Self> {
let inner = Self::build_inner(config).await?;
Ok(Self { inner })
}
async fn build_inner(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<std::sync::Arc<dyn super::stub::dynamic::Places>> {
if gaxi::options::tracing_enabled(&conf) {
return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
}
Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
}
async fn build_transport(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::Places> {
super::transport::Places::new(conf).await
}
async fn build_with_tracing(
conf: gaxi::options::ClientConfig,
) -> crate::ClientBuilderResult<impl super::stub::Places> {
Self::build_transport(conf)
.await
.map(super::tracing::Places::new)
}
pub fn search_nearby(&self) -> super::builder::places::SearchNearby {
super::builder::places::SearchNearby::new(self.inner.clone())
}
pub fn search_text(&self) -> super::builder::places::SearchText {
super::builder::places::SearchText::new(self.inner.clone())
}
pub fn get_photo_media(&self) -> super::builder::places::GetPhotoMedia {
super::builder::places::GetPhotoMedia::new(self.inner.clone())
}
pub fn get_place(&self) -> super::builder::places::GetPlace {
super::builder::places::GetPlace::new(self.inner.clone())
}
pub fn autocomplete_places(&self) -> super::builder::places::AutocompletePlaces {
super::builder::places::AutocompletePlaces::new(self.inner.clone())
}
}