Skip to main content

Drive

Struct Drive 

Source
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: DriveId

Implementations§

Source§

impl Drive

Source

pub fn open(device: &Path) -> Result<Self>

Source

pub fn halt_flag(&self) -> Arc<AtomicBool>

Get a clone of the halt flag. Set to true to interrupt Drive::read().

Source

pub fn halt(&self)

Halt the drive — Drive::read() will bail at the next check point.

Source

pub fn clear_halt(&self)

Clear the halt flag for the next operation.

Source

pub fn on_event(&mut self, f: impl Fn(Event) + Send + 'static)

Set an event handler for read recovery events.

Source

pub fn close(self)

Close the drive cleanly. Unlocks tray, flushes SCSI state, closes fd. Also runs automatically on Drop as a safety net.

Source

pub fn device_path_owned(&self) -> String

Source

pub fn has_profile(&self) -> bool

Whether this drive has a known profile (unlock parameters available).

Source

pub fn scsi_mut(&mut self) -> &mut dyn ScsiTransport

Access the SCSI transport for direct commands (used by CSS/AACS auth).

Source

pub fn wait_ready(&mut self) -> Result<()>

Source

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.

Source

pub fn platform_name(&self) -> &str

Source

pub fn device_path(&self) -> &str

Source

pub fn init(&mut self) -> Result<()>

Initialize drive — unlock + firmware upload. Optional. Adds features: removes riplock, enables UHD reads, speed control.

Source

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.

Source

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.

Source

pub fn report_key_rpc_state(&mut self) -> Option<Vec<u8>>

Read REPORT KEY RPC state (region playback control).

Source

pub fn mode_sense_page(&mut self, page: u8) -> Option<Vec<u8>>

Read MODE SENSE page data.

Source

pub fn read_buffer( &mut self, mode: u8, buffer_id: u8, length: u16, ) -> Option<Vec<u8>>

Read vendor-specific READ BUFFER data.

Source

pub fn is_ready(&self) -> bool

Source

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.

Source

pub fn read_capacity(&mut self) -> Result<u32>

Read the disc capacity in sectors (2048 bytes each).

Source

pub fn set_speed(&mut self, speed_kbs: u16)

Source

pub fn lock_tray(&mut self)

Lock the tray so the disc cannot be ejected during a rip.

Source

pub fn unlock_tray(&mut self)

Unlock the tray so the user can manually eject the disc.

Source

pub fn eject(&mut self) -> Result<()>

Eject the disc tray. Unlocks first, then ejects.

Source

pub fn scsi_execute( &mut self, cdb: &[u8], direction: DataDirection, buf: &mut [u8], timeout_ms: u32, ) -> Result<ScsiResult>

Trait Implementations§

Source§

impl Drop for Drive

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl SectorReader for Drive

Source§

fn read_sectors( &mut self, lba: u32, count: u16, buf: &mut [u8], recovery: bool, ) -> Result<usize>

Read 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.
Source§

fn capacity(&self) -> u32

Total capacity in sectors, if known.

Auto Trait Implementations§

§

impl Freeze for Drive

§

impl !RefUnwindSafe for Drive

§

impl Send for Drive

§

impl !Sync for Drive

§

impl Unpin for Drive

§

impl UnsafeUnpin for Drive

§

impl !UnwindSafe for Drive

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more