@@ -325,6 +325,7 @@ impl CGGTTS {
325
325
}
326
326
327
327
/// Parse [CGGTTS] from a local file.
328
+ /// This will fail on CRC mismatches.
328
329
/// Advanced CGGTTS files generated from modern GNSS
329
330
/// receivers may describe the ionospheric delay compensation:
330
331
/// ```
@@ -342,19 +343,30 @@ impl CGGTTS {
342
343
///```
343
344
pub fn from_file < P : AsRef < Path > > ( path : P ) -> Result < Self , ParsingError > {
344
345
let fd = File :: open ( path) . unwrap_or_else ( |e| panic ! ( "File open error: {}" , e) ) ;
346
+ let mut reader = BufReader :: new ( fd) ;
347
+ Self :: parse ( & mut reader, false )
348
+ }
345
349
350
+ /// Parse [CGGTTS] from a local file, but tolerates CRC errors (check your logs).
351
+ /// See [Self::from_file] for more information.
352
+ pub fn from_file_infaillible_crc < P : AsRef < Path > > ( path : P ) -> Result < Self , ParsingError > {
353
+ let fd = File :: open ( path) . unwrap_or_else ( |e| panic ! ( "File open error: {}" , e) ) ;
346
354
let mut reader = BufReader :: new ( fd) ;
347
- Self :: parse ( & mut reader)
355
+ Self :: parse ( & mut reader, true )
348
356
}
349
357
350
358
/// Parse a new [CGGTTS] from any [Read]able interface.
351
359
/// This will fail on:
352
- /// - Any critical standard violation
353
- /// - If file revision is not 2E (latest)
354
- /// - If following [Track]s do not contain the same [Constellation]
355
- pub fn parse < R : Read > ( reader : & mut BufReader < R > ) -> Result < Self , ParsingError > {
360
+ /// - any critical standard violation
361
+ /// - CRC mismatched (if not tolerated)
362
+ /// - file revision is not 2E (latest)
363
+ /// - [Track]s do not contain the same [Constellation]
364
+ pub fn parse < R : Read > (
365
+ reader : & mut BufReader < R > ,
366
+ tolerate_crc_error : bool ,
367
+ ) -> Result < Self , ParsingError > {
356
368
// Parse header section
357
- let header = Header :: parse ( reader) ?;
369
+ let header = Header :: parse ( reader, tolerate_crc_error ) ?;
358
370
359
371
// Parse tracks:
360
372
// consumes all remaning lines and attempt parsing on each new line.
@@ -390,6 +402,7 @@ impl CGGTTS {
390
402
}
391
403
392
404
/// Parse [CGGTTS] from gzip compressed local path.
405
+ /// CRC errors will not be tolerated.
393
406
#[ cfg( feature = "flate2" ) ]
394
407
#[ cfg_attr( docsrs, doc( cfg( feature = "flate2" ) ) ) ]
395
408
pub fn from_gzip_file < P : AsRef < Path > > ( path : P ) -> Result < Self , ParsingError > {
@@ -398,7 +411,19 @@ impl CGGTTS {
398
411
let reader = GzDecoder :: new ( fd) ;
399
412
400
413
let mut reader = BufReader :: new ( reader) ;
401
- Self :: parse ( & mut reader)
414
+ Self :: parse ( & mut reader, false )
415
+ }
416
+
417
+ /// Parse [CGGTTS] from gzip compressed local path, but tolerates CRC errors.
418
+ #[ cfg( feature = "flate2" ) ]
419
+ #[ cfg_attr( docsrs, doc( cfg( feature = "flate2" ) ) ) ]
420
+ pub fn from_gzip_file_infaillible_crc < P : AsRef < Path > > ( path : P ) -> Result < Self , ParsingError > {
421
+ let fd = File :: open ( path) . unwrap_or_else ( |e| panic ! ( "File open error: {}" , e) ) ;
422
+
423
+ let reader = GzDecoder :: new ( fd) ;
424
+
425
+ let mut reader = BufReader :: new ( reader) ;
426
+ Self :: parse ( & mut reader, true )
402
427
}
403
428
404
429
/// Format [CGGTTS] following standard specifications.
0 commit comments