Restructured as library

This commit is contained in:
G2-Games 2023-09-25 02:05:59 -05:00
parent 54b0977b44
commit 53480ce2eb
10 changed files with 42 additions and 33 deletions

View file

@ -1,13 +1,16 @@
[package] [package]
name = "minidisc-rs" name = "minidisc-cli"
homepage = "https://github.com/G2-Games/minidisc-rs"
repository = "https://github.com/G2-Games/minidisc-rs"
readme = "README.md"
version = "0.0.1" version = "0.0.1"
edition = "2021" edition = "2021"
authors = ["G2 <g2@g2games.dev>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html license = "AGPL-3.0"
[dependencies] [dependencies]
encoding_rs = "0.8.33"
nofmt = "1.0.0"
once_cell = "1.18.0"
rusb = "0.9.3" rusb = "0.9.3"
[dependencies.minidisc-rs]
path = "minidisc-rs"
version = "0.0.1"

10
minidisc-rs/.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

14
minidisc-rs/Cargo.toml Normal file
View file

@ -0,0 +1,14 @@
[package]
name = "minidisc-rs"
version = "0.0.1"
authors = ["G2 <g2@g2games.dev>"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
encoding_rs = "0.8.33"
nofmt = "1.0.0"
once_cell = "1.18.0"
rusb = "0.9.3"

3
minidisc-rs/src/lib.rs Normal file
View file

@ -0,0 +1,3 @@
pub mod netmd;
use netmd::base::NetMD;

View file

@ -5,8 +5,6 @@ use encoding_rs::*;
use std::collections::HashMap; use std::collections::HashMap;
use std::error::Error; use std::error::Error;
use super::utils::half_width_to_full_width_range;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
enum Action { enum Action {
Play = 0x75, Play = 0x75,
@ -173,10 +171,12 @@ struct MediaInfo {
supports_md_clip: u8, supports_md_clip: u8,
} }
/// An interface for interacting with a NetMD device
pub struct NetMDInterface { pub struct NetMDInterface {
pub net_md_device: NetMD, pub net_md_device: NetMD,
} }
#[allow(dead_code)]
impl NetMDInterface { impl NetMDInterface {
const MAX_INTERIM_READ_ATTEMPTS: u8 = 4; const MAX_INTERIM_READ_ATTEMPTS: u8 = 4;
const INTERIM_RESPONSE_RETRY_INTERVAL: u32 = 100; const INTERIM_RESPONSE_RETRY_INTERVAL: u32 = 100;

View file

@ -163,7 +163,6 @@ pub fn scan_query(
input_stack.next(); input_stack.next();
for character in format.chars() { for character in format.chars() {
println!("{}", character);
if escaped { if escaped {
if endianness_override.is_none() && ['<', '>'].contains(&character) { if endianness_override.is_none() && ['<', '>'].contains(&character) {
endianness_override = Some(character); endianness_override = Some(character);
@ -178,7 +177,6 @@ pub fn scan_query(
match character { match character {
character if FORMAT_TYPE_LEN_DICT.contains_key(&character) => { character if FORMAT_TYPE_LEN_DICT.contains_key(&character) => {
println!("Character: {}", character);
match character { match character {
'b' => { 'b' => {
let new_value = let new_value =

View file

@ -1,10 +1,5 @@
mod netmd; use minidisc_rs::netmd::{base, interface};
use rusb;
use crate::netmd::base::NetMD;
use crate::netmd::interface::NetMDInterface;
use std::thread;
use std::time::Duration;
fn main() { fn main() {
for device in rusb::devices().unwrap().iter() { for device in rusb::devices().unwrap().iter() {
@ -24,8 +19,8 @@ fn main() {
new_device.read_product_string_ascii(&device_desc) new_device.read_product_string_ascii(&device_desc)
); );
let player = NetMD::new(new_device, device_desc).unwrap(); let player = base::NetMD::new(new_device, device_desc).unwrap();
let player_controller = NetMDInterface::new(player); let player_controller = interface::NetMDInterface::new(player);
println!( println!(
"Player Model: {}", "Player Model: {}",
@ -49,19 +44,5 @@ fn main() {
player_controller.track_title(i as u16, true).unwrap() player_controller.track_title(i as u16, true).unwrap()
); );
}*/ }*/
/*
let mut request: [u8; 19] = [0x00, 0x18, 0x06, 0x02, 0x20, 0x18,
0x01, 0x00, 0x00, 0x30, 0x00, 0xa,
0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00];
request[4] = 0x75;
let test_result = player.send_command(&request);
match test_result {
Ok(_) => println!("Successfully sent command! Response: {:?}", test_result),
Err(error) => println!("Command failed! Error: {}", error)
}
*/
} }
} }