pub struct Drive {
pub profile: Option<DriveProfile>,
pub platform: Option<Platform>,
pub drive_id: DriveId,
/* private fields */
}Expand description
Optical disc drive session – open, identify, unlock, and read.
Fields§
§profile: Option<DriveProfile>§platform: Option<Platform>§drive_id: DriveIdImplementations§
Source§impl Drive
impl Drive
pub fn open(device: &Path) -> Result<Self>
Sourcepub fn halt_flag(&self) -> Arc<AtomicBool>
pub fn halt_flag(&self) -> Arc<AtomicBool>
Get a clone of the halt flag. Set to true to interrupt Drive::read().
Sourcepub fn clear_halt(&self)
pub fn clear_halt(&self)
Clear the halt flag for the next operation.
Sourcepub fn on_event(&mut self, f: impl Fn(Event) + Send + 'static)
pub fn on_event(&mut self, f: impl Fn(Event) + Send + 'static)
Set an event handler for read recovery events.
Sourcepub fn close(self)
pub fn close(self)
Close the drive cleanly. Unlocks tray, flushes SCSI state, closes fd. Also runs automatically on Drop as a safety net.
pub fn device_path_owned(&self) -> String
Sourcepub fn has_profile(&self) -> bool
pub fn has_profile(&self) -> bool
Whether this drive has a known profile (unlock parameters available).
Sourcepub fn scsi_mut(&mut self) -> &mut dyn ScsiTransport
pub fn scsi_mut(&mut self) -> &mut dyn ScsiTransport
Access the SCSI transport for direct commands (used by CSS/AACS auth).
pub fn wait_ready(&mut self) -> Result<()>
Sourcepub fn drive_status(&mut self) -> DriveStatus
pub fn drive_status(&mut self) -> DriveStatus
Query the physical state of the drive — disc present, tray open, etc. Uses GET EVENT STATUS NOTIFICATION which works regardless of firmware state.
pub fn platform_name(&self) -> &str
pub fn device_path(&self) -> &str
Sourcepub fn init(&mut self) -> Result<()>
pub fn init(&mut self) -> Result<()>
Initialize drive — unlock + firmware upload. Optional. Adds features: removes riplock, enables UHD reads, speed control.
Sourcepub fn probe_disc(&mut self) -> Result<()>
pub fn probe_disc(&mut self) -> Result<()>
Probe disc surface so the drive firmware learns optimal read speeds per region. After this the host reads at max speed and the drive manages zones internally.
Sourcepub fn get_config_feature(&mut self, feature_code: u16) -> Option<Vec<u8>>
pub fn get_config_feature(&mut self, feature_code: u16) -> Option<Vec<u8>>
Query a specific GET CONFIGURATION feature by code. Returns the feature data (without the 8-byte header), or None if not available.
Sourcepub fn report_key_rpc_state(&mut self) -> Option<Vec<u8>>
pub fn report_key_rpc_state(&mut self) -> Option<Vec<u8>>
Read REPORT KEY RPC state (region playback control).
Sourcepub fn read_buffer(
&mut self,
mode: u8,
buffer_id: u8,
length: u16,
) -> Option<Vec<u8>>
pub fn read_buffer( &mut self, mode: u8, buffer_id: u8, length: u16, ) -> Option<Vec<u8>>
Read vendor-specific READ BUFFER data.
pub fn is_ready(&self) -> bool
Sourcepub fn read(
&mut self,
lba: u32,
count: u16,
buf: &mut [u8],
recovery: bool,
) -> Result<usize>
pub fn read( &mut self, lba: u32, count: u16, buf: &mut [u8], recovery: bool, ) -> Result<usize>
Read sectors from the disc. Single-shot — no inline retries, no SCSI reset.
recovery=true bumps the per-CDB timeout to 30 s for the
Disc::patch pass; recovery=false uses 1.5 s for Disc::copy’s
fast skip-forward sweep. On any failure returns Err(DiscRead)
immediately. The orchestration layer (Disc::patch’s outer loop
for the patch pass, DiscStream’s adaptive batch halving for the
stream path) handles retries.
Inline retry phases (5× gentle + reset+reopen + 5× more) were
removed in 0.13.6. Per
freemkv-private/postmortems/2026-04-25-stop-wedge-and-zero-kbs.md,
the inline reset on the LG BU40N (Initio bridge) wedged drive
firmware without ever recovering a sector. The remaining recovery
layers (Disc::patch multi-pass, DiscStream batch halving) do not
touch the wedge-prone reset path.
Sourcepub fn read_capacity(&mut self) -> Result<u32>
pub fn read_capacity(&mut self) -> Result<u32>
Read the disc capacity in sectors (2048 bytes each).
pub fn set_speed(&mut self, speed_kbs: u16)
Sourcepub fn unlock_tray(&mut self)
pub fn unlock_tray(&mut self)
Unlock the tray so the user can manually eject the disc.
pub fn scsi_execute( &mut self, cdb: &[u8], direction: DataDirection, buf: &mut [u8], timeout_ms: u32, ) -> Result<ScsiResult>
Trait Implementations§
Source§impl SectorReader for Drive
impl SectorReader for Drive
Source§fn read_sectors(
&mut self,
lba: u32,
count: u16,
buf: &mut [u8],
recovery: bool,
) -> Result<usize>
fn read_sectors( &mut self, lba: u32, count: u16, buf: &mut [u8], recovery: bool, ) -> Result<usize>
count sectors starting at lba into buf.
buf must be at least count * 2048 bytes.
recovery: true = full retry/reset loop (ripping), false = single attempt (verify).
File-backed readers ignore the flag.