Skip to main content

FluxCells

Struct FluxCells 

Source
pub struct FluxCells { /* private fields */ }
Expand description

While this object is in the form of flux cells, it can actually be used for any form of track data: flux streams, bit streams, or nibble streams. Each bit in the stream represents a flux-cell where there may be a flux transition. If fshift < bshift, we have a flux stream. If fshift == bshift, we have a bit stream. If uniform-length nibbles are tightly packed, we have a nibble stream.

Implementations§

Source§

impl FluxCells

Source

pub fn from_woz_bits( bit_count: usize, buf: &[u8], time: u64, double_speed: bool, ) -> Self

Create cells from a track buffer in the form of a nibble stream or bit stream, assuming 4 microsecond bit cells

Source

pub fn from_woz_flux( byte_count: usize, buf: &[u8], time: u64, double_speed: bool, ) -> Self

Create cells from a WOZ flux track buffer, the flux cells will be set to 500/250 ns. Any padding in buf is ignored.

Source

pub fn change_resolution(&mut self, flux_shift: usize)

Change the resolution of the cells. Mainly useful for converting between bitstream tracks and flux tracks. N.b. if resolution is being reduced information will be lost, in general.

Source

pub fn to_woz_buf( &self, padded_len: Option<usize>, padded_val: u8, ) -> (Vec<u8>, usize)

Convert the cells to the native WOZ or NIB track buffer, works for any kind of cell. If padded_len==None the result is padded to the nearest 512 byte boundary. If padded_len==Some and the data fits within the prescribed length, it is used, otherwise panic. Returns (buf,count), where count is either the bit count for bit streams, or byte count for flux streams.

Source

pub fn sync_to_other_track(&mut self, other: &FluxCells)

Synchronize these cells to another set of cells, used when switching tracks. This will impose alignment of the time-pointer to a flux cell boundary.

Source

pub fn count(&self) -> usize

How many cells are on this track

Source

pub fn set_ptr(&mut self, ticks: usize)

Source

pub fn fwd(&mut self, ticks: usize)

advance on the track by ticks and update the elapsed time

Source

pub fn rev(&mut self, ticks: usize)

Go back on the track by ticks, this will also reverse the elapsed time (pegs to 0). Avoid using, saving and restoring state is usually preferable.

Source

pub fn ticks_since(&self, ref_tick: u64) -> u64

ticks since the reference tick, if ref_tick is in the future return 0

Source

pub fn ps_since(&self, ref_tick: u64) -> u64

picoseconds since the reference tick, if ref_tick is in the future return 0

Source

pub fn density(&self) -> Option<f64>

If there is timing information, return the density of the original data relative to the expected density, otherwise return None.

Source

pub fn read_bit(&mut self) -> bool

emit a pulse from the current bit cell and advance

Source

pub fn write_bit(&mut self, pulse: bool)

write a pulse to the current bit cell and advance

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.