You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I want to use a media source that depends on an external life time 'a:
// My media source implementation:structDatasetMediaSource<'a>{r: hdf5::ByteReader<'a>,// Implements io::Read and io::Seek, but does not have a static life timesize:u64,}impl<'a>DatasetMediaSource<'a>{fnnew(ds:&'a hdf5::Dataset) -> Result<DatasetMediaSource<'a>>{Ok(DatasetMediaSource{r: ds.as_byte_reader()?,size: ds.size()asu64,})}}impl<'a>ReadforDatasetMediaSource<'a>{fnread(&mutself,buf:&mut[u8]) -> std::io::Result<usize>{self.r.read(buf)}}impl<'a>SeekforDatasetMediaSource<'a>{fnseek(&mutself,pos:SeekFrom) -> std::io::Result<u64>{self.r.seek(pos)}}impl<'a>MediaSourceforDatasetMediaSource<'a>{fnis_seekable(&self) -> bool{true}fnbyte_len(&self) -> Option<u64>{Some(self.size)}}
However, MediaSourceStream requires a static life time:
// media_source_stream.rspubstructMediaSourceStream{/// The source reader.inner:Box<dynMediaSource>,// same as: Box<dyn MediaSource + 'static>/// ...
Resulting in the error
let source = Box::new(DatasetMediaSource::new(&ds)?);// type: Box<dyn MediaSource + 'a>
^^^ borrowed value does not live long enough
Does someone have an idea, if I can use such a MediaSource?
The text was updated successfully, but these errors were encountered:
So I want to use a media source that depends on an external life time
'a
:However, MediaSourceStream requires a static life time:
Resulting in the error
Does someone have an idea, if I can use such a MediaSource?
The text was updated successfully, but these errors were encountered: