[][src]Struct spectrusty_formats::tap::pulse::ReadEncPulseIter

pub struct ReadEncPulseIter<R> { /* fields omitted */ }

Encodes data read from an underlying reader as TAPE T-state pulse intervals via an Iterator interface.

The timing of the pulses matches those expected by ZX Spectrum's ROM loading routines.

After invoking ReadEncPulseIter::reset or ReadEncPulseIter::new the first byte is read and checked to determine the duration of the LEAD PULSE signal. If it's less than 128 the number of generated lead pulses is LEAD_PULSES_HEAD. Otherwise, it's LEAD_PULSES_DATA.

After the lead pulses, two synchronization pulses are being emitted following by data pulses for each byte read including the initial flag byte.

This iterator may be used to feed pulses to the EAR IN buffer of the ZX Spectrum emulator (e.g. via EarIn::feed_ear_in) or to produce sound with a help of Bandwidth-Limited Pulse Buffer.

Best used with tap utilities.

Implementations

impl<R> ReadEncPulseIter<R>[src]

pub fn state(&self) -> &PulseIterState[src]

Returns a reference to the current state.

pub fn flag(&self) -> u8[src]

Returns a flag byte.

pub fn err(&self) -> Option<&Error>[src]

Returns an error from the underlying reader if there was one.

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

Returns true if there are no more pulses to emit or there was an error while bytes were read.

pub fn get_mut(&mut self) -> &mut R[src]

Returns a mutable reference to the inner reader.

pub fn get_ref(&self) -> &R[src]

Returns a shared reference to the inner reader.

pub fn into_inner(self) -> R[src]

Returns the underlying reader.

pub fn with_state_and_flag(
    mut self: Self,
    state: PulseIterState,
    flag: u8
) -> Self
[src]

Allows to manually assign a state and a flag. Can be used to deserialize ReadEncPulseIter.

impl<R: Read> ReadEncPulseIter<R>[src]

pub fn new(rd: R) -> Self[src]

Creates a new ReadEncPulseIter from a given Reader.

pub fn reset(&mut self)[src]

Resets the state of the iterator.

The next byte read from the inner reader is interpreted as a flag byte to determine the number of lead pulses. In this instance the state becomes PulseIterState::Lead.

If there are no more bytes to be read the state becomes PulseIterState::Done.

In case of an error while reading from the underlying reader the state becomes PulseIterState::Error.

pub fn data_from_next(&mut self)[src]

Attempts to set the state of the iterator as PulseIterState::Data from the next byte.

The next byte read from the inner reader is interpreted as a data byte. In this instance, the state becomes PulseIterState::Data.

If there are no more bytes to be read the state becomes PulseIterState::Done.

In case of an error while reading from the underlying reader the state becomes PulseIterState::Error.

Trait Implementations

impl<R: Debug> Debug for ReadEncPulseIter<R>[src]

impl<R: Read + Seek> From<ReadEncPulseIter<TapChunkReader<R>>> for TapChunkPulseIter<R>[src]

impl<R: Read> Iterator for ReadEncPulseIter<R>[src]

type Item = NonZeroU32

The type of the elements being iterated over.

Auto Trait Implementations

impl<R> !RefUnwindSafe for ReadEncPulseIter<R>[src]

impl<R> Send for ReadEncPulseIter<R> where
    R: Send
[src]

impl<R> Sync for ReadEncPulseIter<R> where
    R: Sync
[src]

impl<R> Unpin for ReadEncPulseIter<R> where
    R: Unpin
[src]

impl<R> !UnwindSafe for ReadEncPulseIter<R>[src]

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> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<S, T> IntoSample<S> for T where
    S: FromSample<T>, 
[src]

impl<I> IteratorRandom for I where
    I: Iterator
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

impl<T> TryConv for 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>,