flv: Allow breaking a Reader down into parts or building one up from parts.

This commit is contained in:
David Wendt 2023-04-10 19:51:13 -04:00 committed by kmeisthax
parent 4d829768a1
commit 0edfecfea0
1 changed files with 13 additions and 0 deletions

View File

@ -13,6 +13,19 @@ impl<'a> FlvReader<'a> {
}
}
/// Reconstitute an FLV reader from its source parts.
///
/// The seek position must point to identical data between breaking down an
/// FLV reader and building it back up.
pub fn from_parts(source: &'a [u8], position: usize) -> Self {
FlvReader { source, position }
}
/// Break down an FLV reader into its source buffer and seek position.
pub fn into_parts(self) -> (&'a [u8], usize) {
(self.source, self.position)
}
/// Read a certain number of bytes from the buffer.
///
/// This works like `Read`, but returns borrowed slices of the source