Skip to main content

Analyze

Trait Analyze 

Source
pub trait Analyze: Sized {
    type Item: TrackAnalyzable;

    // Provided methods
    async fn analyze(self, threshold: usize) -> Result<TrackStats> { ... }
    async fn analyze_and_print(self, threshold: usize) -> Result<()> { ... }
}
Expand description

Extension trait providing analyze and analyze_and_print for request builders.

A blanket implementation is provided for every builder that implements FetchAndSave whose item type implements crate::analytics::TrackAnalyzable. Import this trait to call .analyze(threshold) and .analyze_and_print(threshold) on any qualifying builder.

§Example

use lastfm_client::{LastFmClient, Analyze};

let stats = client.recent_tracks("username")
    .analyze(5)
    .await?;

Required Associated Types§

Source

type Item: TrackAnalyzable

The item type produced by this builder.

Provided Methods§

Source

async fn analyze(self, threshold: usize) -> Result<TrackStats>

Fetch items and return play-count statistics.

§Arguments
  • threshold - Tracks with fewer plays than this are counted in tracks_below_threshold.
§Errors

Returns an error if the HTTP request fails or the response cannot be parsed.

Source

async fn analyze_and_print(self, threshold: usize) -> Result<()>

Fetch items, compute statistics, and print them to stdout.

§Arguments
  • threshold - Tracks with fewer plays than this are counted in tracks_below_threshold.
§Errors

Returns an error if the HTTP request fails or the response cannot be parsed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§