Compare commits

..

No commits in common. "main" and "0.1.3" have entirely different histories.
main ... 0.1.3

5 changed files with 9 additions and 79 deletions

View file

@ -45,7 +45,7 @@ getrandom = { version = "0.2", features = ["js"] }
des = "0.8" des = "0.8"
cbc = "0.1" cbc = "0.1"
ecb = "0.1" ecb = "0.1"
tokio = { version = "1.36", features = ["full", "sync"] } tokio = { version = "1.36", features = ["sync"] }
g2-unicode-jp = "0.4.1" g2-unicode-jp = "0.4.1"
thiserror = "1.0.57" thiserror = "1.0.57"
phf = { version = "0.11.2", features = ["phf_macros", "macros"] } phf = { version = "0.11.2", features = ["phf_macros", "macros"] }

View file

@ -4,7 +4,7 @@
A library for controlling and interfacing with [MiniDisc](https://en.wikipedia.org/wiki/MiniDisc) devices from within Rust programs. Compatible with many cross platform targets (including Web Assembly!) by using [cross-usb](https://github.com/G2-Games/cross-usb). A library for controlling and interfacing with [MiniDisc](https://en.wikipedia.org/wiki/MiniDisc) devices from within Rust programs. Compatible with many cross platform targets (including Web Assembly!) by using [cross-usb](https://github.com/G2-Games/cross-usb).
The feature set is very similar to that of [netmd-js](https://github.com/cybercase/netmd-js) which this library is inspired by. Development of this project was made much easier by the absolutely awesome [Web Minidisc project](https://github.com/asivery/webminidisc), [NetMD-exploits](https://github.com/asivery/netmd-exploits), and the C based [Linux Minidisc project](https://github.com/linux-minidisc/linux-minidisc). Go check those projects out! The feature set is very similar to that of [netmd-js](https://github.com/cybercase/netmd-js) which this library is inspired by. Devlopment of this project was made much easier by the absolutely awesome [Web Minidisc project](https://github.com/asivery/webminidisc), [NetMD-exploits](https://github.com/asivery/netmd-exploits), and the C based [Linux Minidisc project](https://github.com/linux-minidisc/linux-minidisc). Go check those projects out!
> [!IMPORTANT] > [!IMPORTANT]
> Documentation has not been finished and is a work in progress. Any contributions would be appreciated! > Documentation has not been finished and is a work in progress. Any contributions would be appreciated!

View file

@ -1,42 +0,0 @@
use std::{process::exit, time::Duration};
#[tokio::main]
async fn main() {
let Ok(player) = cross_usb::get_device(minidisc::netmd::DEVICE_IDS_CROSSUSB.to_vec()).await else {
eprintln!("Could not find a MiniDisc device");
exit(1);
};
let Ok(mut player) = minidisc::netmd::NetMDContext::new(player).await else {
eprintln!("Could not open device!");
exit(1);
};
let disc = player.list_content().await.expect("Could not retrieve player's contents");
for track in disc.tracks() {
println!(
"{:02}:\n Title: {} | {}\n Duration: {}\n Encoding: {}\n",
track.index(),
track.title(), track.full_width_title(),
pretty_time(track.duration().as_duration()),
track.encoding(),
);
}
}
fn pretty_time(dur: Duration) -> String {
let mut string = String::new();
if dur >= Duration::from_secs(3600) {
string.push_str(&format!("{:02}", dur.as_secs() / 3600));
string.push(':');
}
if dur >= Duration::from_secs(60) {
string.push_str(&format!("{:02}", (dur.as_secs() / 60) % 3600).to_string());
string.push(':');
}
if dur >= Duration::from_secs(60) {
string.push_str(&format!("{:02}", dur.as_secs() % 60).to_string());
}
string
}

View file

@ -32,8 +32,8 @@ pub enum OperatingStatus {
ReadyForTransfer = 65319, ReadyForTransfer = 65319,
} }
/// A representation of time in the way a NetMD device uses internally. /// A representation of time in the same way NetMD devices do.
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone)]
pub struct Time { pub struct Time {
pub minute: u16, pub minute: u16,
pub second: u16, pub second: u16,
@ -41,7 +41,7 @@ pub struct Time {
} }
/// A representation of the current status of the device. /// A representation of the current status of the device.
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone)]
pub struct DeviceStatus { pub struct DeviceStatus {
pub disc_present: bool, pub disc_present: bool,
pub state: Option<OperatingStatus>, pub state: Option<OperatingStatus>,
@ -50,7 +50,7 @@ pub struct DeviceStatus {
} }
/// Information about a single track /// Information about a single track
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone)]
pub struct Track { pub struct Track {
index: u16, index: u16,
title: String, title: String,
@ -77,34 +77,6 @@ impl Track {
usize::max(encoding_name_correction, full_width_length), usize::max(encoding_name_correction, full_width_length),
) )
} }
pub fn index(&self) -> u16 {
self.index
}
pub fn title(&self) -> &String {
&self.title
}
pub fn full_width_title(&self) -> &String {
&self.full_width_title
}
pub fn duration(&self) -> RawTime {
self.duration
}
pub fn channels(&self) -> Channels {
self.channel
}
pub fn encoding(&self) -> Encoding {
self.encoding
}
pub fn protected(&self) -> TrackFlag {
self.protected
}
} }
/// Information about a single group on the disc, containing [`Track`]s /// Information about a single group on the disc, containing [`Track`]s

View file

@ -75,7 +75,7 @@ impl WireFormat {
} }
/// The encoding of the audio /// The encoding of the audio
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Copy)]
pub enum Encoding { pub enum Encoding {
SP = 0x90, SP = 0x90,
LP2 = 0x92, LP2 = 0x92,
@ -93,7 +93,7 @@ impl std::fmt::Display for Encoding {
} }
/// The number of channels in the audio /// The number of channels in the audio
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Copy)]
pub enum Channels { pub enum Channels {
Mono = 0x01, Mono = 0x01,
Stereo = 0x00, Stereo = 0x00,
@ -114,7 +114,7 @@ enum ChannelCount {
} }
/// The protected flag on a track /// The protected flag on a track
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive)] #[derive(Debug, Clone, Copy, FromPrimitive)]
pub enum TrackFlag { pub enum TrackFlag {
Protected = 0x03, Protected = 0x03,
Unprotected = 0x00, Unprotected = 0x00,