[][src]Struct spectrusty_utils::tap::Tape

pub struct Tape<F> {
    pub running: bool,
    pub tap: Option<Tap<F>>,
}

The struct that emulates a simple tape recorder.

Fields

running: bool

true if the tape is playing, depending on the Tap variant it may indicate tape playback or recording. false then the tape has stopped.

tap: Option<Tap<F>>

Some(tap) indicates the tape cassette is inserted, None - there is no tape.

Implementations

impl<F: Write + Read + Seek> Tape<F>[src]

pub fn new_with_tape(file: F) -> Self[src]

Returns a new instance of Tape with the tape file inserted.

pub fn insert_as_reader(&mut self, file: F) -> Option<Tap<F>>[src]

Inserts the tape file as a Tap::Reader. Returns the previously inserted Tap instance.

pub fn try_insert_as_writer(&mut self, file: F) -> Result<Option<Tap<F>>>[src]

Tries to insert the tape file as a Tap::Writer. Returns the previously inserted Tap instance.

pub fn eject(&mut self) -> Option<Tap<F>>[src]

Ejects and returns the previously inserted Tap instance.

pub fn make_reader(&mut self) -> Result<bool>[src]

Transforms the inserted Tap into the Tap::Reader on success.

Returns Ok(true) if the inserted Tap was a Tap::Writer. In this instance, the cursor position of the reader is set to the beginning of a file and this method ensures that the chunk being currently written is comitted thus ensuring the integrity of the TAP file and also calls the Write::flush on the file before transforming it.

If the inserted Tap is already a Tap::Reader or if there is no Tap inserted returns Ok(false).

pub fn make_writer(&mut self) -> Result<bool>[src]

Transforms the inserted Tap into the Tap::Writer on success.

Returns Ok(true) if the inserted Tap was a Tap::Reader. In this instance the cursor position of the reader is set to the end of a file.

If the inserted Tap is already a Tap::Writer or if there is no Tap inserted returns Ok(false).

pub fn is_ejected(&self) -> bool[src]

Returns true if there is no Tap inserted, otherwise returns false.

pub fn is_inserted(&self) -> bool[src]

Returns true if there is a Tap inserted, otherwise returns false.

pub fn is_running(&self) -> bool[src]

Returns true if there is some Tap inserted and Tape::running is true, otherwise returns false.

pub fn is_idle(&self) -> bool[src]

Returns true if no Tap is inserted or Tape::running is false, otherwise returns true.

pub fn tap_state(&self) -> TapState[src]

Returns the current status of the inserted tape as an enum.

pub fn is_playing(&self) -> bool[src]

Returns true if there is a Tap::Reader variant inserted and Tape::running is true, otherwise returns false.

pub fn is_recording(&self) -> bool[src]

Returns true if there is a Tap::Writer variant inserted and Tape::running is true, otherwise returns false.

pub fn reader_mut(&mut self) -> Option<&mut TapChunkPulseIter<F>>[src]

Returns a mutable reference to the pulse iterator if the current variant of Tape::tap is Tap::Reader.

pub fn writer_mut(&mut self) -> Option<&mut TapChunkWriter<F>>[src]

Returns a mutable reference to the tap chunk writer if the current variant of Tape::tap is Tap::Writer.

pub fn reader_ref(&self) -> Option<&TapChunkPulseIter<F>>[src]

Returns a reference to the pulse iterator if the current variant of Tape::tap is Tap::Reader.

pub fn writer_ref(&self) -> Option<&TapChunkWriter<F>>[src]

Returns a reference to the tap chunk writer if the current variant of Tape::tap is Tap::Writer.

pub fn playing_reader_mut(&mut self) -> Option<&mut TapChunkPulseIter<F>>[src]

Returns a mutable reference to the pulse iterator if there is a Tap::Reader variant inserted and Tape::running is true, otherwise returns None.

pub fn recording_writer_mut(&mut self) -> Option<&mut TapChunkWriter<F>>[src]

Returns a mutable reference to the tap chunk writer if there is a Tap::Writer variant inserted and Tape::running is true, otherwise returns None.

pub fn try_reader_mut(&mut self) -> Result<Option<TapChunkReaderMut<'_, F>>>[src]

Returns a clone of [TapChunkReader] with a mutable reference to the file under the guard that ensures the position of the underlying file is set back to where it was before this method was called when the guard goes out of scope.

pub fn play(&mut self) -> Result<bool>[src]

Sets Tape::running to true and ensures the inserted variant is a Tap::Reader.

Returns Ok(true) if the state of self changes.

pub fn record(&mut self) -> Result<bool>[src]

Sets Tape::running to true and ensures the inserted variant is a Tap::Writer.

Returns Ok(true) if the state of self changes.

pub fn stop(&mut self)[src]

Sets Tape::running to false.

pub fn rewind(&mut self) -> bool[src]

Conditionally rewinds a tape if it's inserted and its variant is Tap::Reader. In this instance returns true. Otherwise returns false.

pub fn forward_chunk(&mut self) -> Result<Option<bool>>[src]

Conditionally forwards a tape to the next chunk if it's inserted and its variant is Tap::Reader. In this instance returns Ok(Some(was_next_chunk)). Otherwise returns Ok(None).

pub fn rewind_prev_chunk(&mut self) -> Result<Option<u32>>[src]

Conditionally rewinds a tape to the previous chunk if it's inserted and its variant is Tap::Reader. In this instance returns Ok(Some(chunk_no)). Otherwise returns Ok(None).

pub fn rewind_chunk(&mut self) -> Result<Option<u32>>[src]

Conditionally rewinds a tape to the beginning of the current chunk if it's inserted and its variant is Tap::Reader. In this instance returns Ok(Some(chunk_no)). Otherwise returns Ok(None).

pub fn rewind_nth_chunk(&mut self, chunk_no: u32) -> Result<Option<bool>>[src]

Conditionally rewinds or forwards a tape to the nth chunk if it's inserted and its variant is Tap::Reader. In this instance returns Ok(Some(was_a_chunk)). Otherwise returns Ok(None).

Trait Implementations

impl<F: Debug> Debug for Tape<F>[src]

impl<F> Default for Tape<F>[src]

Auto Trait Implementations

impl<F> !RefUnwindSafe for Tape<F>

impl<F> Send for Tape<F> where
    F: Send

impl<F> Sync for Tape<F> where
    F: Sync

impl<F> Unpin for Tape<F> where
    F: Unpin

impl<F> !UnwindSafe for Tape<F>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<S, T> IntoSample<S> for T where
    S: FromSample<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,