Skip to content

Request and Response Enums

Joseph Chacko edited this page Jul 22, 2026 · 2 revisions

Request & Response Enums

Relevant source files

The following files were used as context for generating this wiki page:

The aurora-protocol crate defines the communication schema between the aurora-player (GUI) and the aurora-daemon (Background Service). This schema is centered around two primary enums: Request and Response. These enums serve as the high-level API for all music player operations, including playback control, library management, and preference synchronization.

Communication Overview

The system utilizes a client-server model over a Unix Domain Socket. The Request enum represents commands sent from the client to the daemon, while the Response enum represents data or status updates sent from the daemon back to the client.

Request-Response Data Flow

The following diagram illustrates how an action in the UI translates into a Request and results in a Response that updates the system state.

Action to Code Entity Mapping

graph TD
    subgraph "Natural Language Space"
        A["'Play a song'"]
        B["'Search for artist'"]
        C["'Change Volume'"]
    end

    subgraph "Code Entity Space (aurora-protocol)"
        A --> RA["Request::Play(Uuid)"]
        B --> RB["Request::Search(SearchType::ByArtist(String))"]
        C --> RC["Request::SetVolume(f32)"]
        
        RA --> SA["Response::Status(Status)"]
        RB --> SB["Response::SearchResults(Vec<Song>)"]
        RC --> SC["Response::Volume(f32)"]
    end

    subgraph "Daemon Logic (aurora-daemon)"
        RA -.-> H1["handle_client()"]
        RB -.-> H1
        RC -.-> H1
    end
Loading

Sources: protocol/src/interface.rs:5-50, protocol/src/lib.rs:23-26


Request Enum Reference

The Request enum protocol/src/interface.rs:6-35 contains all possible commands the daemon can execute. It is serialized using serde for transmission over the wire.

Playback & Transport Controls

These variants control the active audio stream and the playback queue.

Variant Parameters Description
Play Uuid Immediately clears the queue and plays the song identified by the Uuid.
Pause None Toggles the playback state (Play/Pause).
Next usize Skips forward by N tracks in the queue.
Prev usize Skips backward by N tracks in the queue.
Seek Duration Jumps to a specific timestamp in the current track.
SetVolume f32 Sets the output volume (0.0 to 1.0).

Queue Management

These variants manipulate the current playback list without necessarily interrupting the currently playing song.

Variant Parameters Description
Enqueue Uuid Adds a song to the end of the queue.
PlayNext Uuid Adds a song to the queue immediately after the current track.
ReplaceQueue Vec<Uuid> Replaces the entire current queue with a new list of song IDs.
Clear None Removes all songs from the queue.
RemoveSong Uuid Removes all instances of a specific song ID from the queue.
RemoveSongAt usize Removes the song at a specific index in the queue.
MoveQueue from: usize, to: usize Reorders a song within the queue.
SetShuffle bool Enables or disables shuffle mode.
SetRepeat u8 Sets repeat mode (0: Off, 1: Single, 2: All).

Library & Search

Used for querying the SQLite database managed by the daemon.

Variant Parameters Description
Search SearchType Queries songs by title or artist protocol/src/lib.rs:23-26.
GetArtistList None Retrieves a unique list of all artists in the library.
GetLastPlayed None Retrieves the playback history.
GetLikedSongs None Retrieves all songs marked as "liked".
LikeSong Uuid Adds a song to the liked collection.
UnlikeSong Uuid Removes a song from the liked collection.

Playlist Operations

CRUD operations for user-defined playlists.

Variant Parameters Description
PlaylistList None Requests a list of all available playlists.
PlaylistGet Uuid Requests the full details (including song list) for a playlist.
PlaylistCreate PlaylistIn Creates a new playlist entry.
PlaylistDelete Uuid Deletes a playlist by ID.
PlaylistAddSongs playlist_id, song_ids Appends multiple songs to a playlist.
PlaylistRemoveSong playlist_id, song_id Removes a specific song from a playlist.
PlaylistRename playlist_id, new_title Updates the display name of a playlist.

Sources: protocol/src/interface.rs:6-35, protocol/src/lib.rs:23-26


Response Enum Reference

The Response enum protocol/src/interface.rs:38-50 is sent by the daemon to provide data requested by the client or to broadcast state changes (like volume or theme updates).

Variant Data Type Description
Status Status Contains the current playback state, position, and active song protocol/src/lib.rs:13-20.
Queue Vec<Song> Returns the full list of songs currently in the queue.
SearchResults Vec<Song> Returns songs matching a Search request.
PlaylistList Vec<PlaylistMinimal> Returns basic info (ID/Title) for all playlists.
PlaylistResults Playlist Returns the full Playlist object including its songs.
ArtistList Vec<String> Returns a list of unique artist names.
Theme Theme Broadcasts the current color palette for UI skinning protocol/src/lib.rs:29-40.
Volume f32 Broadcasts the current volume level.
Error err_id, err_msg Indicates a failure in processing a request.
LikedSongs Vec<Song> Returns the list of liked songs.

Sources: protocol/src/interface.rs:38-50, protocol/src/lib.rs:13-20, protocol/src/lib.rs:29-40


Data Structures & State Flow

The Status struct is the most frequently transmitted data, as it is sent every time the playback position or state changes.

State Update Lifecycle

sequenceDiagram
    participant C as aurora-player (Client)
    participant D as aurora-daemon (Server)
    participant S as StateStruct

    Note over C, D: Connection established via Unix Socket
    C->>D: Request::SetVolume(0.8)
    D->>S: update volume in StateStruct
    S-->>D: state updated
    D->>C: Response::Volume(0.8)
    D->>C: Response::Status(Status { ... })
Loading

Key Supporting Types

  • Status: A snapshot of the daemon's playback engine, including current_song, is_paused, position, volume, shuffle, and repeat protocol/src/lib.rs:13-20.
  • SearchType: An enum used in Request::Search to specify the query scope (ByTitle or ByArtist) protocol/src/lib.rs:23-26.
  • Theme: A collection of hex color strings (e.g., bgd0, acct, srch) used to dynamically style the Slint UI protocol/src/lib.rs:29-40.

Sources: protocol/src/interface.rs:38-50, protocol/src/lib.rs:12-41

Clone this wiki locally