MCPcopy Create free account
hub / github.com/Moosync/Moosync / dump_store

Method dump_store

src/store/player_store.rs:595–630  ·  view source on GitHub ↗
(&self, dump_types: &[DumpType])

Source from the content-addressed store, hash-verified

593
594 #[tracing::instrument(level = "debug", skip(self))]
595 fn dump_store(&self, dump_types: &[DumpType]) {
596 let db = Database::open("moosync").build();
597
598 let data = dump_types
599 .iter()
600 .map(|d| match d {
601 DumpType::PlayerState => (
602 "dump_player_state",
603 bitcode::encode(&self.data.player_details),
604 ),
605 DumpType::SongQueue => (
606 "dump_song_queue",
607 bitcode::encode(&self.data.queue.song_queue),
608 ),
609 DumpType::CurrentIndex => (
610 "dump_current_index",
611 bitcode::encode(&self.data.queue.current_index),
612 ),
613 DumpType::QueueData => ("dump_queue_data", bitcode::encode(&self.data.queue.data)),
614 })
615 .collect_vec();
616
617 if let Ok(db) = db {
618 spawn_local(async move {
619 if let Ok(db) = db.await {
620 for dump_type in data {
621 if let Err(e) =
622 write_to_indexed_db(&db, "player_store", dump_type.0, dump_type.1).await
623 {
624 tracing::error!("Failed to dump store: {:?}", e);
625 }
626 }
627 }
628 });
629 }
630 }
631
632 #[tracing::instrument(level = "debug", skip(db, signal))]
633 fn restore_store(signal: RwSignal<Option<PlayerStoreData>>, db: Database) {

Callers 10

update_current_songMethod · 0.80
add_to_queue_at_indexMethod · 0.80
remove_from_queueMethod · 0.80
insert_song_at_indexMethod · 0.80
set_stateMethod · 0.80
set_volumeMethod · 0.80
update_volume_modeMethod · 0.80
toggle_repeatMethod · 0.80
shuffle_queueMethod · 0.80

Calls 1

write_to_indexed_dbFunction · 0.85

Tested by

no test coverage detected