diff --git a/notes.md b/notes.md index 626e18d..ccac46b 100644 --- a/notes.md +++ b/notes.md @@ -1,3 +1,2 @@ * support memory limit as toplevel limit on buffer size when Ok(None) (so only needed in futures/Read version) * rustfmt modules -* bytestream source for ebml parsing diff --git a/src/chunk.rs b/src/chunk.rs index 7ccdfa4..7bfdf35 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -242,12 +242,8 @@ impl Stream for WebmChunker } } -pub trait WebmStream { - fn chunk_webm(self) -> WebmChunker; -} - -impl<'a, T: EbmlEventSource> WebmStream for T { - fn chunk_webm(self) -> WebmChunker { +pub trait WebmStream where Self: Sized + EbmlEventSource { + fn chunk_webm(self) -> WebmChunker { WebmChunker { source: self, state: ChunkerState::BuildingHeader(Cursor::new(Vec::new())) @@ -255,6 +251,8 @@ impl<'a, T: EbmlEventSource> WebmStream for T { } } +impl WebmStream for T {} + #[cfg(test)] mod tests { diff --git a/src/fixers.rs b/src/fixers.rs index 9974bbc..4d73050 100644 --- a/src/fixers.rs +++ b/src/fixers.rs @@ -42,12 +42,8 @@ impl> Stream for ChunkTimecodeFixer } } -pub trait ChunkStream { - fn fix_timecodes(self) -> ChunkTimecodeFixer; -} - -impl> ChunkStream for T { - fn fix_timecodes(self) -> ChunkTimecodeFixer { +pub trait ChunkStream where Self : Sized + Stream { + fn fix_timecodes(self) -> ChunkTimecodeFixer { ChunkTimecodeFixer { stream: self, current_offset: 0, @@ -57,3 +53,5 @@ impl> ChunkStream for T { } } } + +impl> ChunkStream for T {} diff --git a/src/stream_parser.rs b/src/stream_parser.rs index ee8b120..278410a 100644 --- a/src/stream_parser.rs +++ b/src/stream_parser.rs @@ -18,12 +18,8 @@ pub struct EbmlStreamingParser { last_read: usize } -pub trait StreamEbml, S: Stream> { - fn parse_ebml(self) -> EbmlStreamingParser; -} - -impl, S: Stream> StreamEbml for S { - fn parse_ebml(self) -> EbmlStreamingParser { +pub trait StreamEbml where Self: Sized + Stream, Self::Item: AsRef<[u8]> { + fn parse_ebml(self) -> EbmlStreamingParser { EbmlStreamingParser { stream: self, buffer: BytesMut::new(), @@ -32,6 +28,8 @@ impl, S: Stream> StreamEbml for S { } } +impl, S: Stream> StreamEbml for S {} + impl, S: Stream> EbmlStreamingParser { pub fn poll_event<'a, T: FromEbml<'a>>(&'a mut self) -> Result>, ParsingError> { // release buffer from previous event