Struct LastFmEditClientImpl

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

Main implementation for interacting with Last.fm’s web interface.

This implementation provides methods for browsing user libraries and editing scrobble data through web scraping. It requires a valid authenticated session to function.

Implementations§

Source§

impl LastFmEditClientImpl

Source

pub fn from_session( client: Box<dyn HttpClient + Send + Sync>, session: LastFmEditSession, ) -> Self

Create a new LastFmEditClient from an authenticated session.

This is the primary constructor for creating a client. You must obtain a valid session first using the login function.

§Arguments
  • client - Any HTTP client implementation that implements HttpClient
  • session - A valid authenticated session
Source

pub fn from_session_with_rate_limit_patterns( client: Box<dyn HttpClient + Send + Sync>, session: LastFmEditSession, rate_limit_patterns: Vec<String>, ) -> Self

Create a new LastFmEditClient from an authenticated session with custom rate limit patterns.

This is useful for testing or customizing rate limit detection.

§Arguments
  • client - Any HTTP client implementation
  • session - A valid authenticated session
  • rate_limit_patterns - Text patterns that indicate rate limiting in responses
Source

pub async fn login_with_credentials( client: Box<dyn HttpClient + Send + Sync>, username: &str, password: &str, ) -> Result<Self>

Create a new authenticated LastFmEditClient by logging in with username and password.

This is a convenience method that combines login and client creation into one step.

§Arguments
  • client - Any HTTP client implementation
  • username - Last.fm username or email
  • password - Last.fm password
§Returns

Returns an authenticated client on success, or LastFmError::Auth on failure.

Source

pub fn get_session(&self) -> LastFmEditSession

Extract the current session state for persistence.

Source

pub fn restore_session(&self, session: LastFmEditSession)

Restore session state from a previously saved session.

Source

pub fn with_shared_broadcaster( &self, client: Box<dyn HttpClient + Send + Sync>, ) -> Self

Create a new client that shares the same session and event broadcaster.

This is useful when you want multiple HTTP client instances but want them to share the same authentication state and event broadcasting system.

§Arguments
  • client - A new HTTP client implementation
§Returns

Returns a new client that shares the session and broadcaster with this client.

Source

pub fn username(&self) -> String

Get the currently authenticated username.

Returns an empty string if not logged in.

Source

pub async fn validate_session(&self) -> bool

Source

pub fn subscribe(&self) -> ClientEventReceiver

Subscribe to internal client events.

Source

pub fn latest_event(&self) -> Option<ClientEvent>

Get the latest client event without subscribing to future events.

Source

pub async fn get_recent_scrobbles(&self, page: u32) -> Result<Vec<Track>>

Fetch recent scrobbles from the user’s listening history This gives us real scrobble data with timestamps for editing

Source

pub async fn get_recent_tracks_page(&self, page: u32) -> Result<TrackPage>

Get a page of tracks from the user’s recent listening history.

Source

pub async fn find_recent_scrobble_for_track( &self, track_name: &str, artist_name: &str, max_pages: u32, ) -> Result<Option<Track>>

Find the most recent scrobble for a specific track This searches through recent listening history to find real scrobble data

Source

pub async fn edit_scrobble(&self, edit: &ScrobbleEdit) -> Result<EditResponse>

Source

pub async fn edit_scrobble_single( &self, exact_edit: &ExactScrobbleEdit, max_retries: u32, ) -> Result<EditResponse>

Edit a single scrobble with retry logic, returning a single-result EditResponse.

This method takes a fully-specified ExactScrobbleEdit and performs a single edit operation. Unlike edit_scrobble, this method does not perform enrichment or multiple edits - it edits exactly one scrobble instance.

§Arguments
  • exact_edit - A fully-specified edit with all required fields populated
  • max_retries - Maximum number of retry attempts for rate limiting
Source

pub async fn load_edit_form_values_internal( &self, track_name: &str, artist_name: &str, ) -> Result<Vec<ExactScrobbleEdit>>

Load prepopulated form values for editing a specific track This extracts scrobble data directly from the track page forms

Source

pub async fn get_artist_tracks_page( &self, artist: &str, page: u32, ) -> Result<TrackPage>

Source

pub fn extract_tracks_from_document( &self, document: &Html, artist: &str, album: Option<&str>, ) -> Result<Vec<Track>>

Extract tracks from HTML document (delegates to parser)

Source

pub fn parse_tracks_page( &self, document: &Html, page_number: u32, artist: &str, album: Option<&str>, ) -> Result<TrackPage>

Parse tracks page (delegates to parser)

Source

pub fn parse_recent_scrobbles(&self, document: &Html) -> Result<Vec<Track>>

Parse recent scrobbles from HTML document (for testing)

Source

pub async fn get(&self, url: &str) -> Result<Response>

Make an HTTP GET request with authentication and retry logic

Source

pub async fn get_artist_albums_page( &self, artist: &str, page: u32, ) -> Result<AlbumPage>

Trait Implementations§

Source§

impl Clone for LastFmEditClientImpl

Source§

fn clone(&self) -> LastFmEditClientImpl

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl LastFmEditClient for LastFmEditClientImpl

Source§

fn username(&self) -> String

Get the currently authenticated username.
Source§

fn get_recent_scrobbles<'life0, 'async_trait>( &'life0 self, page: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<Track>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch recent scrobbles from the user’s listening history.
Source§

fn find_recent_scrobble_for_track<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, track_name: &'life1 str, artist_name: &'life2 str, max_pages: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<Track>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Find the most recent scrobble for a specific track.
Source§

fn edit_scrobble<'life0, 'life1, 'async_trait>( &'life0 self, edit: &'life1 ScrobbleEdit, ) -> Pin<Box<dyn Future<Output = Result<EditResponse>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Edit scrobbles by discovering and updating all matching instances. Read more
Source§

fn edit_scrobble_single<'life0, 'life1, 'async_trait>( &'life0 self, exact_edit: &'life1 ExactScrobbleEdit, max_retries: u32, ) -> Pin<Box<dyn Future<Output = Result<EditResponse>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Edit a single scrobble with complete information and retry logic. Read more
Source§

fn get_session(&self) -> LastFmEditSession

Extract the current session state for persistence. Read more
Source§

fn restore_session(&self, session: LastFmEditSession)

Restore session state from a previously saved session. Read more
Source§

fn subscribe(&self) -> ClientEventReceiver

Subscribe to internal client events. Read more
Source§

fn latest_event(&self) -> Option<ClientEvent>

Get the latest client event without subscribing to future events. Read more
Source§

fn discover_scrobbles( &self, edit: ScrobbleEdit, ) -> Box<dyn AsyncDiscoveryIterator<ExactScrobbleEdit>>

Create an incremental discovery iterator for scrobble editing. Read more
Source§

fn get_artist_tracks_page<'life0, 'life1, 'async_trait>( &'life0 self, artist: &'life1 str, page: u32, ) -> Pin<Box<dyn Future<Output = Result<TrackPage>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a page of tracks from the user’s library for the specified artist.
Source§

fn get_artist_albums_page<'life0, 'life1, 'async_trait>( &'life0 self, artist: &'life1 str, page: u32, ) -> Pin<Box<dyn Future<Output = Result<AlbumPage>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a page of albums from the user’s library for the specified artist.
Source§

fn artist_tracks(&self, artist: &str) -> ArtistTracksIterator

Create an iterator for browsing an artist’s tracks from the user’s library.
Source§

fn artist_albums(&self, artist: &str) -> ArtistAlbumsIterator

Create an iterator for browsing an artist’s albums from the user’s library.
Source§

fn album_tracks( &self, album_name: &str, artist_name: &str, ) -> AlbumTracksIterator

Create an iterator for browsing tracks from a specific album.
Source§

fn recent_tracks(&self) -> RecentTracksIterator

Create an iterator for browsing the user’s recent tracks/scrobbles.
Source§

fn recent_tracks_from_page(&self, starting_page: u32) -> RecentTracksIterator

Create an iterator for browsing the user’s recent tracks starting from a specific page.
Source§

fn validate_session<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Validate if the current session is still working. Read more
Source§

fn get_recent_tracks_page<'life0, 'async_trait>( &'life0 self, page: u32, ) -> Pin<Box<dyn Future<Output = Result<TrackPage>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a page of tracks from the user’s recent listening history.
Source§

fn discover_scrobble_edit_variations<'life0, 'life1, 'async_trait>( &'life0 self, edit: &'life1 ScrobbleEdit, ) -> Pin<Box<dyn Future<Output = Result<Vec<ExactScrobbleEdit>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Discover all scrobble edit variations based on the provided ScrobbleEdit template. Read more
Source§

fn get_album_tracks<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, album_name: &'life1 str, artist_name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Track>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get tracks from a specific album page.
Source§

fn find_scrobble_by_timestamp<'life0, 'async_trait>( &'life0 self, timestamp: u64, ) -> Pin<Box<dyn Future<Output = Result<Track>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Find a scrobble by its timestamp in recent scrobbles.
Source§

fn edit_album<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, old_album_name: &'life1 str, new_album_name: &'life2 str, artist_name: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<EditResponse>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Edit album metadata by updating scrobbles with new album name.
Source§

fn edit_artist<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, old_artist_name: &'life1 str, new_artist_name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<EditResponse>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Edit artist metadata by updating scrobbles with new artist name. Read more
Source§

fn edit_artist_for_track<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, track_name: &'life1 str, old_artist_name: &'life2 str, new_artist_name: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<EditResponse>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Edit artist metadata for a specific track only. Read more
Source§

fn edit_artist_for_album<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, album_name: &'life1 str, old_artist_name: &'life2 str, new_artist_name: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<EditResponse>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Edit artist metadata for all tracks in a specific album. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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
Source§

impl<T> From<T> for T

Source§

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
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
Source§

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

Source§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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