Auto-update fts index
Some checks failed
CI / Typos (push) Successful in 15s
CI / Clippy (push) Successful in 1m5s
CI / Build and test (push) Failing after 1m2s

This commit is contained in:
2026-02-21 15:55:10 -08:00
parent 5d8ad4665d
commit 141839ae55
36 changed files with 1119 additions and 275 deletions

View File

@@ -88,7 +88,7 @@ enum FlacBlockType {
}
#[derive(Debug)]
#[allow(missing_docs)]
#[expect(missing_docs)]
pub enum FlacBlock {
Streaminfo(FlacStreaminfoBlock),
Picture(FlacPictureBlock),
@@ -212,9 +212,16 @@ impl FlacBlockReader {
}
'outer: while last_read_size != 0 {
match self.current_block.as_mut().unwrap() {
#[expect(clippy::expect_used)]
match self
.current_block
.as_mut()
.expect("current_block is Some, checked above")
{
FlacBlockType::MagicBits { data, left_to_read } => {
last_read_size = buf.read(&mut data[4 - *left_to_read..4]).unwrap();
last_read_size = buf
.read(&mut data[4 - *left_to_read..4])
.map_err(FlacDecodeError::from)?;
*left_to_read -= last_read_size;
if *left_to_read == 0 {
@@ -235,7 +242,9 @@ impl FlacBlockReader {
data,
left_to_read,
} => {
last_read_size = buf.read(&mut data[4 - *left_to_read..4]).unwrap();
last_read_size = buf
.read(&mut data[4 - *left_to_read..4])
.map_err(FlacDecodeError::from)?;
*left_to_read -= last_read_size;
if *left_to_read == 0 {
@@ -253,13 +262,24 @@ impl FlacBlockReader {
}
FlacBlockType::MetaBlock { header, data } => {
last_read_size = buf
.by_ref()
.take(u64::from(header.length) - u64::try_from(data.len()).unwrap())
.read_to_end(data)
.unwrap();
#[expect(clippy::expect_used)]
{
last_read_size = buf
.by_ref()
.take(
u64::from(header.length)
- u64::try_from(data.len())
.expect("data length does not fit into u64"),
)
.read_to_end(data)
.map_err(FlacDecodeError::from)?;
}
if data.len() == usize::try_from(header.length).unwrap() {
#[expect(clippy::expect_used)]
if data.len()
== usize::try_from(header.length)
.expect("header length does not fit into usize")
{
// If we picked this block type, add it to the queue
if self.selector.should_pick_meta(header.block_type) {
let b = FlacBlock::decode(header.block_type, data)?;
@@ -283,7 +303,11 @@ impl FlacBlockReader {
// Limit the number of bytes we read at once, so we don't re-clone
// large amounts of data if `buf` contains multiple sync sequences.
// 5kb is a pretty reasonable frame size.
last_read_size = buf.by_ref().take(5_000).read_to_end(data).unwrap();
last_read_size = buf
.by_ref()
.take(5_000)
.read_to_end(data)
.map_err(FlacDecodeError::from)?;
if last_read_size == 0 {
continue 'outer;
}
@@ -335,9 +359,10 @@ impl FlacBlockReader {
// Backtrack to the first bit AFTER this new sync sequence
buf.seek(std::io::SeekFrom::Current(
-i64::try_from(data.len() - i).unwrap(),
-i64::try_from(data.len() - i)
.expect("seek offset does not fit into i64"),
))
.unwrap();
.map_err(FlacDecodeError::from)?;
self.current_block = Some(FlacBlockType::AudioData {
data: {
@@ -406,6 +431,7 @@ mod tests {
flac::tests::{FlacBlockOutput, FlacTestCase, VorbisCommentTestValue, manifest},
};
#[expect(clippy::unwrap_used)]
fn read_file(
test_case: &FlacTestCase,
fragment_size_range: Option<Range<usize>>,
@@ -447,6 +473,7 @@ mod tests {
return Ok(out_blocks);
}
#[expect(clippy::unwrap_used)]
fn test_identical(
test_case: &FlacTestCase,
fragment_size_range: Option<Range<usize>>,