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:
+8
-2
@@ -256,8 +256,8 @@ impl IsoStream {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::pes::InputStream for IsoStream {
|
||||
fn next_frame(&mut self) -> io::Result<Option<crate::pes::PesFrame>> {
|
||||
impl crate::pes::Stream for IsoStream {
|
||||
fn read(&mut self) -> io::Result<Option<crate::pes::PesFrame>> {
|
||||
// Return buffered frame
|
||||
if let Some(frame) = self.pending_frames.pop_front() {
|
||||
return Ok(Some(frame));
|
||||
@@ -301,6 +301,12 @@ impl crate::pes::InputStream for IsoStream {
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&mut self, _frame: &crate::pes::PesFrame) -> io::Result<()> {
|
||||
Err(io::Error::new(io::ErrorKind::Unsupported, "ISO is read-only for PES"))
|
||||
}
|
||||
|
||||
fn finish(&mut self) -> io::Result<()> { Ok(()) }
|
||||
|
||||
fn info(&self) -> &crate::disc::DiscTitle {
|
||||
&self.disc_title
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user