0.18 round 2: add FrameSink impls to concrete mux sinks
Per-impl migration of MkvStream / M2tsStream / NetworkStream / NullStream / StdioStream from the deprecated pes::Stream trait to the typed pes::FrameSink trait. Both impls coexist during the 0.18 deprecation window — the existing Stream impls are unchanged. The FrameSink::finish signature differs (Box<Self> vs &mut self), which is why this couldn't be a blanket impl. Each migration re-borrows the box and delegates to the underlying Stream::finish body. FrameSink: Send forced two struct fields (M2tsStream's boxed Write/Read, MkvStream's boxed WriteSeek/Read) to gain `+ Send` bounds — minimum surface needed to make the Send-bounded trait impl-able. mux::resolve::output's local Box<dyn WriteSeek> construction picks up the same `+ Send`. tests/streams.rs's shared `stream.write/.finish/.info/.read` calls were disambiguated to `PesStream::*` to resolve the now-multiple candidates from coexisting trait impls. Caller migration (mux::resolve::output return type, autorip, CLI) is a later slice. This commit only adds new impls; nothing removed. See (internal)/memory/0_18_redesign.md. Single contributor: MattJackson.
This commit is contained in:
@@ -109,6 +109,30 @@ impl crate::pes::Stream for NetworkStream {
|
||||
}
|
||||
}
|
||||
|
||||
/// FrameSink sibling to the deprecated Stream impl; both coexist during the
|
||||
/// 0.18 deprecation window. Caller may pick either at the trait-object
|
||||
/// boundary — `Box<dyn Stream>` (deprecated) or `Box<dyn FrameSink>` (new).
|
||||
/// Use `NetworkStream::connect(addr).meta(title)` to construct the write
|
||||
/// half; calling `FrameSink::write` on `NetworkStream::listen(addr)` returns
|
||||
/// `StreamReadOnly`.
|
||||
#[allow(deprecated)] // delegating to deprecated Stream during the 0.18 deprecation window so callers don't see the deprecation twice.
|
||||
impl crate::pes::FrameSink for NetworkStream {
|
||||
fn write(&mut self, frame: &crate::pes::PesFrame) -> io::Result<()> {
|
||||
<Self as crate::pes::Stream>::write(self, frame)
|
||||
}
|
||||
|
||||
fn finish(self: Box<Self>) -> io::Result<()> {
|
||||
// Why: Stream::finish takes &mut self, FrameSink::finish takes Box<Self>.
|
||||
// Re-borrow inside the box, call Stream::finish, drop the box.
|
||||
let mut s: Self = *self;
|
||||
<Self as crate::pes::Stream>::finish(&mut s)
|
||||
}
|
||||
|
||||
fn info(&self) -> &DiscTitle {
|
||||
<Self as crate::pes::Stream>::info(self)
|
||||
}
|
||||
}
|
||||
|
||||
// NetworkStream is PES-only — no IOStream/Read/Write byte interface.
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user