Function flac::metadata::get_stream_info [] [src]

pub fn get_stream_info(filename: &str) -> Result<StreamInfo, ErrorKind>

Reads and returns the StreamInfo metadata block of the given FLAC file.

Failures

  • ErrorKind::NotFound is returned when the there is no StreamInfo within the file.
  • ErrorKind::IO(io::ErrorKind::NotFound) is returned when the given filename isn't found.
  • ErrorKind::IO(io::ErrorKind::InvalidData) is returned when the data within the file isn't valid FLAC data.
  • Several different parser specific errors that are structured as ErrorKind::<parser_name>Parser.

Examples

Handling errors might look something like this:

use flac::metadata;

match metadata::get_stream_info("path/to/file.flac") {
  Ok(stream_info) => {
    // Use the stream_info variable...
  }
  Err(error)      => println!("{:?}", error),
}

Or just ignore the errors:

use flac::metadata;

let stream_info = metadata::get_stream_info("path/to/file.flac").unwrap();