Struct tosho_rbean::RBClient
source · pub struct RBClient { /* private fields */ }
Expand description
Main client for interacting with the 小豆 (Red Bean) API
§Examples
use tosho_rbean::{RBClient, RBConfig, RBPlatform};
#[tokio::main]
async fn main() {
let config = RBConfig {
token: "123".to_string(),
refresh_token: "abcxyz".to_string(),
platform: RBPlatform::Android,
};
let mut client = RBClient::new(config);
// Refresh token
client.refresh_token().await.unwrap();
let user = client.get_user().await.unwrap();
println!("{:?}", user);
}
Implementations§
source§impl RBClient
impl RBClient
sourcepub fn with_proxy(&self, proxy: Proxy) -> Self
pub fn with_proxy(&self, proxy: Proxy) -> Self
Attach a proxy to the client.
This will clone the client and return a new client with the proxy attached.
§Arguments
proxy
- The proxy to attach to the client
pub fn set_expiry_at(&mut self, expiry_at: Option<i64>)
sourcepub async fn refresh_token(&mut self) -> Result<()>
pub async fn refresh_token(&mut self) -> Result<()>
Refresh the token of the client.
The following function will be called on each request to ensure the token is always valid.
The first request will always be a token refresh, and subsequent requests will only refresh if the token is expired.
sourcepub fn get_expiry_at(&self) -> Option<i64>
pub fn get_expiry_at(&self) -> Option<i64>
Get the expiry time of the token.
sourcepub async fn get_user(&mut self) -> Result<UserAccount>
pub async fn get_user(&mut self) -> Result<UserAccount>
Get the current user account information.
sourcepub async fn get_reading_list(&mut self) -> Result<Vec<ReadingListItem>>
pub async fn get_reading_list(&mut self) -> Result<Vec<ReadingListItem>>
Get the current user reading list.
sourcepub async fn get_manga_filters(&mut self) -> Result<Manga>
pub async fn get_manga_filters(&mut self) -> Result<Manga>
Get the manga filters for searching manga.
sourcepub async fn get_chapter_list(
&mut self,
uuid: &str,
) -> Result<ChapterListResponse>
pub async fn get_chapter_list( &mut self, uuid: &str, ) -> Result<ChapterListResponse>
sourcepub async fn get_chapter(
&mut self,
uuid: &str,
) -> Result<ChapterDetailsResponse>
pub async fn get_chapter( &mut self, uuid: &str, ) -> Result<ChapterDetailsResponse>
sourcepub async fn get_chapter_viewer(
&mut self,
uuid: &str,
) -> Result<ChapterPageDetailsResponse>
pub async fn get_chapter_viewer( &mut self, uuid: &str, ) -> Result<ChapterPageDetailsResponse>
sourcepub async fn search(
&mut self,
query: &str,
offset: Option<u32>,
count: Option<u32>,
sort: Option<SortOption>,
) -> Result<MangaListResponse>
pub async fn search( &mut self, query: &str, offset: Option<u32>, count: Option<u32>, sort: Option<SortOption>, ) -> Result<MangaListResponse>
Do a search for a manga.
§Arguments
query
- The query to search for.offset
- The offset of the search result, default to0
count
- The count of the search result, default to999
sort
- The sort option of the search result, default toSortOption::Alphabetical
sourcepub async fn get_home_page(&mut self) -> Result<HomeResponse>
pub async fn get_home_page(&mut self) -> Result<HomeResponse>
Get the home page information.
sourcepub async fn get_publisher(&mut self, slug: &str) -> Result<Publisher>
pub async fn get_publisher(&mut self, slug: &str) -> Result<Publisher>
sourcepub fn modify_url_for_highres(url: &str) -> Result<String>
pub fn modify_url_for_highres(url: &str) -> Result<String>
sourcepub async fn stream_download(
&self,
url: &str,
writer: impl AsyncWrite + Unpin,
) -> Result<()>
pub async fn stream_download( &self, url: &str, writer: impl AsyncWrite + Unpin, ) -> Result<()>
Stream download the image from the given URL.
The URL can be obtained from RBClient::get_chapter_viewer
.
§Parameters
url
- The URL to download the image from.writer
- The writer to write the image to.
sourcepub async fn test_high_res(&self, url: &str) -> Result<bool>
pub async fn test_high_res(&self, url: &str) -> Result<bool>
Try checking if the “hidden” high resolution image is available.
Give the URL of any image that is requested from the API.
pub async fn login( email: &str, password: &str, platform: RBPlatform, ) -> Result<RBLoginResponse>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RBClient
impl !RefUnwindSafe for RBClient
impl Send for RBClient
impl Sync for RBClient
impl Unpin for RBClient
impl !UnwindSafe for RBClient
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more