DynDecoder

Enum DynDecoder 

Source
pub enum DynDecoder<'a, T: Topology> {
    S1(DecodingState<'a, T, 1>),
    S2(DecodingState<'a, T, 2>),
    S4(DecodingState<'a, T, 4>),
    S8(DecodingState<'a, T, 8>),
    S16(DecodingState<'a, T, 16>),
    S32(DecodingState<'a, T, 32>),
    S64(DecodingState<'a, T, 64>),
    S128(DecodingState<'a, T, 128>),
    S256(DecodingState<'a, T, 256>),
    S512(DecodingState<'a, T, 512>),
}
Expand description

Dynamic decoder wrapper that hides the STRIDE_Y const generic.

This enum provides a unified interface regardless of the underlying stride, at the cost of a small dispatch overhead per method call.

§Performance Note

For maximum performance in tight loops, prefer using DecodingState directly with the correct const generic. The dynamic dispatch overhead is typically negligible for most use cases.

§Example

let mut decoder = DecoderBuilder::<SquareGrid>::new()
    .dimensions(32, 32)
    .build(&mut arena)?;

// Use unified interface regardless of stride
decoder.load_dense_syndromes(&syndromes);
decoder.grow_clusters();
let count = decoder.peel_forest(&mut corrections);
decoder.reset_for_next_cycle();

Variants§

§

S1(DecodingState<'a, T, 1>)

Stride 1 (1x1 grids).

§

S2(DecodingState<'a, T, 2>)

Stride 2 (up to 2x2 grids).

§

S4(DecodingState<'a, T, 4>)

Stride 4 (up to 4x4 grids).

§

S8(DecodingState<'a, T, 8>)

Stride 8 (up to 8x8 grids).

§

S16(DecodingState<'a, T, 16>)

Stride 16 (up to 16x16 grids).

§

S32(DecodingState<'a, T, 32>)

Stride 32 (up to 32x32 grids).

§

S64(DecodingState<'a, T, 64>)

Stride 64 (up to 64x64 grids).

§

S128(DecodingState<'a, T, 128>)

Stride 128 (up to 128x128 grids).

§

S256(DecodingState<'a, T, 256>)

Stride 256 (up to 256x256 grids).

§

S512(DecodingState<'a, T, 512>)

Stride 512 (up to 512x512 grids).

Implementations§

Source§

impl<'a, T: Topology> DynDecoder<'a, T>

Source

pub fn load_dense_syndromes(&mut self, syndromes: &[u64])

Loads syndrome measurements from a dense bitarray.

Each u64 in the slice represents 64 consecutive nodes, where bit i being set indicates a syndrome at node (block_index * 64 + i).

§Arguments
  • syndromes - Dense syndrome bitarray with one u64 per 64-node block.
Source

pub fn grow_clusters(&mut self)

Performs full cluster growth until convergence.

This iteratively expands syndrome clusters until all defects are paired or reach boundaries.

Source

pub fn grow_iteration(&mut self) -> bool

Performs a single growth iteration.

Returns true if more iterations are needed, false if converged.

Source

pub fn peel_forest(&mut self, corrections: &mut [EdgeCorrection]) -> usize

Extracts corrections by peeling the cluster forest.

This traces paths from defects and accumulates edge corrections.

§Arguments
  • corrections - Output buffer for edge corrections.
§Returns

The number of corrections written to the buffer.

Source

pub fn decode(&mut self, corrections: &mut [EdgeCorrection]) -> usize

Performs full decode cycle (grow + peel).

This is equivalent to calling grow_clusters followed by peel_forest.

§Arguments
  • corrections - Output buffer for edge corrections.
§Returns

The number of corrections written to the buffer.

Source

pub fn reset_for_next_cycle(&mut self)

Resets state for the next decoding cycle (sparse reset).

This efficiently resets only the blocks that were modified during the previous decoding cycle.

Source

pub fn full_reset(&mut self)

Fully resets all decoder state.

This performs a complete reset of all internal data structures. For repeated decoding, prefer reset_for_next_cycle.

Source

pub fn width(&self) -> usize

Returns the grid width.

Source

pub fn height(&self) -> usize

Returns the grid height.

Source

pub fn stride_y(&self) -> usize

Returns the stride Y value.

Auto Trait Implementations§

§

impl<'a, T> Freeze for DynDecoder<'a, T>

§

impl<'a, T> RefUnwindSafe for DynDecoder<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for DynDecoder<'a, T>
where T: Send,

§

impl<'a, T> Sync for DynDecoder<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for DynDecoder<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for DynDecoder<'a, T>

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.