Tidy Stream extension trait impl
This commit is contained in:
parent
9ca384f9da
commit
b7ee425905
4 changed files with 12 additions and 19 deletions
1
notes.md
1
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
|
||||
|
|
10
src/chunk.rs
10
src/chunk.rs
|
@ -242,12 +242,8 @@ impl<S: EbmlEventSource> Stream for WebmChunker<S>
|
|||
}
|
||||
}
|
||||
|
||||
pub trait WebmStream<T: EbmlEventSource> {
|
||||
fn chunk_webm(self) -> WebmChunker<T>;
|
||||
}
|
||||
|
||||
impl<'a, T: EbmlEventSource> WebmStream<T> for T {
|
||||
fn chunk_webm(self) -> WebmChunker<T> {
|
||||
pub trait WebmStream where Self: Sized + EbmlEventSource {
|
||||
fn chunk_webm(self) -> WebmChunker<Self> {
|
||||
WebmChunker {
|
||||
source: self,
|
||||
state: ChunkerState::BuildingHeader(Cursor::new(Vec::new()))
|
||||
|
@ -255,6 +251,8 @@ impl<'a, T: EbmlEventSource> WebmStream<T> for T {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: EbmlEventSource> WebmStream for T {}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
|
|
|
@ -42,12 +42,8 @@ impl<S: Stream<Item = Chunk>> Stream for ChunkTimecodeFixer<S>
|
|||
}
|
||||
}
|
||||
|
||||
pub trait ChunkStream<T> {
|
||||
fn fix_timecodes(self) -> ChunkTimecodeFixer<T>;
|
||||
}
|
||||
|
||||
impl<T: Stream<Item = Chunk>> ChunkStream<T> for T {
|
||||
fn fix_timecodes(self) -> ChunkTimecodeFixer<T> {
|
||||
pub trait ChunkStream where Self : Sized + Stream<Item = Chunk> {
|
||||
fn fix_timecodes(self) -> ChunkTimecodeFixer<Self> {
|
||||
ChunkTimecodeFixer {
|
||||
stream: self,
|
||||
current_offset: 0,
|
||||
|
@ -57,3 +53,5 @@ impl<T: Stream<Item = Chunk>> ChunkStream<T> for T {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Stream<Item = Chunk>> ChunkStream for T {}
|
||||
|
|
|
@ -18,12 +18,8 @@ pub struct EbmlStreamingParser<S> {
|
|||
last_read: usize
|
||||
}
|
||||
|
||||
pub trait StreamEbml<I: AsRef<[u8]>, S: Stream<Item = I>> {
|
||||
fn parse_ebml(self) -> EbmlStreamingParser<S>;
|
||||
}
|
||||
|
||||
impl<I: AsRef<[u8]>, S: Stream<Item = I>> StreamEbml<I, S> for S {
|
||||
fn parse_ebml(self) -> EbmlStreamingParser<S> {
|
||||
pub trait StreamEbml where Self: Sized + Stream, Self::Item: AsRef<[u8]> {
|
||||
fn parse_ebml(self) -> EbmlStreamingParser<Self> {
|
||||
EbmlStreamingParser {
|
||||
stream: self,
|
||||
buffer: BytesMut::new(),
|
||||
|
@ -32,6 +28,8 @@ impl<I: AsRef<[u8]>, S: Stream<Item = I>> StreamEbml<I, S> for S {
|
|||
}
|
||||
}
|
||||
|
||||
impl<I: AsRef<[u8]>, S: Stream<Item = I>> StreamEbml for S {}
|
||||
|
||||
impl<I: AsRef<[u8]>, S: Stream<Item = I>> EbmlStreamingParser<S> {
|
||||
pub fn poll_event<'a, T: FromEbml<'a>>(&'a mut self) -> Result<Async<Option<T>>, ParsingError<S::Error>> {
|
||||
// release buffer from previous event
|
||||
|
|
Loading…
Reference in a new issue