Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up docs for File::sync_* #123756

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,20 @@ impl File {
OpenOptions::new()
}

/// Attempts to sync all OS-internal metadata to disk.
/// Attempts to sync all OS-internal file content and metadata to disk.
///
/// This function will attempt to ensure that all in-memory data reaches the
/// filesystem before returning.
///
/// This can be used to handle errors that would otherwise only be caught
/// when the `File` is closed. Dropping a file will ignore errors in
/// synchronizing this in-memory data.
/// when the `File` is closed, as dropping a `File` will ignore all errors.
/// Note, however, that `sync_all` is generally more expensive than closing
/// a file by dropping it, because the latter is not required to block until
/// the data has been written to the filesystem.
///
/// If synchronizing the metadata is not required, use [`sync_data`] instead.
///
/// [`sync_data`]: File::sync_data
///
/// # Examples
///
Expand All @@ -489,6 +495,7 @@ impl File {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(alias = "fsync")]
pub fn sync_all(&self) -> io::Result<()> {
self.inner.fsync()
}
Expand Down Expand Up @@ -520,6 +527,7 @@ impl File {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(alias = "fdatasync")]
pub fn sync_data(&self) -> io::Result<()> {
self.inner.datasync()
}
Expand Down
Loading