Fix EBML Source lifetimes, breaking the chunker
This commit is contained in:
parent
495ca0f555
commit
11bb7f4412
3 changed files with 8 additions and 14 deletions
|
@ -225,7 +225,7 @@ pub trait FromEbml<'b>: Sized {
|
|||
fn should_unwrap(element_id: u64) -> bool;
|
||||
fn decode(element_id: u64, bytes: &'b[u8]) -> Result<Self, Error>;
|
||||
|
||||
fn decode_element(bytes: &'b[u8]) -> Result<Option<(Self, usize)>, Error> {
|
||||
fn decode_element<'a: 'b>(bytes: &'a[u8]) -> Result<Option<(Self, usize)>, Error> {
|
||||
match decode_tag(bytes) {
|
||||
Ok(None) => Ok(None),
|
||||
Err(err) => Err(err),
|
||||
|
@ -263,7 +263,7 @@ pub trait FromEbml<'b>: Sized {
|
|||
pub trait EbmlEventSource<'a> {
|
||||
type Event: FromEbml<'a>;
|
||||
type Error;
|
||||
fn poll_event(&mut self) -> Result<Async<Option<Self::Event>>, Self::Error>;
|
||||
fn poll_event(&'a mut self) -> Result<Async<Option<Self::Event>>, Self::Error>;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -41,7 +41,7 @@ impl<'a, T: FromEbml<'a>> EbmlEventSource<'a> for EbmlIterator<'a, T> {
|
|||
type Event = T;
|
||||
type Error = Error;
|
||||
|
||||
fn poll_event(&mut self) -> Result<Async<Option<T>>, Error> {
|
||||
fn poll_event(&'a mut self) -> Result<Async<Option<T>>, Error> {
|
||||
match Self::Event::decode_element(&self.slice[self.position..]) {
|
||||
Err(err) => Err(err),
|
||||
Ok(None) => Ok(Async::Ready(None)),
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<I: AsRef<[u8]>, S: Stream<Item = I>> WebmStream<S> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn poll_event2<'a>(&'a mut self) -> Result<Async<Option<WebmElement<'a>>>, ParsingError<S::Error>> {
|
||||
pub fn poll_event<'a>(&'a mut self) -> Result<Async<Option<WebmElement<'a>>>, ParsingError<S::Error>> {
|
||||
// release buffer from previous event
|
||||
self.buffer.advance(self.last_read);
|
||||
self.last_read = 0;
|
||||
|
@ -71,20 +71,14 @@ impl<I: AsRef<[u8]>, S: Stream<Item = I>> WebmStream<S> {
|
|||
}
|
||||
}
|
||||
|
||||
/*fn umm<'a, I: AsRef<[u8]>, S: Stream<Item = I>>(webm_stream: &'a mut WebmStream<S>)
|
||||
-> Result<Async<Option<WebmElement<'a>>>, ParsingError<S::Error>>
|
||||
{
|
||||
return webmStream.poll_event();
|
||||
}*/
|
||||
|
||||
/*impl<'a, I: AsRef<[u8]>, S: Stream<Item = I>> EbmlEventSource<'a> for WebmStream<S> {
|
||||
impl<'a, I: AsRef<[u8]>, S: Stream<Item = I>> EbmlEventSource<'a> for WebmStream<S> {
|
||||
type Event = WebmElement<'a>;
|
||||
type Error = ParsingError<S::Error>;
|
||||
|
||||
fn poll_event(&'a mut self) -> Result<Async<Option<WebmElement<'a>>>, Self::Error> {
|
||||
return self.poll_event2();
|
||||
fn poll_event(&'a mut self) -> Result<Async<Option<Self::Event>>, Self::Error> {
|
||||
return WebmStream::poll_event(&mut self);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
Loading…
Reference in a new issue