Skip to main content

InputStream

Struct InputStream 

Source
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>

Source

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§

Source§

impl<'src, T: Debug> Debug for InputStream<'src, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.