Struct UserData

Source
pub struct UserData {
Show 13 fields pub client_preferences: Vec<ClientPreference>, pub annotations: Vec<Annotation>, pub relation_annotations: Vec<RelationAnnotation>, pub plays: Vec<Play>, pub counts: Vec<PlayCount>, pub collections: Vec<Collection>, pub playlists: Vec<Playlist>, pub scrobbles: Vec<Scrobble>, pub playback_states: Vec<PlaybackState>, pub set_aside: Vec<SetAside>, pub same_artist: Vec<SameArtist>, pub track_identities: Vec<TrackIdentity>, pub relinks: Vec<Relink>,
}
Expand description

Everything the user wrote, as it sits on disk.

Fields§

§client_preferences: Vec<ClientPreference>

Optional owner-private application preferences; retained across scans and exports.

§annotations: Vec<Annotation>

One record per owner and target.

§relation_annotations: Vec<RelationAnnotation>

Notes and labels attached to graph relationships.

§plays: Vec<Play>

The most recent plays, oldest first, bounded by HISTORY_LIMIT.

§counts: Vec<PlayCount>

All-time counts, which never forget.

§collections: Vec<Collection>

Saved queries, by name.

§playlists: Vec<Playlist>

Private, ordered static playlists, including repeated/missing tracks.

§scrobbles: Vec<Scrobble>

Client-declared listens with unknown duration/completion, oldest first.

§playback_states: Vec<PlaybackState>

Optional named native-player checkpoints, private to their immutable owner.

§set_aside: Vec<SetAside>

Records taken off the missing report — see SetAside.

§same_artist: Vec<SameArtist>

Spellings the owner says are one artist — see SameArtist.

§track_identities: Vec<TrackIdentity>

Last observed evidence for referenced files, used for safe relocation.

§relinks: Vec<Relink>

Explicit owner-scoped reattachments, retained for conflict-safe undo.

Implementations§

Source§

impl UserData

Source

pub fn playback_state( &self, owner: &str, profile: &str, ) -> Option<&PlaybackState>

Read only one owner’s named checkpoint; another owner cannot select it.

Source

pub fn set_playback_state( &mut self, state: PlaybackState, ) -> Result<(), StoreError>

Add or replace exactly one owner’s named checkpoint, validating before mutation.

Callers must authorize the supplied owner and compare the existing session/revision while holding the installation’s writer lock. This domain operation does not implicitly acquire a second lock or save.

Source

pub fn clear_playback_state(&mut self, owner: &str, profile: &str) -> bool

Forget one profile for this owner, leaving other owners/profiles untouched.

Source§

impl UserData

Source

pub fn playlist(&self, owner: &str, id: &str) -> Option<&Playlist>

Finds a playlist only within the supplied owner’s private namespace.

Source

pub fn create_playlist( &mut self, owner: &str, name: &str, tracks: Vec<EntityRef>, now: u64, ) -> Result<String, String>

Creates a bounded static playlist and returns its persistent random ID.

Invalid data or a reached store/owner limit fails before any mutation.

Source

pub fn update_playlist( &mut self, owner: &str, id: &str, name: Option<&str>, comment: Option<&str>, tracks: Option<Vec<EntityRef>>, now: u64, ) -> Result<(), String>

Updates only the supplied fields of an owner’s playlist atomically.

Some("") clears the comment; None preserves it. A missing owner/ID pair and invalid replacement data fail without changing the playlist.

Source

pub fn delete_playlist(&mut self, owner: &str, id: &str) -> bool

Deliberately removes one owner’s playlist, leaving all music intact.

Source

pub fn record_scrobble(&mut self, event: Scrobble) -> Result<(), String>

Records a declared listen and updates its count without fabricating a Play.

Recent declarations retain their multiplicity, ordered by client time, and are bounded by HISTORY_LIMIT. Counts outlive that recent log.

Source§

impl UserData

Validates an explicit reattachment without changing any data.

The source must be waiting, the destination must exist and have the same kind, and that owner’s destination must hold no conflicting personal record. Other owners are untouched and never cause a conflict.

Applies a validated reattachment, preserving its original records for undo.

Checks undo without mutation, refusing edits or newly conflicting data.

Undo never discards new listening events or note edits. If the moved records have changed, it refuses and leaves the store unchanged.

Takes back one reattachment after the same checks as its preview.

Source§

impl UserData

Source

pub fn find(&self, owner: &str, target: &EntityRef) -> Option<&Annotation>

The record for one owner and target, if there is one.

Source

pub fn entry( &mut self, owner: &str, target: &EntityRef, now: u64, ) -> &mut Annotation

The record for one owner and target, opening one if needed.

now stamps a record that did not exist; an existing one keeps its creation date and has its updated_at moved by the caller.

Source

pub fn forget_empty(&mut self)

Drops the records that no longer say anything.

Called after every change, so that un-loving the one album somebody ever loved leaves nothing behind.

Source

pub fn find_relation( &self, owner: &str, relation: &RelationRef, ) -> Option<&RelationAnnotation>

Personal annotation for one relation, if one exists.

Source

pub fn find_relation_in( &self, catalog: &Catalog, owner: &str, relation: &RelationRef, ) -> Option<&RelationAnnotation>

Finds one owner’s credit context across exact catalog identity aliases.

An exact reference wins. A unique equivalent credit is usable when the catalog can resolve both endpoints; ambiguous aliases select nothing. Other relationship kinds retain exact-reference behavior.

Source

pub fn relation_entry_in( &mut self, catalog: &Catalog, owner: &str, relation: &RelationRef, now: u64, ) -> Result<&mut RelationAnnotation, String>

Opens existing credit context without combining historical annotations. A new credit keeps its known artist MBID when local tags later disappear.

Source

pub fn remove_relation_in( &mut self, catalog: &Catalog, owner: &str, relation: &RelationRef, ) -> Result<bool, String>

Removes one exact or uniquely equivalent owner annotation. Ambiguous history is refused without deleting or merging any row.

Source

pub fn relation_entry( &mut self, owner: &str, relation: &RelationRef, now: u64, ) -> &mut RelationAnnotation

Opens the personal annotation for one relation.

Source

pub fn copy( &mut self, owner: &str, from: &EntityRef, to: &EntityRef, now: u64, ) -> bool

Copies everything said about one target onto another.

Returns false when there was nothing to copy — which is worth telling the user, since a silent success there means they typed the wrong name and will not find out until they look.

Source

pub fn forget_last_play(&mut self, owner: &str, track: &EntityRef) -> bool

Takes back the most recent play of a track, log and counter together.

The counter is not a summary of the log — the log is bounded at HISTORY_LIMIT and the counter is not — so a removal that touched one and not the other would leave a track played “three times” with two plays behind it, and nothing on screen to say which was right. They are written together by UserData::record_play and they are taken back together here.

Returns false when there was nothing to take back, which the caller says rather than reporting a removal that did not happen.

Source

pub fn forget_history(&mut self, owner: &str) -> (usize, usize)

Forgets everything an owner ever played.

Native events, declared scrobbles and counters are cleared together. Returns how many events/declarations and how many counters went, because “your history is cleared” is a claim nobody can check and a number is.

Source

pub fn record_play(&mut self, play: Play)

Records one listen: the bounded log and the all-time counter together.

Both, always — see UserData::forget_last_play for why the two must never be written apart.

Source

pub fn collection(&self, owner: &str, name: &str) -> Option<&Collection>

A saved query by name, compared without regard to case or accents: somebody typing aede collection Metal means the one they saved as “metal”.

Source

pub fn save_collection( &mut self, owner: &str, name: &str, expression: &str, now: u64, ) -> bool

Saves a query under a name, replacing one of the same name.

Returns true when a collection was replaced, which the caller says out loud: overwriting somebody’s saved query in silence is how they find out a week later.

Source

pub fn forget_collection(&mut self, owner: &str, name: &str) -> bool

Drops a saved query; false when there was none by that name.

Source

pub fn play_count(&self, owner: &str, track: &EntityRef) -> u32

How many times one person played a track, all-time.

Trait Implementations§

Source§

impl Clone for UserData

Source§

fn clone(&self) -> UserData

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 Debug for UserData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UserData

Source§

fn default() -> UserData

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

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

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.

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,