import Foundation
import VelodyDomain

public protocol LocalLibraryStore: Sendable {
    func loadTracks() async -> [LibraryTrack]
    func replaceTracks(_ tracks: [LibraryTrack]) async
}

public actor InMemoryLocalLibraryStore: LocalLibraryStore {
    private var tracks: [LibraryTrack]

    public init(tracks: [LibraryTrack] = []) {
        self.tracks = tracks
    }

    public func loadTracks() async -> [LibraryTrack] {
        tracks
    }

    public func replaceTracks(_ tracks: [LibraryTrack]) async {
        self.tracks = tracks
    }
}
