mirror of
https://github.com/iluvcapra/bwavfile.git
synced 2025-12-31 17:00:44 +00:00
allow more types to be used as paths
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
|
||||
use std::fs::File;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use std::io::SeekFrom;
|
||||
use std::io::Cursor;
|
||||
use std::io::{Read, Seek, BufReader};
|
||||
@@ -198,7 +200,7 @@ pub struct WaveReader<R: Read + Seek> {
|
||||
|
||||
impl WaveReader<BufReader<File>> {
|
||||
|
||||
pub fn open(path: &str) -> Result<Self, ParserError> {
|
||||
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, ParserError> {
|
||||
let f = File::open(path)?;
|
||||
let inner = BufReader::new(f);
|
||||
Ok( Self::new(inner)? )
|
||||
@@ -211,7 +213,7 @@ impl WaveReader<File> {
|
||||
///
|
||||
/// A convenience that opens `path` and calls `Self::new()`
|
||||
|
||||
pub fn open_unbuffered(path: &str) -> Result<Self, ParserError> {
|
||||
pub fn open_unbuffered<P: AsRef<Path>>(path: P) -> Result<Self, ParserError> {
|
||||
let inner = File::open(path)?;
|
||||
return Ok( Self::new(inner)? )
|
||||
}
|
||||
@@ -600,4 +602,4 @@ fn test_list_form() {
|
||||
|
||||
assert_ne!(buf.len(), 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user