pub struct PexelsClient { /* private fields */ }Expand description
Main client for the Pexels API
This client provides methods to interact with all endpoints of the Pexels API and handles authentication, request building and response parsing.
Implementations§
Source§impl PexelsClient
impl PexelsClient
Sourcepub fn with_config<S: Into<String>>(
api_key: S,
timeout: u64,
max_idle_connections: usize,
) -> Self
pub fn with_config<S: Into<String>>( api_key: S, timeout: u64, max_idle_connections: usize, ) -> Self
Sourcepub fn with_base_url<S: Into<String>>(self, base_url: S) -> Self
pub fn with_base_url<S: Into<String>>(self, base_url: S) -> Self
Sourcepub async fn search_photos(
&self,
query: &str,
params: &SearchParams,
) -> Result<PhotosPage, PexelsError>
pub async fn search_photos( &self, query: &str, params: &SearchParams, ) -> Result<PhotosPage, PexelsError>
Search for photos matching the specified query and parameters
§Arguments
query- The search queryparams- Additional search parameters (pagination, filters, etc.)
§Returns
A Result containing the photos search response or an error
§Example
use pexels_api::{PexelsClient, SearchParams,Size};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = PexelsClient::new("your_api_key");
let params = SearchParams::new()
.page(1)
.per_page(15)
.size(Size::Large);
let photos = client.search_photos("nature", ¶ms).await?;
println!("Found {} photos", photos.total_results);
Ok(())
}Sourcepub async fn curated_photos(
&self,
params: &PaginationParams,
) -> Result<PhotosPage, PexelsError>
pub async fn curated_photos( &self, params: &PaginationParams, ) -> Result<PhotosPage, PexelsError>
Sourcepub async fn get_photo(&self, id: u64) -> Result<Photo, PexelsError>
pub async fn get_photo(&self, id: u64) -> Result<Photo, PexelsError>
Sourcepub async fn search_videos(
&self,
query: &str,
params: &VideoSearchParams,
) -> Result<VideosPage, PexelsError>
pub async fn search_videos( &self, query: &str, params: &VideoSearchParams, ) -> Result<VideosPage, PexelsError>
Sourcepub async fn popular_videos(
&self,
params: &PaginationParams,
) -> Result<VideosPage, PexelsError>
pub async fn popular_videos( &self, params: &PaginationParams, ) -> Result<VideosPage, PexelsError>
Sourcepub async fn popular_videos_with_params(
&self,
params: &PopularVideoParams,
) -> Result<VideosPage, PexelsError>
pub async fn popular_videos_with_params( &self, params: &PopularVideoParams, ) -> Result<VideosPage, PexelsError>
Sourcepub async fn get_video(&self, id: u64) -> Result<Video, PexelsError>
pub async fn get_video(&self, id: u64) -> Result<Video, PexelsError>
Sourcepub async fn get_collections(
&self,
params: &PaginationParams,
) -> Result<CollectionsPage, PexelsError>
pub async fn get_collections( &self, params: &PaginationParams, ) -> Result<CollectionsPage, PexelsError>
Sourcepub async fn get_featured_collections(
&self,
params: &PaginationParams,
) -> Result<CollectionsPage, PexelsError>
pub async fn get_featured_collections( &self, params: &PaginationParams, ) -> Result<CollectionsPage, PexelsError>
Sourcepub async fn get_collection_media(
&self,
id: &str,
params: &PaginationParams,
) -> Result<MediaPage, PexelsError>
pub async fn get_collection_media( &self, id: &str, params: &PaginationParams, ) -> Result<MediaPage, PexelsError>
Sourcepub async fn get_collection_media_with_params(
&self,
id: &str,
params: &CollectionMediaParams,
) -> Result<MediaPage, PexelsError>
pub async fn get_collection_media_with_params( &self, id: &str, params: &CollectionMediaParams, ) -> Result<MediaPage, PexelsError>
Auto Trait Implementations§
impl !RefUnwindSafe for PexelsClient
impl !UnwindSafe for PexelsClient
impl Freeze for PexelsClient
impl Send for PexelsClient
impl Sync for PexelsClient
impl Unpin for PexelsClient
impl UnsafeUnpin for PexelsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more