@@ -923,7 +923,9 @@ where
923
923
}
924
924
925
925
impl ElfParser < File > {
926
- fn open_file_io < P > ( file : File , path : P ) -> Self
926
+ /// Create an `ElfParser` that uses regular file I/O on the provided
927
+ /// file.
928
+ fn from_file_io < P > ( file : File , path : P ) -> Self
927
929
where
928
930
P : Into < PathBuf > ,
929
931
{
@@ -938,15 +940,16 @@ impl ElfParser<File> {
938
940
parser
939
941
}
940
942
941
- /// Create an `ElfParser` from an open file.
942
- pub ( crate ) fn open_non_mmap < P > ( path : P ) -> Result < Self >
943
+ /// Create an `ElfParser` employing regular file I/O, opening the
944
+ /// file at `path`.
945
+ pub ( crate ) fn open_file_io < P > ( path : P ) -> Result < Self >
943
946
where
944
947
P : Into < PathBuf > ,
945
948
{
946
949
let path = path. into ( ) ;
947
950
let file =
948
951
File :: open ( & path) . with_context ( || format ! ( "failed to open `{}`" , path. display( ) ) ) ?;
949
- let slf = Self :: open_file_io ( file, path) ;
952
+ let slf = Self :: from_file_io ( file, path) ;
950
953
Ok ( slf)
951
954
}
952
955
@@ -958,7 +961,7 @@ impl ElfParser<File> {
958
961
959
962
impl ElfParser < Mmap > {
960
963
/// Create an `ElfParser` from an open file.
961
- pub ( crate ) fn open_file < P > ( file : & File , path : P ) -> Result < Self >
964
+ pub ( crate ) fn from_file < P > ( file : & File , path : P ) -> Result < Self >
962
965
where
963
966
P : Into < PathBuf > ,
964
967
{
@@ -987,7 +990,7 @@ impl ElfParser<Mmap> {
987
990
pub ( crate ) fn open ( path : & Path ) -> Result < ElfParser > {
988
991
let file =
989
992
File :: open ( path) . with_context ( || format ! ( "failed to open {}" , path. display( ) ) ) ?;
990
- Self :: open_file ( & file, path)
993
+ Self :: from_file ( & file, path)
991
994
}
992
995
}
993
996
@@ -1434,10 +1437,10 @@ mod tests {
1434
1437
}
1435
1438
1436
1439
let path = file. path ( ) . to_path_buf ( ) ;
1437
- let parser_mmap = ElfParser :: open_file ( file. as_file ( ) , & path) . unwrap ( ) ;
1440
+ let parser_mmap = ElfParser :: from_file ( file. as_file ( ) , & path) . unwrap ( ) ;
1438
1441
let ( ) = test ( parser_mmap) ;
1439
1442
1440
- let parser_io = ElfParser :: open_file_io ( file. into_file ( ) , & path) ;
1443
+ let parser_io = ElfParser :: from_file_io ( file. into_file ( ) , & path) ;
1441
1444
let ( ) = test ( parser_io) ;
1442
1445
}
1443
1446
@@ -1502,10 +1505,10 @@ mod tests {
1502
1505
}
1503
1506
1504
1507
let path = file. path ( ) . to_path_buf ( ) ;
1505
- let parser_mmap = ElfParser :: open_file ( file. as_file ( ) , & path) . unwrap ( ) ;
1508
+ let parser_mmap = ElfParser :: from_file ( file. as_file ( ) , & path) . unwrap ( ) ;
1506
1509
let ( ) = test ( parser_mmap) ;
1507
1510
1508
- let parser_io = ElfParser :: open_file_io ( file. into_file ( ) , & path) ;
1511
+ let parser_io = ElfParser :: from_file_io ( file. into_file ( ) , & path) ;
1509
1512
let ( ) = test ( parser_io) ;
1510
1513
}
1511
1514
@@ -1708,10 +1711,10 @@ mod tests {
1708
1711
}
1709
1712
1710
1713
let path = file. path ( ) . to_path_buf ( ) ;
1711
- let parser_mmap = ElfParser :: open_file ( file. as_file ( ) , & path) . unwrap ( ) ;
1714
+ let parser_mmap = ElfParser :: from_file ( file. as_file ( ) , & path) . unwrap ( ) ;
1712
1715
let ( ) = test ( parser_mmap) ;
1713
1716
1714
- let parser_io = ElfParser :: open_file_io ( file. into_file ( ) , & path) ;
1717
+ let parser_io = ElfParser :: from_file_io ( file. into_file ( ) , & path) ;
1715
1718
let ( ) = test ( parser_io) ;
1716
1719
}
1717
1720
0 commit comments