RemoteApiClient

Struct RemoteApiClient 

Source
pub struct RemoteApiClient { /* private fields */ }
Expand description

远程API客户端

封装了HTTP客户端和API基础URL,提供所有MSR API的调用方法。 支持自定义超时时间和基础URL配置。

Implementations§

Source§

impl RemoteApiClient

Source

pub fn new(base: String) -> Self

创建默认配置的客户端

使用30秒的超时时间和默认的用户代理字符串。

§参数
  • base - API的基础URL地址
§示例
use easy_msr_api::client::remote::RemoteApiClient;
 
let client = RemoteApiClient::new("https://monster-siren.hypergryph.com/api".to_string());
Source

pub fn with_config(base: String, timeout: Duration) -> Self

使用自定义超时时间创建客户端

§参数
  • base - API的基础URL地址
  • timeout - HTTP请求超时时间
§示例
use std::time::Duration;
use easy_msr_api::client::remote::RemoteApiClient;
 
let client = RemoteApiClient::with_config(
    "https://monster-siren.hypergryph.com/api".to_string(),
    Duration::from_secs(60)
);
Source

pub async fn get_song(&self, id: String) -> Result<SongResp, AppError>

获取指定ID的歌曲详情

§参数
  • id - 歌曲的唯一标识符(cid)
§返回

返回包含歌曲详细信息的响应

Source

pub async fn get_all_songs(&self) -> Result<AllSongsResp, AppError>

获取所有歌曲列表

§返回

返回包含所有歌曲基本信息的列表

Source

pub async fn get_album(&self, id: String) -> Result<AlbumResp, AppError>

获取指定ID的专辑信息

§参数
  • id - 专辑的唯一标识符(cid)
§返回

返回包含专辑详细信息的响应

Source

pub async fn get_album_detail( &self, id: String, ) -> Result<AlbumDetailResp, AppError>

获取指定ID的专辑详情(包含歌曲列表)

§参数
  • id - 专辑的唯一标识符(cid)
§返回

返回包含专辑详情和歌曲列表的响应

Source

pub async fn get_all_albums( &self, ) -> Result<ApiResp<Vec<AllAlbumsItem>>, AppError>

获取所有专辑列表

§返回

返回包含所有专辑基本信息的列表

Source

pub async fn get_all_news( &self, last_cid: Option<String>, ) -> Result<SearchNewsResp, AppError>

获取所有新闻列表

§参数
  • last_cid - 可选参数,用于分页,从指定cid之后开始获取
§返回

返回包含新闻列表的响应

Source

pub async fn get_news_detail( &self, id: String, ) -> Result<NewsDetailResp, AppError>

获取指定ID的新闻详情

§参数
  • id - 新闻的唯一标识符(cid)
§返回

返回包含新闻详细内容的响应

Source

pub async fn get_font(&self) -> Result<FontResp, AppError>

获取字体配置信息

§返回

返回包含字体文件URL配置的响应

Source

pub async fn search(&self, keyword: String) -> Result<SearchResp, AppError>

综合搜索(同时搜索专辑和新闻)

§参数
  • keyword - 搜索关键词
§返回

返回包含专辑和新闻搜索结果的响应

Source

pub async fn search_albums( &self, keyword: String, last_cid: Option<String>, ) -> Result<SearchAlbumResp, AppError>

搜索专辑

§参数
  • keyword - 搜索关键词
  • last_cid - 可选参数,用于分页
§返回

返回包含专辑搜索结果的响应

Source

pub async fn search_news( &self, keyword: String, last_cid: Option<String>, ) -> Result<SearchNewsResp, AppError>

搜索新闻

§参数
  • keyword - 搜索关键词
  • last_cid - 可选参数,用于分页
§返回

返回包含新闻搜索结果的响应

Trait Implementations§

Source§

impl Clone for RemoteApiClient

Source§

fn clone(&self) -> RemoteApiClient

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,