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 35 36 37 38 39 40 41 42 43 44
#![feature(async_await)] //! # yt-api //! //! With the `yt-api` crate you can interact asynchronously with the youtube-api. //! //! ## Performing a search query //! //! To perform a search query, you can use the [`search`][search()] shortcut function. //! //! ```rust //! # #![feature(async_await)] //! # use std::env; //! # use futures::future::{FutureExt, TryFutureExt}; //! # use yt_api::{ //! # search::SearchList, //! # ApiKey, //! # }; //! # //! # fn main() { //! let search_list = SearchList::new(ApiKey::new("your-youtube-api-key")).q("rust lang".to_string()); //! //! let future = async move { //! let result = yt_api::search(&search_list).await.unwrap(); //! }; //! //! tokio::run(future.unit_error().boxed().compat()); //! # } //! ``` mod api; use reqwest::r#async::Client; use std::result::Result; pub use api::*; /// shortcut function to search for a video, channel or playlist pub async fn search( query: &search::SearchList, ) -> Result<search::SearchListResponse, search::Error> { let client = Client::new(); search::perform(client, query).await }