pub struct MicroCartridge { /* private fields */ }Expand description
This struct represents an emulated Microdrive tape cartridge.
It consist of up to MAX_SECTORS Sectors. Instances of this struct can be “inserted” into one of 8 ZxMicrodrives’s emulator drives.
Implementations§
Source§impl MicroCartridge
 
impl MicroCartridge
Sourcepub fn head_at(&self) -> f32
 
pub fn head_at(&self) -> f32
Returns the current drive’s head position counted in sectors as floating point value.
The fractional part indicates how far the head position is within a sector.
Sourcepub fn max_sectors(&self) -> usize
 
pub fn max_sectors(&self) -> usize
Returns the number of the emulated physical sectors on the tape.
Sourcepub fn count_formatted(&self) -> usize
 
pub fn count_formatted(&self) -> usize
Returns the number of formatted sectors.
Sourcepub fn iter_with_indices(
    &self,
) -> FilterMap<Enumerate<Zip<Iter<'_, Sector>, Iter<'_, u32, Lsb0>>>, &dyn Fn((usize, (&Sector, BitRef<'_, Const, u32>))) -> Option<(u8, &Sector)>> ⓘ
 
pub fn iter_with_indices( &self, ) -> FilterMap<Enumerate<Zip<Iter<'_, Sector>, Iter<'_, u32, Lsb0>>>, &dyn Fn((usize, (&Sector, BitRef<'_, Const, u32>))) -> Option<(u8, &Sector)>> ⓘ
Returns an iterator of formatted sectors with their original indices.
Sourcepub fn is_write_protected(&self) -> bool
 
pub fn is_write_protected(&self) -> bool
Returns true if the cartridge is write protected.
Sourcepub fn set_write_protected(&mut self, protect: bool)
 
pub fn set_write_protected(&mut self, protect: bool)
Changes the write protected flag of the cartridge.
Sourcepub fn is_sector_formatted(&self, sector: u8) -> bool
 
pub fn is_sector_formatted(&self, sector: u8) -> bool
Returns true if the given sector is formatted.
§Panics
Panics if sector equals to or is above the max_sectors limit.
Sourcepub fn new_with_sectors<S>(
    sectors: S,
    write_protect: bool,
    max_sectors: usize,
) -> MicroCartridge
 
pub fn new_with_sectors<S>( sectors: S, write_protect: bool, max_sectors: usize, ) -> MicroCartridge
Creates a new instance of MicroCartridge with provided sectors.
§Note
Content of the sectors is not verified and is assumed to be properly formatted.
§Panics
The number of sectors provided must not be greater than MAX_USABLE_SECTORS.
max_sectors must not be 0 and must be grater or equal to the number of provided sectors and
must not be greater than MAX_SECTORS.
Sourcepub fn new(max_sectors: usize) -> MicroCartridge
 
pub fn new(max_sectors: usize) -> MicroCartridge
Creates a new instance of MicroCartridge with custom max_sectors number.
§Panics
max_sectors must not be 0 and must not be greater than MAX_SECTORS.
Trait Implementations§
Source§impl Clone for MicroCartridge
 
impl Clone for MicroCartridge
Source§fn clone(&self) -> MicroCartridge
 
fn clone(&self) -> MicroCartridge
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MicroCartridge
 
impl Debug for MicroCartridge
Source§impl Default for MicroCartridge
 
impl Default for MicroCartridge
Source§fn default() -> MicroCartridge
 
fn default() -> MicroCartridge
Source§impl<'de> Deserialize<'de> for MicroCartridge
 
impl<'de> Deserialize<'de> for MicroCartridge
Source§fn deserialize<__D>(
    __deserializer: __D,
) -> Result<MicroCartridge, <__D as Deserializer<'de>>::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(
    __deserializer: __D,
) -> Result<MicroCartridge, <__D as Deserializer<'de>>::Error>where
    __D: Deserializer<'de>,
Source§impl Index<u8> for MicroCartridge
 
impl Index<u8> for MicroCartridge
Source§impl IndexMut<u8> for MicroCartridge
 
impl IndexMut<u8> for MicroCartridge
Source§impl<'a> IntoIterator for &'a MicroCartridge
Iterates through formatted sectors.
 
impl<'a> IntoIterator for &'a MicroCartridge
Iterates through formatted sectors.
Source§type IntoIter = FilterMap<Zip<Iter<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a dyn Fn((&'a Sector, BitRef<'a, Const, u32>)) -> Option<&'a Sector>>
 
type IntoIter = FilterMap<Zip<Iter<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a dyn Fn((&'a Sector, BitRef<'a, Const, u32>)) -> Option<&'a Sector>>
Source§fn into_iter(self) -> <&'a MicroCartridge as IntoIterator>::IntoIter
 
fn into_iter(self) -> <&'a MicroCartridge as IntoIterator>::IntoIter
Source§impl<'a> IntoIterator for &'a mut MicroCartridge
Iterates through formatted sectors.
 
impl<'a> IntoIterator for &'a mut MicroCartridge
Iterates through formatted sectors.
Source§type IntoIter = FilterMap<Zip<IterMut<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a dyn Fn((&'a mut Sector, BitRef<'a, Const, u32>)) -> Option<&'a mut Sector>>
 
type IntoIter = FilterMap<Zip<IterMut<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a dyn Fn((&'a mut Sector, BitRef<'a, Const, u32>)) -> Option<&'a mut Sector>>
Source§fn into_iter(self) -> <&'a mut MicroCartridge as IntoIterator>::IntoIter
 
fn into_iter(self) -> <&'a mut MicroCartridge as IntoIterator>::IntoIter
Source§impl MicroCartridgeExt for MicroCartridge
 
impl MicroCartridgeExt for MicroCartridge
Source§fn file_info<S: AsRef<[u8]>>(
    &self,
    file_name: S,
) -> Result<Option<CatFile>, MdrValidationError>
 
fn file_info<S: AsRef<[u8]>>( &self, file_name: S, ) -> Result<Option<CatFile>, MdrValidationError>
file_name exists.Source§fn file_type<S: AsRef<[u8]>>(
    &self,
    file_name: S,
) -> Result<Option<CatFileType>, MdrValidationError>
 
fn file_type<S: AsRef<[u8]>>( &self, file_name: S, ) -> Result<Option<CatFileType>, MdrValidationError>
file_name exists.Source§fn file_to_tap_writer<S: AsRef<[u8]>, W: Write + Seek>(
    &self,
    file_name: S,
    wr: &mut TapChunkWriter<W>,
) -> Result<bool>
 
fn file_to_tap_writer<S: AsRef<[u8]>, W: Write + Seek>( &self, file_name: S, wr: &mut TapChunkWriter<W>, ) -> Result<bool>
Source§fn file_from_tap_reader<R: Read + Seek>(
    &mut self,
    rd: &mut TapChunkReader<R>,
) -> Result<u8>
 
fn file_from_tap_reader<R: Read + Seek>( &mut self, rd: &mut TapChunkReader<R>, ) -> Result<u8>
Source§fn retrieve_file<S: AsRef<[u8]>, W: Write>(
    &self,
    file_name: S,
    wr: W,
) -> Result<Option<(CatFileType, usize)>>
 
fn retrieve_file<S: AsRef<[u8]>, W: Write>( &self, file_name: S, wr: W, ) -> Result<Option<(CatFileType, usize)>>
wr if the file with file_name exists.
Returns the type and the size of the file on success. Read moreSource§fn store_file<S: AsRef<[u8]>, R: Read>(
    &mut self,
    file_name: S,
    is_save: bool,
    rd: R,
) -> Result<u8>
 
fn store_file<S: AsRef<[u8]>, R: Read>( &mut self, file_name: S, is_save: bool, rd: R, ) -> Result<u8>
rd as a new file on a MicroCartridge.
Returns the number of newly occupied sectors on success. Read moreSource§fn erase_file<S: AsRef<[u8]>>(&mut self, file_name: S) -> u8
 
fn erase_file<S: AsRef<[u8]>>(&mut self, file_name: S) -> u8
file_name as free.
Returns the number of erased sectors.Source§fn file_sector_ids_unordered<S: AsRef<[u8]>>(
    &self,
    file_name: S,
) -> FileSectorIdsUnordIter<'_> ⓘ
 
fn file_sector_ids_unordered<S: AsRef<[u8]>>( &self, file_name: S, ) -> FileSectorIdsUnordIter<'_> ⓘ
file_name. Read moreSource§fn file_sectors<S: AsRef<[u8]>>(&self, file_name: S) -> FileSectorIter<'_> ⓘ
 
fn file_sectors<S: AsRef<[u8]>>(&self, file_name: S) -> FileSectorIter<'_> ⓘ
file_name. Read moreSource§fn catalog(&self) -> Result<Option<Catalog>, MdrValidationError>
 
fn catalog(&self) -> Result<Option<Catalog>, MdrValidationError>
Source§fn catalog_name(&self) -> Result<Option<Cow<'_, str>>, MdrValidationError>
 
fn catalog_name(&self) -> Result<Option<Cow<'_, str>>, MdrValidationError>
Source§fn validate_sectors(&self) -> Result<usize, MdrValidationError>
 
fn validate_sectors(&self) -> Result<usize, MdrValidationError>
Source§fn count_sectors_in_use(&self) -> usize
 
fn count_sectors_in_use(&self) -> usize
Source§fn write_mdr<W: Write>(&self, wr: W) -> Result<usize>
 
fn write_mdr<W: Write>(&self, wr: W) -> Result<usize>
.mdr file using a provided writer. Read moreSource§fn new_formatted<S: AsRef<[u8]>>(max_sectors: usize, catalog_name: S) -> Self
 
fn new_formatted<S: AsRef<[u8]>>(max_sectors: usize, catalog_name: S) -> Self
Source§impl Serialize for MicroCartridge
 
impl Serialize for MicroCartridge
Source§fn serialize<__S>(
    &self,
    __serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
    __S: Serializer,
 
fn serialize<__S>(
    &self,
    __serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
    __S: Serializer,
Auto Trait Implementations§
impl Freeze for MicroCartridge
impl RefUnwindSafe for MicroCartridge
impl Send for MicroCartridge
impl Sync for MicroCartridge
impl Unpin for MicroCartridge
impl UnwindSafe for MicroCartridge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> FmtForward for T
 
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
    Self: Binary,
 
fn fmt_binary(self) -> FmtBinary<Self>where
    Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
    Self: Display,
 
fn fmt_display(self) -> FmtDisplay<Self>where
    Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
    Self: LowerExp,
 
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
    Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
    Self: LowerHex,
 
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
    Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
    Self: Octal,
 
fn fmt_octal(self) -> FmtOctal<Self>where
    Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
    Self: Pointer,
 
fn fmt_pointer(self) -> FmtPointer<Self>where
    Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
    Self: UpperExp,
 
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
    Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
    Self: UpperHex,
 
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
    Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<S, T> IntoSample<S> for Twhere
    S: FromSample<T>,
 
impl<S, T> IntoSample<S> for Twhere
    S: FromSample<T>,
Source§fn into_sample(self) -> S
 
fn into_sample(self) -> S
S a sample type from self.Source§impl<T> Pipe for Twhere
    T: ?Sized,
 
impl<T> Pipe for Twhere
    T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
    Self: Sized,
 
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
    Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
    R: 'a,
 
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
    R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
    R: 'a,
 
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
    R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
 
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
    &'a mut self,
    func: impl FnOnce(&'a mut B) -> R,
) -> R
 
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
 
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
 
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
 
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
 
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
 
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
 
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
 
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
 
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
 
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
 
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
 
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
 
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
 
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
 
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
 
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
 
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
 
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.