MSRApiClient

Struct MSRApiClient 

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

默认的MSR API客户端,使用官方API地址

这个客户端提供了对MSR API的完整封装,使用官方的API地址作为默认配置。 支持所有主要的API调用,包括歌曲、专辑、新闻和搜索功能。

Implementations§

Source§

impl MSRApiClient

Source

pub fn new() -> Self

创建默认的MSR API客户端,使用官方API地址

§示例
use easy_msr_api::MSRApiClient;
 
let client = MSRApiClient::new();
Source

pub fn with_base(base: String) -> Self

使用自定义API地址创建客户端

§参数
  • base - API的基础URL地址
§示例
use easy_msr_api::MSRApiClient;
 
let client = MSRApiClient::with_base("https://custom-api.com".to_string());
Source

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

获取指定ID的歌曲详情

Source

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

获取所有歌曲列表

Source

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

获取指定ID的专辑信息

Source

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

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

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的新闻详情

Source

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

获取字体配置信息

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 Default for MSRApiClient

Source§

fn default() -> Self

Returns the “default value” for a type. 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> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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,