pub struct InputStream<'src, T> { /* private fields */ }Expand description
Type that allows you to create an SFML input stream from a Read + Seek source.
Implementations§
Source§impl<'src, T: Read + Seek> InputStream<'src, T>
impl<'src, T: Read + Seek> InputStream<'src, T>
Sourcepub fn new(stream: &'src mut T) -> InputStream<'src, T>
pub fn new(stream: &'src mut T) -> InputStream<'src, T>
Create a new input stream from a Read + Seek source.
§Panics
Panics if a new InputStream can’t be created for some reason.
Examples found in repository?
examples/music-stream.rs (line 15)
11fn main() -> Result<(), Box<dyn Error>> {
12 example_ensure_right_working_dir();
13
14 let mut file = File::open("orchestral.ogg")?;
15 let mut stream = InputStream::new(&mut file);
16 let mut music = Music::from_stream(&mut stream)?;
17
18 // Display Music informations
19 println!("orchestral.ogg :");
20 println!(" {} seconds", music.duration().as_seconds());
21 println!(" {} samples / sec", music.sample_rate());
22 println!(" {} channels", music.channel_count());
23
24 music.play();
25
26 while music.status() == SoundStatus::PLAYING {
27 // Leave some CPU time for other processes
28 sleep(Time::milliseconds(100));
29 // Display the playing position
30 print!(
31 "\rPlaying... {:.2} sec",
32 music.playing_offset().as_seconds()
33 );
34 let _ = std::io::stdout().flush();
35 }
36 println!();
37 Ok(())
38}Trait Implementations§
Auto Trait Implementations§
impl<'src, T> Freeze for InputStream<'src, T>
impl<'src, T> RefUnwindSafe for InputStream<'src, T>where
T: RefUnwindSafe,
impl<'src, T> Send for InputStream<'src, T>where
T: Send,
impl<'src, T> Sync for InputStream<'src, T>where
T: Sync,
impl<'src, T> Unpin for InputStream<'src, T>
impl<'src, T> UnsafeUnpin for InputStream<'src, T>
impl<'src, T> !UnwindSafe for InputStream<'src, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more