pub struct BangumiClient {
pub base_path: String,
pub user_agent: Option<String>,
pub client: Client,
pub access_token: Option<String>,
}Expand description
用于与Bangumi API进行交互的客户端
提供了构建请求、发送请求以及处理响应的功能
Fields§
§base_path: StringAPI的基础路径
user_agent: Option<String>可选的User-Agent头,用于标识请求来源
client: Clientreqwest HTTP客户端,用于发送实际的网络请求
access_token: Option<String>可选的访问令牌,用于认证需要授权的API请求
Implementations§
Source§impl BangumiClient
impl BangumiClient
Sourcepub fn new(
base_path: String,
user_agent: Option<String>,
access_token: Option<String>,
) -> Self
pub fn new( base_path: String, user_agent: Option<String>, access_token: Option<String>, ) -> Self
Sourcepub fn request_builder(&self, method: Method, url: &str) -> RequestBuilder
pub fn request_builder(&self, method: Method, url: &str) -> RequestBuilder
Sourcepub async fn request_send(
&self,
request_builder: RequestBuilder,
) -> Result<Response>
pub async fn request_send( &self, request_builder: RequestBuilder, ) -> Result<Response>
Source§impl BangumiClient
impl BangumiClient
Sourcepub async fn search_characters(
&self,
limit: Option<u32>,
offset: Option<u32>,
payload: Option<CharacterSearch>,
) -> Result<Paged<Character>>
pub async fn search_characters( &self, limit: Option<u32>, offset: Option<u32>, payload: Option<CharacterSearch>, ) -> Result<Paged<Character>>
Sourcepub async fn get_character(&self, character_id: u32) -> Result<Character>
pub async fn get_character(&self, character_id: u32) -> Result<Character>
Sourcepub async fn get_character_image(
&self,
character_id: u32,
type: SimpleImageType,
) -> Result<Bytes>
pub async fn get_character_image( &self, character_id: u32, type: SimpleImageType, ) -> Result<Bytes>
Sourcepub async fn get_character_subjects(
&self,
character_id: u32,
) -> Result<Vec<CharacterSubject>>
pub async fn get_character_subjects( &self, character_id: u32, ) -> Result<Vec<CharacterSubject>>
Sourcepub async fn get_character_persons(
&self,
character_id: u32,
) -> Result<Vec<CharacterPerson>>
pub async fn get_character_persons( &self, character_id: u32, ) -> Result<Vec<CharacterPerson>>
Sourcepub async fn collect_character(&self, character_id: u32) -> Result<()>
pub async fn collect_character(&self, character_id: u32) -> Result<()>
Source§impl BangumiClient
impl BangumiClient
Sourcepub async fn get_collection_subjects(
&self,
username: &str,
subject_type: Option<SubjectType>,
type: Option<CollectionType>,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Paged<CollectionSubject>>
pub async fn get_collection_subjects( &self, username: &str, subject_type: Option<SubjectType>, type: Option<CollectionType>, limit: Option<u32>, offset: Option<u32>, ) -> Result<Paged<CollectionSubject>>
Sourcepub async fn get_collection_subject(
&self,
username: &str,
subject_id: u32,
) -> Result<CollectionSubject>
pub async fn get_collection_subject( &self, username: &str, subject_id: u32, ) -> Result<CollectionSubject>
Sourcepub async fn post_collection_subject(
&self,
subject_id: u32,
payload: Option<CollectionSubjectUpdate>,
) -> Result<()>
pub async fn post_collection_subject( &self, subject_id: u32, payload: Option<CollectionSubjectUpdate>, ) -> Result<()>
Sourcepub async fn patch_collection_subject(
&self,
subject_id: u32,
payload: Option<CollectionSubjectUpdate>,
) -> Result<()>
pub async fn patch_collection_subject( &self, subject_id: u32, payload: Option<CollectionSubjectUpdate>, ) -> Result<()>
Sourcepub async fn get_collection_episodes(
&self,
subject_id: u32,
offset: Option<u32>,
limit: Option<u32>,
episode_type: Option<EpisodeType>,
) -> Result<Paged<CollectionEpisode>>
pub async fn get_collection_episodes( &self, subject_id: u32, offset: Option<u32>, limit: Option<u32>, episode_type: Option<EpisodeType>, ) -> Result<Paged<CollectionEpisode>>
Sourcepub async fn patch_collection_episodes(
&self,
subject_id: u32,
payload: Option<CollectionEpisodesUpdate>,
) -> Result<()>
pub async fn patch_collection_episodes( &self, subject_id: u32, payload: Option<CollectionEpisodesUpdate>, ) -> Result<()>
Sourcepub async fn get_collection_episode(
&self,
episode_id: u32,
) -> Result<CollectionEpisode>
pub async fn get_collection_episode( &self, episode_id: u32, ) -> Result<CollectionEpisode>
Sourcepub async fn put_collection_episode(
&self,
episode_id: u32,
payload: Option<CollectionEpisodeUpdate>,
) -> Result<()>
pub async fn put_collection_episode( &self, episode_id: u32, payload: Option<CollectionEpisodeUpdate>, ) -> Result<()>
Sourcepub async fn get_collection_characters(
&self,
username: &str,
) -> Result<Paged<CollectionCharacter>>
pub async fn get_collection_characters( &self, username: &str, ) -> Result<Paged<CollectionCharacter>>
Sourcepub async fn get_collection_character(
&self,
username: &str,
character_id: u32,
) -> Result<CollectionCharacter>
pub async fn get_collection_character( &self, username: &str, character_id: u32, ) -> Result<CollectionCharacter>
Sourcepub async fn get_collection_persons(
&self,
username: &str,
) -> Result<Paged<CollectionPerson>>
pub async fn get_collection_persons( &self, username: &str, ) -> Result<Paged<CollectionPerson>>
Sourcepub async fn get_collection_person(
&self,
username: &str,
person_id: u32,
) -> Result<CollectionPerson>
pub async fn get_collection_person( &self, username: &str, person_id: u32, ) -> Result<CollectionPerson>
Source§impl BangumiClient
impl BangumiClient
Source§impl BangumiClient
impl BangumiClient
Sourcepub async fn edit_index(
&self,
index_id: u32,
payload: Option<IndexBasicInfo>,
) -> Result<Index>
pub async fn edit_index( &self, index_id: u32, payload: Option<IndexBasicInfo>, ) -> Result<Index>
Sourcepub async fn get_index_subjects(
&self,
index_id: u32,
type: Option<SubjectType>,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Paged<IndexSubject>>
pub async fn get_index_subjects( &self, index_id: u32, type: Option<SubjectType>, limit: Option<u32>, offset: Option<u32>, ) -> Result<Paged<IndexSubject>>
Sourcepub async fn add_index_subject(
&self,
index_id: u32,
payload: Option<IndexSubjectAddInfo>,
) -> Result<()>
pub async fn add_index_subject( &self, index_id: u32, payload: Option<IndexSubjectAddInfo>, ) -> Result<()>
Sourcepub async fn edit_index_subject(
&self,
index_id: u32,
subject_id: u32,
payload: Option<IndexSubjectEditInfo>,
) -> Result<()>
pub async fn edit_index_subject( &self, index_id: u32, subject_id: u32, payload: Option<IndexSubjectEditInfo>, ) -> Result<()>
Sourcepub async fn collect_index(&self, index_id: u32) -> Result<()>
pub async fn collect_index(&self, index_id: u32) -> Result<()>
Source§impl BangumiClient
impl BangumiClient
Sourcepub async fn search_persons(
&self,
limit: Option<u32>,
offset: Option<u32>,
payload: Option<PersonSearch>,
) -> Result<Paged<PersonDetail>>
pub async fn search_persons( &self, limit: Option<u32>, offset: Option<u32>, payload: Option<PersonSearch>, ) -> Result<Paged<PersonDetail>>
Sourcepub async fn get_person(&self, person_id: u32) -> Result<PersonDetail>
pub async fn get_person(&self, person_id: u32) -> Result<PersonDetail>
Sourcepub async fn get_person_image(
&self,
person_id: u32,
type: SimpleImageType,
) -> Result<Bytes>
pub async fn get_person_image( &self, person_id: u32, type: SimpleImageType, ) -> Result<Bytes>
Sourcepub async fn get_person_subjects(
&self,
person_id: u32,
) -> Result<Vec<PersonSubject>>
pub async fn get_person_subjects( &self, person_id: u32, ) -> Result<Vec<PersonSubject>>
Sourcepub async fn get_person_characters(
&self,
person_id: u32,
) -> Result<Vec<PersonCharacter>>
pub async fn get_person_characters( &self, person_id: u32, ) -> Result<Vec<PersonCharacter>>
Sourcepub async fn collect_person(&self, person_id: u32) -> Result<()>
pub async fn collect_person(&self, person_id: u32) -> Result<()>
Source§impl BangumiClient
impl BangumiClient
Sourcepub async fn get_revision_persons(
&self,
person_id: u32,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Paged<RevisionCommon>>
pub async fn get_revision_persons( &self, person_id: u32, limit: Option<u32>, offset: Option<u32>, ) -> Result<Paged<RevisionCommon>>
Sourcepub async fn get_revision_person(
&self,
revision_id: u32,
) -> Result<RevisionPerson>
pub async fn get_revision_person( &self, revision_id: u32, ) -> Result<RevisionPerson>
Sourcepub async fn get_revision_characters(
&self,
character_id: u32,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Paged<RevisionCommon>>
pub async fn get_revision_characters( &self, character_id: u32, limit: Option<u32>, offset: Option<u32>, ) -> Result<Paged<RevisionCommon>>
Sourcepub async fn get_revision_character(
&self,
revision_id: u32,
) -> Result<RevisionCharacter>
pub async fn get_revision_character( &self, revision_id: u32, ) -> Result<RevisionCharacter>
Sourcepub async fn get_revision_subjects(
&self,
subject_id: u32,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Paged<RevisionCommon>>
pub async fn get_revision_subjects( &self, subject_id: u32, limit: Option<u32>, offset: Option<u32>, ) -> Result<Paged<RevisionCommon>>
Sourcepub async fn get_revision_subject(
&self,
revision_id: u32,
) -> Result<RevisionSubject>
pub async fn get_revision_subject( &self, revision_id: u32, ) -> Result<RevisionSubject>
Sourcepub async fn get_revision_episodes(
&self,
episode_id: u32,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Paged<RevisionCommon>>
pub async fn get_revision_episodes( &self, episode_id: u32, limit: Option<u32>, offset: Option<u32>, ) -> Result<Paged<RevisionCommon>>
Sourcepub async fn get_revision_episode(
&self,
revision_id: u32,
) -> Result<RevisionEpisode>
pub async fn get_revision_episode( &self, revision_id: u32, ) -> Result<RevisionEpisode>
Source§impl BangumiClient
impl BangumiClient
Sourcepub async fn get_calendar(&self) -> Result<Vec<DailyCalendarItem>>
pub async fn get_calendar(&self) -> Result<Vec<DailyCalendarItem>>
Sourcepub async fn search_subjects(
&self,
limit: Option<u32>,
offset: Option<u32>,
payload: Option<SubjectSearch>,
) -> Result<Paged<Subject>>
pub async fn search_subjects( &self, limit: Option<u32>, offset: Option<u32>, payload: Option<SubjectSearch>, ) -> Result<Paged<Subject>>
Sourcepub async fn get_subjects(
&self,
type: SubjectType,
cat: Option<SubjectCategory>,
series: Option<bool>,
platform: Option<&str>,
sort: Option<SubjectBrowseSort>,
year: Option<u32>,
month: Option<u32>,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<Paged<Subject>>
pub async fn get_subjects( &self, type: SubjectType, cat: Option<SubjectCategory>, series: Option<bool>, platform: Option<&str>, sort: Option<SubjectBrowseSort>, year: Option<u32>, month: Option<u32>, limit: Option<u32>, offset: Option<u32>, ) -> Result<Paged<Subject>>
获取番剧条目列表
根据筛选条件获取番剧条目列表,支持按类型、分类、时间等条件筛选
§参数
r#type: 条目类型(必需,指定要获取的条目类型,如动画、书籍等)cat: 子类别(可选,进一步筛选条目子类别,如动画中的TV、电影等)series: 是否为系列作品(可选,筛选系列作品或独立作品)platform: 平台(可选,筛选特定平台的条目)sort: 排序方式(可选,指定结果排序规则,如按日期、排名排序)year: 年份(可选,筛选特定年份的条目)month: 月份(可选,筛选特定月份的条目)limit: 结果数量上限(可选,限制返回的条目数量)offset: 结果偏移量(可选,用于分页,指定从第几条结果开始返回)
§返回
成功返回分页的番剧条目列表,失败返回错误
Sourcepub async fn get_subject(&self, subject_id: u32) -> Result<Subject>
pub async fn get_subject(&self, subject_id: u32) -> Result<Subject>
Sourcepub async fn get_subject_persons(
&self,
subject_id: u32,
) -> Result<Vec<SubjectPerson>>
pub async fn get_subject_persons( &self, subject_id: u32, ) -> Result<Vec<SubjectPerson>>
Sourcepub async fn get_subject_characters(
&self,
subject_id: u32,
) -> Result<Vec<SubjectCharacter>>
pub async fn get_subject_characters( &self, subject_id: u32, ) -> Result<Vec<SubjectCharacter>>
Sourcepub async fn get_subject_subjects(
&self,
subject_id: u32,
) -> Result<Vec<SubjectSubject>>
pub async fn get_subject_subjects( &self, subject_id: u32, ) -> Result<Vec<SubjectSubject>>
Source§impl BangumiClient
impl BangumiClient
pub async fn get_user(&self, username: &str) -> Result<UserPublic>
pub async fn get_user_avatar( &self, username: &str, type: AvatarType, ) -> Result<Bytes>
pub async fn get_me(&self) -> Result<User>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BangumiClient
impl !RefUnwindSafe for BangumiClient
impl Send for BangumiClient
impl Sync for BangumiClient
impl Unpin for BangumiClient
impl !UnwindSafe for BangumiClient
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
Mutably borrows from an owned value. Read more