Trait cbm::disk::Disk [−][src]
pub trait Disk { fn native_disk_format(&self) -> &'static DiskFormat; fn disk_format(&self) -> Result<&DiskFormat>; fn disk_format_mut(&mut self) -> Result<&mut DiskFormat>; fn set_disk_format(&mut self, disk_format: Option<DiskFormat>); fn blocks(&self) -> Rc<RefCell<BlockDevice>>; fn blocks_ref(&self) -> Ref<BlockDevice>; fn blocks_ref_mut(&self) -> RefMut<BlockDevice>; fn header(&self) -> Result<&Header>; fn header_mut(&mut self) -> Result<&mut Header>; fn set_header(&mut self, header: Option<Header>); fn flush_header(&mut self) -> Result<()>; fn bam(&self) -> Result<Rc<RefCell<BAM>>>; fn set_bam(&mut self, bam: Option<BAM>); fn initialize(&mut self) { ... } fn write_format(&mut self, name: &Petscii, id: &Id) -> Result<()> { ... } fn iter(&self) -> DirectoryIterator { ... } fn directory(&self) -> Result<Vec<DirectoryEntry>> { ... } fn find_directory_entry(&self, filename: &Petscii) -> Result<DirectoryEntry> { ... } fn next_free_directory_entry(&mut self) -> Result<DirectoryEntry> { ... } fn write_directory_entry(&mut self, entry: &DirectoryEntry) -> Result<()> { ... } fn check_filename_availability(&self, filename: &Petscii) -> Result<()> { ... } fn rename(
&mut self,
original_filename: &Petscii,
new_filename: &Petscii
) -> Result<()> { ... } fn open_file(&self, filename: &Petscii) -> Result<File> { ... } fn open_file_from_entry(&self, entry: &DirectoryEntry) -> Result<File> { ... } fn create_file(
&mut self,
filename: &Petscii,
file_type: FileType,
scheme: Scheme
) -> Result<File> { ... } fn read_sector<'a>(&self, location: Location) -> Result<Vec<u8>> { ... } fn write_sector(&mut self, location: Location, data: &[u8]) -> Result<()> { ... } fn dump(&mut self, writer: &mut Write) -> Result<()> { ... } fn name<'a>(&'a self) -> Option<&'a Petscii> { ... } fn validate(&self) -> Result<Vec<ValidationError>> { ... } fn blocks_free(&self) -> Result<usize> { ... } }
All disk image types implement the Disk
trait, and most disk operations
can be performed polymorphically using Disk
as a trait object.
Required Methods
fn native_disk_format(&self) -> &'static DiskFormat
fn disk_format(&self) -> Result<&DiskFormat>
fn disk_format_mut(&mut self) -> Result<&mut DiskFormat>
fn set_disk_format(&mut self, disk_format: Option<DiskFormat>)
fn blocks(&self) -> Rc<RefCell<BlockDevice>>
fn blocks_ref(&self) -> Ref<BlockDevice>
fn blocks_ref_mut(&self) -> RefMut<BlockDevice>
fn header(&self) -> Result<&Header>
fn header_mut(&mut self) -> Result<&mut Header>
fn set_header(&mut self, header: Option<Header>)
fn flush_header(&mut self) -> Result<()>
fn bam(&self) -> Result<Rc<RefCell<BAM>>>
fn set_bam(&mut self, bam: Option<BAM>)
Provided Methods
fn initialize(&mut self)
Initialize the disk by reading the format metadata, if any. This may be called again, for example, when the BAM or header have been re-written.
fn write_format(&mut self, name: &Petscii, id: &Id) -> Result<()>
Format the disk image. Currently, this does not accurately reflect the exact formatting method used by the 1541/1571/1581 CBM DOS.
fn iter(&self) -> DirectoryIterator
Return an iterator of directory entries found on this disk image.
fn directory(&self) -> Result<Vec<DirectoryEntry>>
Return a list of all directory entries
fn find_directory_entry(&self, filename: &Petscii) -> Result<DirectoryEntry>
Locate a directory entry based on its filename.
fn next_free_directory_entry(&mut self) -> Result<DirectoryEntry>
Return a DirectoryEntry
representing the next free slot on the
directory track. This entry may be used to create a new directory
entry by populating its fields and passing it to
write_directory_entry()
.
fn write_directory_entry(&mut self, entry: &DirectoryEntry) -> Result<()>
Write the the provide directory entry to disk, using the same slot as it was originally read from.
fn check_filename_availability(&self, filename: &Petscii) -> Result<()>
Confirm that no directory entry currently exists with the provided filename.
fn rename(
&mut self,
original_filename: &Petscii,
new_filename: &Petscii
) -> Result<()>
&mut self,
original_filename: &Petscii,
new_filename: &Petscii
) -> Result<()>
Rename a file.
fn open_file(&self, filename: &Petscii) -> Result<File>
Open a file based on its filename.
fn open_file_from_entry(&self, entry: &DirectoryEntry) -> Result<File>
Open a file based on its directory entry.
fn create_file(
&mut self,
filename: &Petscii,
file_type: FileType,
scheme: Scheme
) -> Result<File>
&mut self,
filename: &Petscii,
file_type: FileType,
scheme: Scheme
) -> Result<File>
Create a new file on the disk. It will be initialized as a closed zero-length file, and a file handle will be returned which may be used to provision a writer.
fn read_sector<'a>(&self, location: Location) -> Result<Vec<u8>>
Read a specific block from the disk, given its track and sector location.
fn write_sector(&mut self, location: Location, data: &[u8]) -> Result<()>
Write a block of data to a specific location on the disk.
fn dump(&mut self, writer: &mut Write) -> Result<()>
Write a hex dump of the disk image to the provided writer.
fn name<'a>(&'a self) -> Option<&'a Petscii>
Return the name of this disk as found in the disk header.
fn validate(&self) -> Result<Vec<ValidationError>>
Check the consistency of the disk image. Unlike the "validate" ("v0:") command in CBM DOS, this is a read-only operation and does not attempt any repairs. A list of validation errors is returned.
fn blocks_free(&self) -> Result<usize>
Return the blocks free based on the BAM free sector counts. (Not based on the BAM bitmaps, nor on the file sizes in the directory entries.)
Trait Implementations
impl Display for Disk
[src]
impl Display for Disk
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Debug for Disk
[src]
impl Debug for Disk
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a> IntoIterator for &'a Disk
[src]
impl<'a> IntoIterator for &'a Disk
type Item = Result<DirectoryEntry>
The type of the elements being iterated over.
type IntoIter = DirectoryIterator
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more