Trait spectrusty_formats::mdr::SectorExt
source · pub trait SectorExt {
Show 24 methods
fn is_free(&self) -> bool;
fn catalog_name(&self) -> &[u8; 10];
fn file_name(&self) -> &[u8; 10];
fn file_name_matches(&self, name: &[u8]) -> bool;
fn file_type(&self) -> Result<Option<CatFileType>, &'static str>;
fn sector_seq(&self) -> u8;
fn file_block_seq(&self) -> u8;
fn file_block_len(&self) -> u16;
fn is_last_file_block(&self) -> bool;
fn is_save_file(&self) -> bool;
fn data(&self) -> &[u8] ⓘ;
fn data_mut(&mut self) -> &mut [u8] ⓘ;
fn data_record(&self) -> &[u8] ⓘ;
fn set_file_name(&mut self, file_name: &[u8]);
fn set_file_block_seq(&mut self, block_seq: u8);
fn set_file_block_len(&mut self, len: u16);
fn set_last_file_block(&mut self, eof: bool);
fn set_save_file_flag(&mut self, is_save: bool);
fn update_block_checksums(&mut self);
fn erase(&mut self);
fn format(&mut self, seq: u8, catalog_name: &[u8]);
fn validate(&self) -> Result<(), &'static str>;
fn file_header(&self) -> Result<Option<&MdrFileHeader>, &'static str>;
fn tap_header(&self) -> Result<Option<Header>, &'static str>;
}
Expand description
Extends MicroCartridge’s Sector with methods for reading and manipulating Microdrive’s file system.
Required Methods§
sourcefn catalog_name(&self) -> &[u8; 10]
fn catalog_name(&self) -> &[u8; 10]
Returns the name in sector’s header.
sourcefn file_name_matches(&self, name: &[u8]) -> bool
fn file_name_matches(&self, name: &[u8]) -> bool
Returns true
if the given name
matches name in the blocks’s header.
sourcefn file_type(&self) -> Result<Option<CatFileType>, &'static str>
fn file_type(&self) -> Result<Option<CatFileType>, &'static str>
Returns a file type of this sector if the sector is occupied.
sourcefn sector_seq(&self) -> u8
fn sector_seq(&self) -> u8
Returns HDNUMB
entry of the sector’s header.
sourcefn file_block_seq(&self) -> u8
fn file_block_seq(&self) -> u8
Returns RECNUM
entry of the blocks’s header.
sourcefn file_block_len(&self) -> u16
fn file_block_len(&self) -> u16
Returns RECLEN
entry of the blocks’s header.
sourcefn is_last_file_block(&self) -> bool
fn is_last_file_block(&self) -> bool
Returns an EOF
flag’s state of RECFLG
entry of the blocks’s header.
sourcefn is_save_file(&self) -> bool
fn is_save_file(&self) -> bool
Returns a SAVE
flag’s state of RECFLG
entry of the blocks’s header.
sourcefn data_record(&self) -> &[u8] ⓘ
fn data_record(&self) -> &[u8] ⓘ
Returns a reference to the data segment limited in size by the RECLEN
entry.
sourcefn set_file_name(&mut self, file_name: &[u8])
fn set_file_name(&mut self, file_name: &[u8])
Changes the name in blocks’s header.
sourcefn set_file_block_seq(&mut self, block_seq: u8)
fn set_file_block_seq(&mut self, block_seq: u8)
Changes RECNUM
entry of the blocks’s header.
sourcefn set_file_block_len(&mut self, len: u16)
fn set_file_block_len(&mut self, len: u16)
Changes RECLEN
entry of the blocks’s header.
sourcefn set_last_file_block(&mut self, eof: bool)
fn set_last_file_block(&mut self, eof: bool)
Changes an EOF
flag of RECFLG
entry of the blocks’s header.
sourcefn set_save_file_flag(&mut self, is_save: bool)
fn set_save_file_flag(&mut self, is_save: bool)
Changes a SAVE
flag of RECFLG
entry of the blocks’s header.
sourcefn update_block_checksums(&mut self)
fn update_block_checksums(&mut self)
Updates checksums of a block segment.
sourcefn format(&mut self, seq: u8, catalog_name: &[u8])
fn format(&mut self, seq: u8, catalog_name: &[u8])
Formats this sector with the given sector number (1 - 254) and catalog_name
.
Panics
If seq
is not in [1, 254] range.
sourcefn file_header(&self) -> Result<Option<&MdrFileHeader>, &'static str>
fn file_header(&self) -> Result<Option<&MdrFileHeader>, &'static str>
Returns a reference to the file header if this sector is the first sector of a SAVE *
file.