@@ -10,25 +10,30 @@ use crate::{
1010/// An enum abstraction for BINSEQ readers that can process records in parallel
1111///
1212/// This is a convenience enum that can be used for general workflows where the
13- /// distinction between BQ and VBQ readers is not important.
13+ /// distinction between BINSEQ readers is not important.
1414///
15- /// For more specialized workflows see [`bq::MmapReader`] and [`vbq ::MmapReader`].
15+ /// For more specialized workflows see [`bq::MmapReader`], [`vbq::MmapReader`], and [`cbq ::MmapReader`].
1616pub enum BinseqReader {
1717 Bq ( bq:: MmapReader ) ,
1818 Vbq ( vbq:: MmapReader ) ,
1919 Cbq ( cbq:: MmapReader ) ,
2020}
2121impl BinseqReader {
22- pub fn new ( path : & str ) -> Result < Self > {
23- let pathbuf = Path :: new ( path) ;
24- match pathbuf. extension ( ) {
22+ pub fn new < P : AsRef < Path > > ( path : P ) -> Result < Self > {
23+ match path. as_ref ( ) . extension ( ) {
2524 Some ( ext) => match ext. to_str ( ) {
2625 Some ( "bq" ) => Ok ( Self :: Bq ( bq:: MmapReader :: new ( path) ?) ) ,
2726 Some ( "vbq" ) => Ok ( Self :: Vbq ( vbq:: MmapReader :: new ( path) ?) ) ,
2827 Some ( "cbq" ) => Ok ( Self :: Cbq ( cbq:: MmapReader :: new ( path) ?) ) ,
29- _ => Err ( ExtensionError :: UnsupportedExtension ( path. to_string ( ) ) . into ( ) ) ,
28+ _ => Err ( ExtensionError :: UnsupportedExtension (
29+ path. as_ref ( ) . to_string_lossy ( ) . to_string ( ) ,
30+ )
31+ . into ( ) ) ,
3032 } ,
31- None => Err ( ExtensionError :: UnsupportedExtension ( path. to_string ( ) ) . into ( ) ) ,
33+ None => Err ( ExtensionError :: UnsupportedExtension (
34+ path. as_ref ( ) . to_string_lossy ( ) . to_string ( ) ,
35+ )
36+ . into ( ) ) ,
3237 }
3338 }
3439
0 commit comments