pub trait MicroCartridgeExt: Sized {
Show 16 methods fn file_info<S: AsRef<[u8]>>(
        &self,
        file_name: S
    ) -> Result<Option<CatFile>, MdrValidationError>; fn file_type<S: AsRef<[u8]>>(
        &self,
        file_name: S
    ) -> Result<Option<CatFileType>, MdrValidationError>; fn retrieve_file<S: AsRef<[u8]>, W: Write>(
        &self,
        file_name: S,
        wr: W
    ) -> Result<Option<(CatFileType, usize)>>; fn store_file<S: AsRef<[u8]>, R: Read>(
        &mut self,
        file_name: S,
        is_save: bool,
        rd: R
    ) -> Result<u8>; fn erase_file<S: AsRef<[u8]>>(&mut self, file_name: S) -> u8; fn file_to_tap_writer<S: AsRef<[u8]>, W: Write + Seek>(
        &self,
        file_name: S,
        wr: &mut TapChunkWriter<W>
    ) -> Result<bool>; fn file_from_tap_reader<R: Read + Seek>(
        &mut self,
        rd: &mut TapChunkReader<R>
    ) -> Result<u8>; fn file_sector_ids_unordered<S: AsRef<[u8]>>(
        &self,
        file_name: S
    ) -> FileSectorIdsUnordIter<'_> ; fn file_sectors<S: AsRef<[u8]>>(&self, file_name: S) -> FileSectorIter<'_> ; fn catalog(&self) -> Result<Option<Catalog>, MdrValidationError>; fn catalog_name(&self) -> Result<Option<Cow<'_, str>>, MdrValidationError>; fn validate_sectors(&self) -> Result<usize, MdrValidationError>; fn count_sectors_in_use(&self) -> usize; fn from_mdr<R: Read>(rd: R, max_sectors: usize) -> Result<Self>; fn write_mdr<W: Write>(&self, wr: W) -> Result<usize>; fn new_formatted<S: AsRef<[u8]>>(max_sectors: usize, catalog_name: S) -> Self;
}
Expand description

Extends MicroCartridge with methods for reading and manipulating Microdrive’s file system.

Required Methods§

Returns file meta data if the file with file_name exists.

Returns a file type if the file with file_name exists.

Retrieves content of a file from a MicroCartridge and writes it to wr if the file with file_name exists. Returns the type and the size of the file on success.

If the file is a SAVE * type file the first 9 bytes of data constitute its file block header.

Stores content read from rd as a new file on a MicroCartridge. Returns the number of newly occupied sectors on success.

The is_save argument determines if the file is a binary file (SAVE *) or a data file (OPEN #). In case is_save is true the first 9 bytes of the data read from rd must represent a file block header.

Returns an error if a file with the same name already exists or if there is not enough free sectors to store the complete file.

In case of an error of io::ErrorKind::WriteZero kind, you may delete the partial file data with MicroCartridgeExt::erase_file.

Marks all sectors (including copies and unclosed files) belonging to a provided file_name as free. Returns the number of erased sectors.

Retrieves content of a binary file and writes it to a TAP chunk writer with a proper TAP header.

Returns Ok(true) if a file_name exists and the file was successfully written. Returns Ok(false) if a file_name is missing or a file is not a binary (SAVE *) file.

Stores content read from a TAP chunk reader as a new file on a MicroCartridge. Returns the number of newly occupied sectors on success.

The first TAP chunk must represent a proper TAP header and the folowing chunk must be a data block.

Returns an error if a file with the same name already exists or if there is not enough free sectors to store the complete file.

In case of an error of io::ErrorKind::WriteZero kind, you may delete the partial file data with MicroCartridgeExt::erase_file.

Returns an iterator of sector indices with unordered blocks of the provided file_name.

The same block numbers may be returned multiple times if there were multiple copies of the file.

Returns an iterator of sectors with ordered blocks belonging to the provided file_name.

Does not return duplicate blocks if there are more than one copy of the file.

Validates formatted sectors and returns a catalog of files.

Does not check the integrity of file blocks.

Returns Ok(None) if there are no formatted sectors.

Validates formatted sectors and returns a catalog name if all formatted sectors contain the same header indicating a properly formatted cartridge.

Does not check the integrity of file blocks.

Returns Ok(None) if there are no formatted sectors.

Checks if each formatted sector has flags property set and if all checksums are valid.

Returns the number of sectors being used by file data.

Reads the content of an .mdr file into the MicroCartridge sectors.

The content of sectors is not being validated. The file can contain from 1 to 254 sectors. If the file contains an additional byte, it is being read as a flag which is non-zero if the cartridge is write protected.

Provide the cartridge sector capacity as max_sectors. If the file contains more sectors than max_sectors the cartridge sector capacity will equal to the number of sectors read.

Use MicroCartridgeExt::validate_sectors to verify sector’s content.

Writes all formatted sectors to an .mdr file using a provided writer.

Returns the number of bytes written.

Writes an additional byte as a flag which is non-zero if the cartridge is write protected.

If there are no formatted sectors in the cartridge, doesn’t write anything.

Creates a new instance of MicroCartridge with formatted sectors.

Panics

max_sectors must not be 0 and must not be greater than MAX_SECTORS.

Implementors§