Unified Stream trait: read() and write() on one type

Stream trait: read() returns PesFrame, write() accepts PesFrame.
A stream is a stream — you read from it or write to it.
No separate Input/Output traits.

API: libfreemkv::input(url) and libfreemkv::output(url, title, codecs)
Returns Box<dyn Stream>.
This commit is contained in:
MattJackson
2026-04-15 03:33:29 +00:00
parent 323d04b7b7
commit 547babf39a
33 changed files with 689 additions and 400 deletions
+11 -2
View File
@@ -333,8 +333,8 @@ impl IOStream for DiscStream {
}
}
impl crate::pes::InputStream for DiscStream {
fn next_frame(&mut self) -> io::Result<Option<crate::pes::PesFrame>> {
impl crate::pes::Stream for DiscStream {
fn read(&mut self) -> io::Result<Option<crate::pes::PesFrame>> {
// Return buffered frame if available
if let Some(frame) = self.pending_frames.pop_front() {
return Ok(Some(frame));
@@ -399,6 +399,15 @@ impl crate::pes::InputStream for DiscStream {
}
}
fn write(&mut self, _frame: &crate::pes::PesFrame) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Unsupported, "disc is read-only"))
}
fn finish(&mut self) -> io::Result<()> {
self.drive.unlock_tray();
Ok(())
}
fn info(&self) -> &DiscTitle {
&self.title
}