Skip to content

Commit

Permalink
DecoderResult: into_inner_vec
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersTrier committed Apr 11, 2024
1 parent d557c85 commit 2ea99d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/decoder_result.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::rate::DecoderWork;
use std::mem::swap;

// ======================================================================
// DecoderResult - PUBLIC
Expand Down Expand Up @@ -27,6 +28,16 @@ impl<'a> DecoderResult<'a> {
pub fn restored_original_iter(&self) -> RestoredOriginal {
RestoredOriginal::new(self.work)
}

/// Returns inner Vec
pub fn into_inner_vec(self) -> Vec<u8> {
let mut buf = Vec::new();
swap(&mut buf, &mut self.work.shards.data);
//TODO: truncate
//buf.truncate(self.
self.work.reset_received();
buf
}
}

// ======================================================================
Expand All @@ -38,15 +49,6 @@ impl<'a> DecoderResult<'a> {
}
}

// ======================================================================
// DecoderResult - IMPL DROP

impl<'a> Drop for DecoderResult<'a> {
fn drop(&mut self) {
self.work.reset_received();
}
}

// ======================================================================
// RestoredOriginal - PUBLIC

Expand Down
2 changes: 1 addition & 1 deletion src/engine/shards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) struct Shards {
shard_bytes: usize,

// Flat array of `shard_count * shard_bytes` bytes.
data: Vec<u8>,
pub(crate) data: Vec<u8>,
}

impl Shards {
Expand Down
2 changes: 1 addition & 1 deletion src/rate/decoder_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct DecoderWork {
recovery_received_count: usize,
// May contain extra zero bits.
received: FixedBitSet,
shards: Shards,
pub(crate) shards: Shards,
}

impl DecoderWork {
Expand Down

0 comments on commit 2ea99d3

Please sign in to comment.