Trait aur::bridge::hyper::AurRequester
source · pub trait AurRequester {
fn aur_info<T: Display>(
&self,
packages: &[T]
) -> Box<dyn Future<Item = Search<InfoResult>, Error = Error> + Send>;
fn aur_search_by(
&self,
query: &str,
by: SearchBy
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send>;
fn aur_search(
&self,
query: &str
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send> { ... }
fn aur_orphans(
&self
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send> { ... }
}
Expand description
Trait which defines the methods necessary to interact with the service.
Examples
To bring in the implemenation for the hyper
Client, simply use the
trait:
use aur::AurHyperRequester;
At this point, the methods will be on your Hyper Client.
Required Methods§
sourcefn aur_info<T: Display>(
&self,
packages: &[T]
) -> Box<dyn Future<Item = Search<InfoResult>, Error = Error> + Send>
fn aur_info<T: Display>(
&self,
packages: &[T]
) -> Box<dyn Future<Item = Search<InfoResult>, Error = Error> + Send>
Retrieves information about one or more packages along with metadata.
Examples
Ensure that the "rust-nightly"
package exists:
extern crate aur;
extern crate hyper;
extern crate hyper_tls;
extern crate tokio_core;
use aur::bridge::hyper::AurRequester;
use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::Core;
let core = Core::new()?;
let handle = core.handle();
let connector = HttpsConnector::new(4, &handle)?;
let client = Client::configure().connector(connector).build(&handle);
let done = client.aur_info(&["rust-nightly"]).map(|search| {
assert_eq!(search.result_count, 1);
}).map_err(|_| ());
Errors
Resolves to Error::Fmt
if there was an error formatting the URI.
Resolves to Error::Hyper
if there was an error sending the request.
Resolves to Error::Json
if there was an error deserializing the
response body.
Resolves to Error::Uri
if there was an error parsing the Uri.
sourcefn aur_search_by(
&self,
query: &str,
by: SearchBy
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send>
fn aur_search_by(
&self,
query: &str,
by: SearchBy
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send>
Searches for packages by a query, searching by maintainer name.
Examples
Ensure that at least two packages return for the "rust"
query,
searching by name:
extern crate aur;
extern crate hyper;
extern crate hyper_tls;
extern crate tokio_core;
use aur::{
bridge::hyper::AurRequester,
model::SearchBy,
};
use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::Core;
let handle = core.handle();
let connector = HttpsConnector::new(4, handle)?;
let client = Client::configure().connector(connector).build(&handle);
let done = client.aur_search("rust", SearchBy::Name).map(|search| {
assert!(search.result_count >= 2);
}).map_err(|_| ());
Errors
Resolves to Error::Fmt
if there was an error formatting the URI.
Resolves to Error::Hyper
if there was an error sending the request.
Resolves to Error::Json
if there was an error deserializing the
response body.
Resolves to Error::Uri
if there was an error parsing the Uri.
Provided Methods§
sourcefn aur_search(
&self,
query: &str
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send>
fn aur_search(
&self,
query: &str
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send>
Search for packages by a query.
Examples
Ensure that at least two packages return for the "rust"
query, not
specifying a maintainer:
extern crate aur;
extern crate hyper;
extern crate hyper_tls;
extern crate tokio_core;
use aur::bridge::hyper::AurRequester;
use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::Core;
let handle = core.handle();
let connector = HttpsConnector::new(4, handle)?;
let client = Client::configure().connector(connector).build(&handle);
let done = client.aur_search(Some("rust"), None).map(|search| {
assert!(search.result_count >= 2);
}).map_err(|_| ());
Errors
Resolves to Error::Fmt
if there was an error formatting the URI.
Resolves to Error::Hyper
if there was an error sending the request.
Resolves to Error::Json
if there was an error deserializing the
response body.
Resolves to Error::Uri
if there was an error parsing the Uri.
sourcefn aur_orphans(
&self
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send>
fn aur_orphans(
&self
) -> Box<dyn Future<Item = Search<SearchResult>, Error = Error> + Send>
Search for a list of orphaned packages.
Examples
Retrieve a list of orphaned packages:
extern crate aur;
extern crate hyper;
extern crate hyper_tls;
extern crate tokio_core;
use aur::bridge::hyper::AurRequester;
use hyper::Client;
use hyper_tls::HttpsConnector;
use tokio_core::Core;
let handle = core.handle();
let connector = HttpsConnector::new(4, handle)?;
let client = Client::configure().connector(connector).build(&handle);
let done = client.aur_orphans().map(|search| {
println!("Orphaned packages: {}", search.result_count);
}).map_err(|_| ());
Errors
Resolves to Error::Fmt
if there was an error formatting the URI.
Resolves to Error::Hyper
if there was an error sending the request.
Resolves to Error::Json
if there was an error deserializing the
response body.
Resolves to Error::Uri
if there was an error parsing the Uri.