One possible solution for RustAudio/lewton#84 requires to look ahead future packets. This issue is for discussing the API and internal design.
My idea is as follows:
- Add a function like this:
PacketReader::peeking_reader<'a>(&'a mut self) -> PeekingPacketReader<'a>
This way, we cannot use the original PacketReader while using PeekingPacketReader.
PeekingPacketReader provides subset functions of those of PacketReader: into_inner, read_packet and read_packet_expected. (and possibly delete_unread_packets?)
- When a
PeekingPacketReader is generated, it stores the current position of underlying reader, which will be restored when the PeekingPacketReader is dropped.
- Alternatively, we can store all the loaded packets into
PacketReader and yield them first after the Peeking one is invalidated. This way, we don't have to rely on base reader's Seekableness.
How do you think?
One possible solution for RustAudio/lewton#84 requires to look ahead future packets. This issue is for discussing the API and internal design.
My idea is as follows:
PacketReader::peeking_reader<'a>(&'a mut self) -> PeekingPacketReader<'a>This way, we cannot use the original
PacketReaderwhile usingPeekingPacketReader.PeekingPacketReaderprovides subset functions of those ofPacketReader:into_inner,read_packetandread_packet_expected. (and possiblydelete_unread_packets?)PeekingPacketReaderis generated, it stores the current position of underlying reader, which will be restored when thePeekingPacketReaderis dropped.PacketReaderand yield them first after the Peeking one is invalidated. This way, we don't have to rely on base reader'sSeekableness.How do you think?