@@ -20,8 +20,6 @@ use std::fs::File;
2020use std:: io:: { BufReader , Cursor , Read , Seek , SeekFrom } ;
2121use std:: path:: Path ;
2222
23- const MAX_JUNK_BYTES : usize = 1024 ;
24-
2523/// Options to control how Lofty parses a file
2624#[ derive( Copy , Clone , Debug , Ord , PartialOrd , Eq , PartialEq ) ]
2725#[ non_exhaustive]
@@ -51,6 +49,12 @@ impl Default for ParseOptions {
5149}
5250
5351impl ParseOptions {
52+ /// Default parsing mode
53+ pub const DEFAULT_PARSING_MODE : ParsingMode = ParsingMode :: BestAttempt ;
54+
55+ /// Default number of junk bytes to read
56+ pub const DEFAULT_MAX_JUNK_BYTES : usize = 1024 ;
57+
5458 /// Creates a new `ParseOptions`, alias for `Default` implementation
5559 ///
5660 /// See also: [`ParseOptions::default`]
@@ -67,8 +71,8 @@ impl ParseOptions {
6771 Self {
6872 read_properties : true ,
6973 use_custom_resolvers : true ,
70- parsing_mode : ParsingMode :: BestAttempt ,
71- max_junk_bytes : MAX_JUNK_BYTES ,
74+ parsing_mode : Self :: DEFAULT_PARSING_MODE ,
75+ max_junk_bytes : Self :: DEFAULT_MAX_JUNK_BYTES ,
7276 }
7377 }
7478
@@ -433,7 +437,9 @@ impl<R: Read + Seek> Probe<R> {
433437 ///
434438 /// On success, the file type will be replaced
435439 ///
436- /// NOTE: This is influenced by `ParseOptions`, be sure to set it with `Probe::options()` prior to calling this.
440+ /// NOTE: The chance for succeeding is influenced by [`ParseOptions`].
441+ /// Be sure to set it with [`Probe::options()`] prior to calling this method.
442+ /// Some files may require more than the default [`ParseOptions::DEFAULT_MAX_JUNK_BYTES`] to be detected successfully.
437443 ///
438444 /// # Errors
439445 ///
@@ -459,7 +465,9 @@ impl<R: Read + Seek> Probe<R> {
459465 pub fn guess_file_type ( mut self ) -> std:: io:: Result < Self > {
460466 let max_junk_bytes = self
461467 . options
462- . map_or ( MAX_JUNK_BYTES , |options| options. max_junk_bytes ) ;
468+ . map_or ( ParseOptions :: DEFAULT_MAX_JUNK_BYTES , |options| {
469+ options. max_junk_bytes
470+ } ) ;
463471
464472 let f_ty = self . guess_inner ( max_junk_bytes) ?;
465473 self . f_ty = f_ty. or ( self . f_ty ) ;
0 commit comments