AACS pipeline reshape + TrueHD metadata + central consts + clippy/fmt clean

- AACS: delete in-lib keydb parser (Step 3); boil-down primitives
  (mk_from_dk/vuk_from_mk/uk_from_vuk) + newtypes; KeySource->get_uk(ctx)+
  ResolveCtx; Unlocker->unlock()->Result<Vid,UnlockError> + AacsCertUnlocker;
  OEM bus-key gate (AacsBusKeyUnavailable); structured ResolutionTrace (Step 4).
- TrueHD: sample-rate from major-sync, Atmos label, 44.1k AU duration.
- consts: central media/format constants module; 17 duplicate const-defs
  centralized (sector/TS-packet/source-packet); mpls stream-entry + category
  codes named.
- clippy --all-targets -D warnings clean (1.86); fmt clean; 2199 lib tests.
This commit is contained in:
Matthew Jackson
2026-06-26 12:19:24 -07:00
parent 05729f5dfe
commit decb87a250
48 changed files with 2208 additions and 2031 deletions
+18 -18
View File
@@ -244,6 +244,22 @@ fn cstr_to_str(bytes: &[u8]) -> &str {
std::str::from_utf8(&bytes[..end]).unwrap_or("")
}
pub(super) fn drive_has_disc(path: &Path) -> Result<bool> {
let mut transport = MacScsiTransport::open(path)?;
let cdb = [crate::scsi::SCSI_TEST_UNIT_READY, 0, 0, 0, 0, 0];
let mut buf = [0u8; 0];
match transport.execute(
&cdb,
crate::scsi::DataDirection::None,
&mut buf,
crate::scsi::TUR_TIMEOUT_MS,
) {
Ok(_) => Ok(true),
Err(ref e) if e.scsi_sense().is_some_and(|s| s.is_not_ready()) => Ok(false),
Err(e) => Err(e),
}
}
#[cfg(test)]
mod tests {
use super::K_MAX_CDB_SIZE;
@@ -256,7 +272,7 @@ mod tests {
#[test]
fn oversized_cdb_returns_invalid_cdb_length() {
// Build a CDB one byte over the limit.
let long_cdb = vec![0u8; K_MAX_CDB_SIZE + 1];
let long_cdb = [0u8; K_MAX_CDB_SIZE + 1];
// Replicate the guard logic from MacScsiTransport::execute so
// this test runs on Linux CI as well (no IOKit present there).
let result: Result<(), Error> = if long_cdb.len() > K_MAX_CDB_SIZE {
@@ -279,7 +295,7 @@ mod tests {
/// A CDB exactly at the limit must not trigger the guard.
#[test]
fn max_length_cdb_does_not_trigger_guard() {
let cdb = vec![0u8; K_MAX_CDB_SIZE];
let cdb = [0u8; K_MAX_CDB_SIZE];
let triggered = cdb.len() > K_MAX_CDB_SIZE;
assert!(
!triggered,
@@ -287,19 +303,3 @@ mod tests {
);
}
}
pub(super) fn drive_has_disc(path: &Path) -> Result<bool> {
let mut transport = MacScsiTransport::open(path)?;
let cdb = [crate::scsi::SCSI_TEST_UNIT_READY, 0, 0, 0, 0, 0];
let mut buf = [0u8; 0];
match transport.execute(
&cdb,
crate::scsi::DataDirection::None,
&mut buf,
crate::scsi::TUR_TIMEOUT_MS,
) {
Ok(_) => Ok(true),
Err(ref e) if e.scsi_sense().is_some_and(|s| s.is_not_ready()) => Ok(false),
Err(e) => Err(e),
}
}
+3 -1
View File
@@ -992,7 +992,8 @@ mod scsi_sense_predicate_tests {
// Each is_* predicate matches exactly its one key and no other.
// Catches a copy-paste bug where e.g. is_not_ready compared the
// wrong constant.
let cases: &[(u8, fn(&ScsiSense) -> bool)] = &[
type SenseCase = (u8, fn(&ScsiSense) -> bool);
let cases: &[SenseCase] = &[
(SENSE_KEY_MEDIUM_ERROR, ScsiSense::is_medium_error),
(SENSE_KEY_HARDWARE_ERROR, ScsiSense::is_hardware_error),
(SENSE_KEY_NOT_READY, ScsiSense::is_not_ready),
@@ -1126,6 +1127,7 @@ mod inquiry_tests {
//! - vendor identification: bytes 8..16 (8 ASCII chars)
//! - product identification: bytes 16..32 (16 ASCII chars)
//! - product revision level: bytes 32..36 (4 ASCII chars)
//!
//! Fields are space-padded ASCII; the parser trims surrounding
//! whitespace.
use super::*;