Struct rs621::client::Client[][src]

pub struct Client { /* fields omitted */ }

Client struct.

Implementations

impl Client[src]

pub fn new(url: &str, user_agent: impl AsRef<[u8]>) -> Result<Self>[src]

Create a new client with the specified value for the User-Agent header. The API requires a non-empty User-Agent header for all requests, preferably including your E621 username and the name of your project.

pub fn with_proxy(
    url: &str,
    user_agent: impl AsRef<[u8]>,
    proxy: &str
) -> Result<Self>
[src]

Create a new client with the specified User-Agent header and proxy. The API requires a non-empty User-Agent header for all requests, preferably including your E621 username and the name of your project.

pub fn get_json_endpoint(
    &self,
    endpoint: &str
) -> impl Future<Output = Result<Value>>
[src]

impl Client[src]

pub fn get_posts<'a, I, J, T>(&'a self, ids: I) -> PostStream<'a, J, T> where
    T: Borrow<u64> + Unpin,
    J: Iterator<Item = T> + Unpin,
    I: IntoIterator<Item = T, IntoIter = J> + Unpin
[src]

Returns posts with the given IDs. Note that the order is NOT preserved!

use futures::prelude::*;

let client = Client::new("https://e926.net", "MyProject/1.0 (by username on e621)")?;
let mut post_stream = client.get_posts(&[8595, 535, 2105, 1470]);

while let Some(post) = post_stream.next().await {
    println!("Post #{}", post?.id);
}

Returns a Stream over all the posts matching the search query.

use futures::prelude::*;

let client = Client::new("https://e926.net", "MyProject/1.0 (by username on e621)")?;

let mut post_stream = client.post_search(&["fluffy", "rating:s"][..]).take(3);

while let Some(post) = post_stream.next().await {
    assert_eq!(post?.rating, PostRating::Safe);
}

pub fn post_search_from_page<'a, T: Into<Query>>(
    &'a self,
    tags: T,
    page: SearchPage
) -> PostSearchStream<'a>
[src]

Same as Client::post_search, but starting from a specific result page.

use futures::prelude::*;

let client = Client::new("https://e926.net", "MyProject/1.0 (by username on e621)")?;

let mut post_stream = client
    .post_search_from_page(&["fluffy", "rating:s"][..], SearchPage::Page(4))
    .take(5);

while let Some(post) = post_stream.next().await {
    let post = post?;

    assert_eq!(post.rating, PostRating::Safe);
}

Returns a Stream over all the posts matching the search query, starting from the given page.

use rs621::post::SearchPage;
let client = Client::new("https://e926.net", "MyProject/1.0 (by username on e621)")?;

let mut post_stream = client
    .post_search_from_page(&["fluffy", "rating:s"][..], SearchPage::BeforePost(123456))
    .take(3);

while let Some(post) = post_stream.next().await {
    let post = post?;
    assert!(post.id < 123456);
    assert_eq!(post.rating, PostRating::Safe);
}

impl Client[src]

Performs a pool search.

use futures::prelude::*;

let client = Client::new("https://e926.net", "MyProject/1.0 (by username on e621)")?;

let mut pool_stream = client.pool_search(PoolSearch::new().name_matches("foo"));

while let Some(pool) = pool_stream.next().await {
    assert!(pool?.name.contains("foo"));
}

Trait Implementations

impl Debug for Client[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.