Skip to content

Commit

Permalink
Apply rustfmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentMazare committed Aug 29, 2024
1 parent 27710f5 commit f17a87c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
14 changes: 3 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ impl TableOfContent {
let all_headers = ogg::all_headers(rdr)?;
let entries: Vec<_> = all_headers
.into_iter()
.map(|(file_pos, hdr)| Entry {
file_pos,
granule_position: hdr.granule_position,
})
.map(|(file_pos, hdr)| Entry { file_pos, granule_position: hdr.granule_position })
.collect();
Ok(Self { entries })
}
Expand All @@ -40,10 +37,7 @@ impl TableOfContent {
let mut entries = Vec::new();
while let Ok(file_pos) = rdr.read_u64::<LittleEndian>() {
let granule_position = rdr.read_u64::<LittleEndian>().unwrap();
entries.push(Entry {
file_pos,
granule_position,
});
entries.push(Entry { file_pos, granule_position });
}
Ok(Self { entries })
}
Expand All @@ -58,9 +52,7 @@ impl TableOfContent {
}

pub fn last_entry_before(&self, start_pos: u64) -> Option<&Entry> {
let packet_idx = self
.entries
.partition_point(|entry| entry.granule_position < start_pos);
let packet_idx = self.entries.partition_point(|entry| entry.granule_position < start_pos);
let mut packet_idx = packet_idx.saturating_sub(1);
while packet_idx < self.entries.len() && self.entries[packet_idx].granule_position == 0 {
packet_idx += 1;
Expand Down
15 changes: 3 additions & 12 deletions src/ogg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ impl<R: std::io::Read + std::io::Seek> PacketReader<R> {
None => anyhow::bail!("no data left"),
Some(header) => header,
};
if self
.current_header
.header_type
.has_flag(HeaderTypeFlag::Continuation)
{
if self.current_header.header_type.has_flag(HeaderTypeFlag::Continuation) {
anyhow::bail!("continuations are not handled properly when seeking")
}
if move_to_last_segment {
Expand All @@ -135,8 +131,7 @@ impl<R: std::io::Read + std::io::Seek> PacketReader<R> {
}
}
self.segment_idx = n_to_skip;
self.reader
.seek(std::io::SeekFrom::Current(to_skip as i64))?;
self.reader.seek(std::io::SeekFrom::Current(to_skip as i64))?;
}
Ok(self.current_header.granule_position)
}
Expand Down Expand Up @@ -171,11 +166,7 @@ impl<R: std::io::Read> PacketReader<R> {
None => anyhow::bail!("empty file"),
Some(header) => header,
};
Ok(Self {
reader,
current_header,
segment_idx: 0,
})
Ok(Self { reader, current_header, segment_idx: 0 })
}

pub fn next_packet(&mut self) -> Result<Option<Vec<u8>>> {
Expand Down

0 comments on commit f17a87c

Please sign in to comment.