summaryrefslogtreecommitdiffstats
path: root/vendor/fd-lock/src/lib.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/fd-lock/src/lib.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/fd-lock/src/lib.rs')
-rw-r--r--vendor/fd-lock/src/lib.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/vendor/fd-lock/src/lib.rs b/vendor/fd-lock/src/lib.rs
new file mode 100644
index 000000000..9d3d6192b
--- /dev/null
+++ b/vendor/fd-lock/src/lib.rs
@@ -0,0 +1,43 @@
+//! Advisory reader-writer locks for files.
+//!
+//! # Notes on Advisory Locks
+//!
+//! "advisory locks" are locks which programs must opt-in to adhere to. This
+//! means that they can be used to coordinate file access, but not prevent
+//! access. Use this to coordinate file access between multiple instances of the
+//! same program. But do not use this to prevent actors from accessing or
+//! modifying files.
+//!
+//! # Example
+//!
+//! ```no_run
+//! # use std::io;
+//! use std::io::prelude::*;
+//! use std::fs::File;
+//! use fd_lock::RwLock;
+//!
+//! # fn main() -> io::Result<()> {
+//! // Lock a file and write to it.
+//! let mut f = RwLock::new(File::open("foo.txt")?);
+//! write!(f.write()?, "chashu cat")?;
+//!
+//! // A lock can also be held across multiple operations.
+//! let mut f = f.write()?;
+//! write!(f, "nori cat")?;
+//! write!(f, "bird!")?;
+//! # Ok(()) }
+//! ```
+
+#![forbid(future_incompatible)]
+#![deny(missing_debug_implementations, nonstandard_style)]
+#![cfg_attr(doc, warn(missing_docs, rustdoc::missing_doc_code_examples))]
+
+mod read_guard;
+mod rw_lock;
+mod write_guard;
+
+pub(crate) mod sys;
+
+pub use read_guard::RwLockReadGuard;
+pub use rw_lock::RwLock;
+pub use write_guard::RwLockWriteGuard;