Struct rs621::client::Client [−][src]
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]
url: &str,
user_agent: impl AsRef<[u8]>,
proxy: &str
) -> Result<Self>
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]
&self,
endpoint: &str
) -> impl Future<Output = Result<Value>>
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]
T: Borrow<u64> + Unpin,
J: Iterator<Item = T> + Unpin,
I: IntoIterator<Item = T, IntoIter = J> + Unpin,
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); }
pub fn post_search<'a, T: Into<Query>>(
&'a self,
tags: T
) -> PostSearchStream<'a>
[src]
&'a self,
tags: T
) -> PostSearchStream<'a>
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]
&'a self,
tags: T,
page: SearchPage
) -> PostSearchStream<'a>
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]
pub fn pool_search<'a>(&'a self, search: PoolSearch) -> PoolStream<'a>
[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
Auto Trait Implementations
impl !RefUnwindSafe for Client
[src]
impl Send for Client
[src]
impl Sync for Client
[src]
impl Unpin for Client
[src]
impl !UnwindSafe for Client
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,