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
impl UserData
Sourcepub fn playback_state(
&self,
owner: &str,
profile: &str,
) -> Option<&PlaybackState>
pub fn playback_state( &self, owner: &str, profile: &str, ) -> Option<&PlaybackState>
Read only one owner’s named checkpoint; another owner cannot select it.
Sourcepub fn set_playback_state(
&mut self,
state: PlaybackState,
) -> Result<(), StoreError>
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.
Sourcepub fn clear_playback_state(&mut self, owner: &str, profile: &str) -> bool
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
impl UserData
Sourcepub fn playlist(&self, owner: &str, id: &str) -> Option<&Playlist>
pub fn playlist(&self, owner: &str, id: &str) -> Option<&Playlist>
Finds a playlist only within the supplied owner’s private namespace.
Sourcepub fn create_playlist(
&mut self,
owner: &str,
name: &str,
tracks: Vec<EntityRef>,
now: u64,
) -> Result<String, String>
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.
Sourcepub fn update_playlist(
&mut self,
owner: &str,
id: &str,
name: Option<&str>,
comment: Option<&str>,
tracks: Option<Vec<EntityRef>>,
now: u64,
) -> Result<(), String>
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.
Sourcepub fn delete_playlist(&mut self, owner: &str, id: &str) -> bool
pub fn delete_playlist(&mut self, owner: &str, id: &str) -> bool
Deliberately removes one owner’s playlist, leaving all music intact.
Sourcepub fn record_scrobble(&mut self, event: Scrobble) -> Result<(), String>
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
impl UserData
Sourcepub fn preview_relink(
&self,
owner: &str,
from: &EntityRef,
to: &EntityRef,
catalog: &Catalog,
) -> Result<RelinkSummary, String>
pub fn preview_relink( &self, owner: &str, from: &EntityRef, to: &EntityRef, catalog: &Catalog, ) -> Result<RelinkSummary, String>
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.
Sourcepub fn relink(
&mut self,
owner: &str,
from: &EntityRef,
to: &EntityRef,
catalog: &Catalog,
now: u64,
) -> Result<u64, String>
pub fn relink( &mut self, owner: &str, from: &EntityRef, to: &EntityRef, catalog: &Catalog, now: u64, ) -> Result<u64, String>
Applies a validated reattachment, preserving its original records for undo.
Sourcepub fn preview_undo_relink(
&self,
owner: &str,
id: u64,
) -> Result<RelinkSummary, String>
pub fn preview_undo_relink( &self, owner: &str, id: u64, ) -> Result<RelinkSummary, String>
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.
Sourcepub fn undo_relink(
&mut self,
owner: &str,
id: u64,
now: u64,
) -> Result<RelinkSummary, String>
pub fn undo_relink( &mut self, owner: &str, id: u64, now: u64, ) -> Result<RelinkSummary, String>
Takes back one reattachment after the same checks as its preview.
Source§impl UserData
impl UserData
Sourcepub fn find(&self, owner: &str, target: &EntityRef) -> Option<&Annotation>
pub fn find(&self, owner: &str, target: &EntityRef) -> Option<&Annotation>
The record for one owner and target, if there is one.
Sourcepub fn entry(
&mut self,
owner: &str,
target: &EntityRef,
now: u64,
) -> &mut Annotation
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.
Sourcepub fn forget_empty(&mut self)
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.
Sourcepub fn find_relation(
&self,
owner: &str,
relation: &RelationRef,
) -> Option<&RelationAnnotation>
pub fn find_relation( &self, owner: &str, relation: &RelationRef, ) -> Option<&RelationAnnotation>
Personal annotation for one relation, if one exists.
Sourcepub fn find_relation_in(
&self,
catalog: &Catalog,
owner: &str,
relation: &RelationRef,
) -> Option<&RelationAnnotation>
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.
Sourcepub fn relation_entry_in(
&mut self,
catalog: &Catalog,
owner: &str,
relation: &RelationRef,
now: u64,
) -> Result<&mut RelationAnnotation, String>
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.
Sourcepub fn remove_relation_in(
&mut self,
catalog: &Catalog,
owner: &str,
relation: &RelationRef,
) -> Result<bool, String>
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.
Sourcepub fn relation_entry(
&mut self,
owner: &str,
relation: &RelationRef,
now: u64,
) -> &mut RelationAnnotation
pub fn relation_entry( &mut self, owner: &str, relation: &RelationRef, now: u64, ) -> &mut RelationAnnotation
Opens the personal annotation for one relation.
Sourcepub fn copy(
&mut self,
owner: &str,
from: &EntityRef,
to: &EntityRef,
now: u64,
) -> bool
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.
Sourcepub fn forget_last_play(&mut self, owner: &str, track: &EntityRef) -> bool
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.
Sourcepub fn forget_history(&mut self, owner: &str) -> (usize, usize)
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.
Sourcepub fn record_play(&mut self, play: Play)
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.
Sourcepub fn collection(&self, owner: &str, name: &str) -> Option<&Collection>
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”.
Sourcepub fn save_collection(
&mut self,
owner: &str,
name: &str,
expression: &str,
now: u64,
) -> bool
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.
Sourcepub fn forget_collection(&mut self, owner: &str, name: &str) -> bool
pub fn forget_collection(&mut self, owner: &str, name: &str) -> bool
Drops a saved query; false when there was none by that name.
Sourcepub fn play_count(&self, owner: &str, track: &EntityRef) -> u32
pub fn play_count(&self, owner: &str, track: &EntityRef) -> u32
How many times one person played a track, all-time.