DiskImage

Struct DiskImage 

Source
pub struct DiskImage { /* private fields */ }
Expand description

A DiskImage represents the structure of a floppy disk. It contains a pool of track data structures, which are indexed by a head vector which contains cylinder vectors.

A DiskImage can be created from a specified disk format using an ImageBuilder.

A DiskImage may be of two DiskDataResolution levels: ByteStream or BitStream. ByteStream images are sourced from sector-based disk image formats, while BitStream images are sourced from bitstream-based disk image formats.

Implementations§

Source§

impl DiskImage

Source

pub fn detect_format<RS: ReadSeek>( image: &mut RS, ) -> Result<DiskImageContainer, DiskImageError>

Source

pub fn create(disk_format: StandardFormat) -> Self

Create a new DiskImage with the specified disk format. This function should not be called directly - use an [ImageBuilder] if you wish to create a new DiskImage from a specified format.

Source

pub fn track_iter(&self) -> impl Iterator<Item = &Box<dyn Track + Send + Sync>>

Source

pub fn track_idx_iter(&self) -> impl Iterator<Item = usize> + '_

Source

pub fn track_ch_iter(&self) -> impl Iterator<Item = DiskCh> + '_

Source

pub fn track(&self, ch: DiskCh) -> Option<&Box<dyn Track + Send + Sync>>

Source

pub fn track_mut( &mut self, ch: DiskCh, ) -> Option<&mut Box<dyn Track + Send + Sync>>

Source

pub fn track_by_idx( &self, track_idx: usize, ) -> Option<&Box<dyn Track + Send + Sync>>

Source

pub fn track_by_idx_mut( &mut self, track_idx: usize, ) -> Option<&mut Box<dyn Track + Send + Sync>>

Source

pub fn set_resolution(&mut self, resolution: DiskDataResolution)

Source

pub fn set_flag(&mut self, flag: DiskImageFlags)

Source

pub fn clear_flag(&mut self, flag: DiskImageFlags)

Source

pub fn has_flag(&self, flag: DiskImageFlags) -> bool

Source

pub fn required_caps(&self) -> FormatCaps

Source

pub fn load_from_file( file_path: PathBuf, disk_selection: Option<DiskSelection>, callback: Option<Box<dyn Fn(LoadingStatus) + Send + 'static>>, ) -> Result<Self, DiskImageError>

Source

pub fn load<RS: ReadSeek>( image_io: &mut RS, image_path: Option<PathBuf>, disk_selection: Option<DiskSelection>, callback: Option<Box<dyn Fn(LoadingStatus) + Send + 'static>>, ) -> Result<Self, DiskImageError>

Source

pub fn set_volume_name(&mut self, name: String)

Source

pub fn volume_name(&self) -> Option<&str>

Source

pub fn get_comment(&self) -> Option<&str>

Source

pub fn set_comment(&mut self, comment: String)

Source

pub fn set_data_rate(&mut self, rate: DiskDataRate)

Source

pub fn data_rate(&self) -> DiskDataRate

Source

pub fn set_data_encoding(&mut self, encoding: DiskDataEncoding)

Source

pub fn data_encoding(&self) -> DiskDataEncoding

Source

pub fn set_image_format(&mut self, format: DiskDescriptor)

Source

pub fn image_format(&self) -> DiskDescriptor

Source

pub fn geometry(&self) -> DiskCh

Source

pub fn heads(&self) -> u8

Source

pub fn tracks(&self, head: u8) -> u16

Source

pub fn write_ct(&self) -> u64

Source

pub fn source_format(&self) -> Option<DiskImageFileFormat>

Source

pub fn set_source_format(&mut self, format: DiskImageFileFormat)

Source

pub fn resolution(&self) -> DiskDataResolution

Return the resolution of the disk image, either ByteStream or BitStream.

Source

pub fn add_track_fluxstream( &mut self, ch: DiskCh, track: FluxStreamTrack, clock_hint: Option<f64>, rpm_hint: Option<DiskRpm>, ) -> Result<&Box<dyn Track + Send + Sync>, DiskImageError>

Adds a new track to the disk image, of FluxStream resolution. Data of this resolution is sourced from FluxStream images such as Kryoflux, SCP or MFI.

This function locks the disk image to FluxStream resolution and adds a new track with the specified data encoding, data rate, geometry, and data clock.

§Parameters
  • track: A FluxStreamTrack the track to add. Unlike adding a bitstream or metasector track, we must construct a FluxStreamTrack first before adding it.
§Returns
  • Ok(()) if the track was successfully added.
  • Err(DiskImageError::SeekError) if the head value in ch is greater than or equal to 2.
  • Err(DiskImageError::ParameterError) if the length of data and weak do not match.
  • Err(DiskImageError::IncompatibleImage) if the disk image is not compatible with BitStream resolution.
Source

pub fn add_track_bitstream( &mut self, params: BitStreamTrackParams<'_>, ) -> Result<(), DiskImageError>

Adds a new track to the disk image, of BitStream resolution. Data of this resolution is sourced from BitStream images such as MFM, HFE or 86F.

This function locks the disk image to BitStream resolution and adds a new track with the specified data encoding, data rate, geometry, and data clock.

§Parameters
  • params: A BitstreamTrackParams struct describing the track to be added.
§Returns
  • Ok(()) if the track was successfully added.
  • Err(DiskImageError::SeekError) if the head value in ch is greater than or equal to 2.
  • Err(DiskImageError::ParameterError) if the length of data and weak do not match.
  • Err(DiskImageError::IncompatibleImage) if the disk image is not compatible with BitStream resolution.
Source

pub fn add_track_metasector( &mut self, encoding: DiskDataEncoding, data_rate: DiskDataRate, ch: DiskCh, ) -> Result<&mut Box<dyn Track + Send + Sync>, DiskImageError>

Adds a new track to the disk image, of ByteStream resolution. Data of this resolution is typically sourced from sector-based image formats.

This function locks the disk image to ByteStream resolution and adds a new track with the specified data encoding, data rate, and geometry.

§Parameters
  • data_encoding: The encoding used for the track data.
  • data_rate: The data rate of the track.
  • ch: The geometry of the track (cylinder and head).
§Returns
  • Ok(()) if the track was successfully added.
  • Err(DiskImageError::SeekError) if the head value in ch is greater than or equal to 2.
  • Err(DiskImageError::IncompatibleImage) if the disk image is not compatible with ByteStream resolution.
Source

pub fn next_sector_on_track(&self, chs: DiskChs) -> Option<DiskChs>

Source

pub fn read_sector( &mut self, phys_ch: DiskCh, id_chs: DiskChs, n: Option<u8>, scope: RwSectorScope, debug: bool, ) -> Result<ReadSectorResult, DiskImageError>

Read the sector data from the sector at the physical location ‘phys_ch’ with the sector ID values specified by ‘id_chs’. The data is returned within a ReadSectorResult struct which also sets some convenience metadata flags which are needed when handling ByteStream images. When reading a BitStream image, the sector data includes the address mark and crc. Offsets are provided within ReadSectorResult so these can be skipped when processing the read operation.

Source

pub fn write_sector( &mut self, phys_ch: DiskCh, id_chs: DiskChs, n: Option<u8>, data: &[u8], scope: RwSectorScope, deleted: bool, debug: bool, ) -> Result<WriteSectorResult, DiskImageError>

Source

pub fn read_all_sectors( &mut self, phys_ch: DiskCh, id_ch: DiskCh, n: u8, eot: u8, ) -> Result<ReadTrackResult, DiskImageError>

Read all sectors from the track identified by ‘ch’. The data is returned within a ReadSectorResult struct which also sets some convenience metadata flags which are needed when handling ByteStream images. Unlike read_sector(), the data returned is only the actual sector data. The address marks and CRCs are not included in the data. This function is intended for use in implementing the Read Track FDC command.

Source

pub fn read_track( &mut self, ch: DiskCh, overdump: Option<usize>, ) -> Result<ReadTrackResult, DiskImageError>

Read the track specified by ch, decoding data. The data is returned within a ReadTrackResult struct, which crucially contains the exact length of the track data in bits.

§Parameters
  • ch: The cylinder and head of the track to read.
  • overdump: An optional parameter to specify the number of bytes to read past the end of the track. This is useful for examining track wrapping behavior.
Source

pub fn read_track_raw( &mut self, ch: DiskCh, overdump: Option<usize>, ) -> Result<ReadTrackResult, DiskImageError>

Read the track specified by ch, without decoding. The data is returned within a ReadTrackResult struct, which crucially contains the exact length of the track data in bits.

§Parameters
  • ch: The cylinder and head of the track to read.
  • overdump: An optional parameter to specify the number of bytes to read past the end of the track. This is useful for examining track wrapping behavior.
Source

pub fn add_empty_track( &mut self, ch: DiskCh, encoding: DiskDataEncoding, data_rate: DiskDataRate, bitcells: usize, ) -> Result<usize, DiskImageError>

Source

pub fn format_track( &mut self, ch: DiskCh, format_buffer: Vec<DiskChsn>, fill_pattern: &[u8], sector_gap: usize, ) -> Result<(), DiskImageError>

Source

pub fn reset_image(&mut self)

Reset an image to an empty state.

Source

pub fn format( &mut self, format: StandardFormat, boot_sector: Option<&[u8]>, creator: Option<&[u8; 8]>, ) -> Result<(), DiskImageError>

Source

pub fn get_next_id(&self, chs: DiskChs) -> Option<DiskChsn>

Source

pub fn update_standard_boot_sector( &mut self, format: StandardFormat, ) -> Result<(), DiskImageError>

Source

pub fn boot_sector(&self) -> Option<&BootSector>

Retrieve the DOS boot sector of the disk image, if present.

Source

pub fn get_track_ct(&self, head: usize) -> usize

Source

pub fn remove_empty_tracks(&mut self)

Remove tracks with no sectors from the image. This should be called with caution as sometimes disk images contain empty tracks between valid tracks.

Source

pub fn dump_info<W: Write>(&mut self, out: W) -> Result<(), Error>

Source

pub fn dump_consistency<W: Write>(&mut self, out: W) -> Result<(), Error>

Source

pub fn get_sector_map(&self) -> Vec<Vec<Vec<SectorMapEntry>>>

Source

pub fn find_duplication_mark(&self) -> Option<(DiskCh, DiskChsn)>

Source

pub fn dump_sector_map<W: Write>(&self, out: W) -> Result<(), Error>

Source

pub fn dump_sector_hex<W: Write>( &mut self, phys_ch: DiskCh, id_chs: DiskChs, n: Option<u8>, scope: RwSectorScope, bytes_per_row: usize, out: W, ) -> Result<(), DiskImageError>

Source

pub fn dump_sector_string( &mut self, phys_ch: DiskCh, id_chs: DiskChs, n: Option<u8>, ) -> Result<String, DiskImageError>

Source

pub fn has_weak_bits(&self) -> bool

Source

pub fn compatible_formats( &self, writable: bool, ) -> Vec<(DiskImageFileFormat, Vec<String>)>

Return a list of tuples representing the disk image formats that are compatible with the current image. This does not mean that fluxfox supports writing to these formats, only that the image is compatible with them.

The tuple contains the DiskImageFormat and a list of strings representing the format’s typical file extensions.

Arguments:

  • writable: If true, only return formats that are writable.
Source

pub fn incr_writes(&mut self)

Source§

impl DiskImage

Source

pub fn detect_copy_protection(&self) -> Option<CopyProtectionScheme>

Attempt to determine the copy protection scheme used on the disk image. Returns None if no copy protection is detected.

Trait Implementations§

Source§

impl Default for DiskImage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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, 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