@@ -465,14 +465,20 @@ impl File {
465
465
OpenOptions :: new ( )
466
466
}
467
467
468
- /// Attempts to sync all OS-internal metadata to disk.
468
+ /// Attempts to sync all OS-internal file content and metadata to disk.
469
469
///
470
470
/// This function will attempt to ensure that all in-memory data reaches the
471
471
/// filesystem before returning.
472
472
///
473
473
/// This can be used to handle errors that would otherwise only be caught
474
- /// when the `File` is closed. Dropping a file will ignore errors in
475
- /// synchronizing this in-memory data.
474
+ /// when the `File` is closed, as dropping a `File` will ignore all errors.
475
+ /// Note, however, that `sync_all` is generally more expensive than closing
476
+ /// a file by dropping it, because the latter is not required to block until
477
+ /// the data has been written to the filesystem.
478
+ ///
479
+ /// If synchronizing the metadata is not required, use [`sync_data`] instead.
480
+ ///
481
+ /// [`sync_data`]: File::sync_data
476
482
///
477
483
/// # Examples
478
484
///
@@ -489,6 +495,7 @@ impl File {
489
495
/// }
490
496
/// ```
491
497
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
498
+ #[ doc( alias = "fsync" ) ]
492
499
pub fn sync_all ( & self ) -> io:: Result < ( ) > {
493
500
self . inner . fsync ( )
494
501
}
@@ -520,6 +527,7 @@ impl File {
520
527
/// }
521
528
/// ```
522
529
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
530
+ #[ doc( alias = "fdatasync" ) ]
523
531
pub fn sync_data ( & self ) -> io:: Result < ( ) > {
524
532
self . inner . datasync ( )
525
533
}
0 commit comments