Struct spectrusty_formats::mdr::MicroCartridge
source · 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, Lsb0>))) -> Option<(u8, &Sector)>>
pub fn iter_with_indices(
&self
) -> FilterMap<Enumerate<Zip<Iter<'_, Sector>, Iter<'_, u32, Lsb0>>>, &dyn Fn((usize, (&Sector, BitRef<'_, Const, u32, Lsb0>))) -> 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
) -> MicroCartridgewhere
S: Into<Vec<Sector, Global>>,
pub fn new_with_sectors<S>(
sectors: S,
write_protect: bool,
max_sectors: usize
) -> MicroCartridgewhere
S: Into<Vec<Sector, Global>>,
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
impl<'a> IntoIterator for &'a MicroCartridge
Iterates through formatted sectors.
§type IntoIter = FilterMap<Zip<Iter<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a (dyn Fn((&'a Sector, BitRef<'a, Const, u32, Lsb0>)) -> Option<&'a Sector> + 'a)>
type IntoIter = FilterMap<Zip<Iter<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a (dyn Fn((&'a Sector, BitRef<'a, Const, u32, Lsb0>)) -> Option<&'a Sector> + 'a)>
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
impl<'a> IntoIterator for &'a mut MicroCartridge
Iterates through formatted sectors.
§type IntoIter = FilterMap<Zip<IterMut<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a (dyn Fn((&'a mut Sector, BitRef<'a, Const, u32, Lsb0>)) -> Option<&'a mut Sector> + 'a)>
type IntoIter = FilterMap<Zip<IterMut<'a, Sector>, Iter<'a, u32, Lsb0>>, &'a (dyn Fn((&'a mut Sector, BitRef<'a, Const, u32, Lsb0>)) -> Option<&'a mut Sector> + 'a)>
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. Read moresource§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 RefUnwindSafe for MicroCartridge
impl Send for MicroCartridge
impl Sync for MicroCartridge
impl Unpin for MicroCartridge
impl UnwindSafe for MicroCartridge
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
§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.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
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
.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read more§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.§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. Read more§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more