Crate gnudb

Crate gnudb 

Source
Expand description

Crate to get CDDB information from gnudb.org (like cddb.com and freedb.org in the past)

Right now only login, query and read are implemented, both over HTTP and CDDBP protocol. All CDDBP I/O is done async using smol. The HTTP functions are synchronous for simplicity, using ureq.

Example HTTP usage:

use gnudb::{Connection, Match};
use discid::DiscId;
use gnudb::{http_query, http_read};

    // get a disc id by querying the disc in the default CD/DVD ROM drive
    let discid = DiscId::read(Some(DiscId::default_device().as_str())).unwrap();
    let matches: Vec<Match> = http_query("gnudb.gnudb.org", 80, &discid).unwrap();
    // select the right match
    let m: &Match = &matches[2];
    // read all the metadata
    let _disc = http_read("gnudb.gnudb.org", 80, m).unwrap();

Example CDDBP usage:

use gnudb::{Connection, Match};
use discid::DiscId;
use smol::block_on;

block_on(async {
    // get a disc id by querying the disc in the default CD/DVD ROM drive
    let discid = DiscId::read(Some(DiscId::default_device().as_str())).unwrap();
    // open a connection
    let mut con = Connection::new().await.unwrap();
    // find a list of matches (could be multiple)
    let matches: Vec<Match> = con.query(&discid).await.unwrap();
    // select the right match
    let m: &Match = &matches[2];
    // read all the metadata
    let _disc = con.read(m).await.unwrap();
    // close the connection (Drop trait is implemented, so not strictly necessary)
    con.close();
});

Modules§

error

Structs§

Connection
Represents a CDDBP connection to a GNUDb server Multiple commands can be sent over the same connection
Disc
Match
Track

Functions§

http_query
HTTP query to a GNUDb server for a given discid returns a vector of matches or an error Every query creates a new connection
http_read
HTTP read to a GNUDb server to fetch a single disc’s metadata Every request creates a new connection