@@ -624,20 +624,20 @@ impl File {
624
624
self . inner . datasync ( )
625
625
}
626
626
627
- /// Acquire an exclusive advisory lock on the file. Blocks until the lock can be acquired.
627
+ /// Acquire an exclusive lock on the file. Blocks until the lock can be acquired.
628
628
///
629
- /// This acquires an exclusive advisory lock; no other file handle to this file may acquire
630
- /// another lock.
629
+ /// This acquires an exclusive lock; no other file handle to this file may acquire another lock.
631
630
///
632
- /// If this file handle/descriptor, or a clone of it, already holds an advisory lock the exact
633
- /// behavior is unspecified and platform dependent, including the possibility that it will
634
- /// deadlock. However, if this method returns, then an exclusive lock is held.
631
+ /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
632
+ /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
633
+ /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
634
+ /// cause non-lockholders to block.
635
635
///
636
- /// If the file not open for writing, it is unspecified whether this function returns an error.
636
+ /// If this file handle/descriptor, or a clone of it, already holds an lock the exact behavior
637
+ /// is unspecified and platform dependent, including the possibility that it will deadlock.
638
+ /// However, if this method returns, then an exclusive lock is held.
637
639
///
638
- /// Note, this is an advisory lock meant to interact with [`lock_shared`], [`try_lock`],
639
- /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
640
- /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
640
+ /// If the file not open for writing, it is unspecified whether this function returns an error.
641
641
///
642
642
/// The lock will be released when this file (along with any other file descriptors/handles
643
643
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -648,8 +648,12 @@ impl File {
648
648
/// and the `LockFileEx` function on Windows with the `LOCKFILE_EXCLUSIVE_LOCK` flag. Note that,
649
649
/// this [may change in the future][changes].
650
650
///
651
+ /// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
652
+ /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
653
+ ///
651
654
/// [changes]: io#platform-specific-behavior
652
655
///
656
+ /// [`lock`]: File::lock
653
657
/// [`lock_shared`]: File::lock_shared
654
658
/// [`try_lock`]: File::try_lock
655
659
/// [`try_lock_shared`]: File::try_lock_shared
@@ -674,18 +678,19 @@ impl File {
674
678
self . inner . lock ( )
675
679
}
676
680
677
- /// Acquire a shared (non-exclusive) advisory lock on the file. Blocks until the lock can be acquired.
681
+ /// Acquire a shared (non-exclusive) lock on the file. Blocks until the lock can be acquired.
678
682
///
679
- /// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but
680
- /// none may hold an exclusive lock at the same time.
683
+ /// This acquires a shared lock; more than one file handle may hold a shared lock, but none may
684
+ /// hold an exclusive lock at the same time.
681
685
///
682
- /// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact
683
- /// behavior is unspecified and platform dependent, including the possibility that it will
684
- /// deadlock. However, if this method returns, then a shared lock is held.
686
+ /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
687
+ /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
688
+ /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
689
+ /// cause non-lockholders to block.
685
690
///
686
- /// Note, this is an advisory lock meant to interact with [` lock`], [`try_lock`],
687
- /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
688
- /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block .
691
+ /// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior
692
+ /// is unspecified and platform dependent, including the possibility that it will deadlock.
693
+ /// However, if this method returns, then a shared lock is held .
689
694
///
690
695
/// The lock will be released when this file (along with any other file descriptors/handles
691
696
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -696,9 +701,13 @@ impl File {
696
701
/// and the `LockFileEx` function on Windows. Note that, this
697
702
/// [may change in the future][changes].
698
703
///
704
+ /// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
705
+ /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
706
+ ///
699
707
/// [changes]: io#platform-specific-behavior
700
708
///
701
709
/// [`lock`]: File::lock
710
+ /// [`lock_shared`]: File::lock_shared
702
711
/// [`try_lock`]: File::try_lock
703
712
/// [`try_lock_shared`]: File::try_lock_shared
704
713
/// [`unlock`]: File::unlock
@@ -722,24 +731,23 @@ impl File {
722
731
self . inner . lock_shared ( )
723
732
}
724
733
725
- /// Try to acquire an exclusive advisory lock on the file.
734
+ /// Try to acquire an exclusive lock on the file.
726
735
///
727
736
/// Returns `Ok(false)` if a different lock is already held on this file (via another
728
737
/// handle/descriptor).
729
738
///
730
- /// This acquires an exclusive advisory lock; no other file handle to this file may acquire
731
- /// another lock.
739
+ /// This acquires an exclusive lock; no other file handle to this file may acquire another lock.
732
740
///
733
- /// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact
734
- /// behavior is unspecified and platform dependent, including the possibility that it will
735
- /// deadlock. However, if this method returns `Ok(true)`, then it has acquired an exclusive
736
- /// lock .
741
+ /// This lock may be advisory or mandatory. This lock is meant to interact with [` lock`],
742
+ /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
743
+ /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
744
+ /// cause non-lockholders to block .
737
745
///
738
- /// If the file not open for writing, it is unspecified whether this function returns an error.
746
+ /// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior
747
+ /// is unspecified and platform dependent, including the possibility that it will deadlock.
748
+ /// However, if this method returns `Ok(true)`, then it has acquired an exclusive lock.
739
749
///
740
- /// Note, this is an advisory lock meant to interact with [`lock`], [`lock_shared`],
741
- /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
742
- /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
750
+ /// If the file not open for writing, it is unspecified whether this function returns an error.
743
751
///
744
752
/// The lock will be released when this file (along with any other file descriptors/handles
745
753
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -751,10 +759,14 @@ impl File {
751
759
/// and `LOCKFILE_FAIL_IMMEDIATELY` flags. Note that, this
752
760
/// [may change in the future][changes].
753
761
///
762
+ /// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
763
+ /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
764
+ ///
754
765
/// [changes]: io#platform-specific-behavior
755
766
///
756
767
/// [`lock`]: File::lock
757
768
/// [`lock_shared`]: File::lock_shared
769
+ /// [`try_lock`]: File::try_lock
758
770
/// [`try_lock_shared`]: File::try_lock_shared
759
771
/// [`unlock`]: File::unlock
760
772
/// [`read`]: Read::read
@@ -777,22 +789,23 @@ impl File {
777
789
self . inner . try_lock ( )
778
790
}
779
791
780
- /// Try to acquire a shared (non-exclusive) advisory lock on the file.
792
+ /// Try to acquire a shared (non-exclusive) lock on the file.
781
793
///
782
794
/// Returns `Ok(false)` if an exclusive lock is already held on this file (via another
783
795
/// handle/descriptor).
784
796
///
785
- /// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but
786
- /// none may hold an exclusive lock at the same time.
797
+ /// This acquires a shared lock; more than one file handle may hold a shared lock, but none may
798
+ /// hold an exclusive lock at the same time.
787
799
///
788
- /// If this file handle, or a clone of it, already holds an advisory lock, the exact behavior is
800
+ /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
801
+ /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
802
+ /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
803
+ /// cause non-lockholders to block.
804
+ ///
805
+ /// If this file handle, or a clone of it, already holds an lock, the exact behavior is
789
806
/// unspecified and platform dependent, including the possibility that it will deadlock.
790
807
/// However, if this method returns `Ok(true)`, then it has acquired a shared lock.
791
808
///
792
- /// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`],
793
- /// [`try_lock`], and [`unlock`]. Its interactions with other methods, such as [`read`]
794
- /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
795
- ///
796
809
/// The lock will be released when this file (along with any other file descriptors/handles
797
810
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
798
811
///
@@ -803,11 +816,15 @@ impl File {
803
816
/// `LOCKFILE_FAIL_IMMEDIATELY` flag. Note that, this
804
817
/// [may change in the future][changes].
805
818
///
819
+ /// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
820
+ /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
821
+ ///
806
822
/// [changes]: io#platform-specific-behavior
807
823
///
808
824
/// [`lock`]: File::lock
809
825
/// [`lock_shared`]: File::lock_shared
810
826
/// [`try_lock`]: File::try_lock
827
+ /// [`try_lock_shared`]: File::try_lock_shared
811
828
/// [`unlock`]: File::unlock
812
829
/// [`read`]: Read::read
813
830
/// [`write`]: Write::write
@@ -844,6 +861,9 @@ impl File {
844
861
/// and the `UnlockFile` function on Windows. Note that, this
845
862
/// [may change in the future][changes].
846
863
///
864
+ /// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
865
+ /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
866
+ ///
847
867
/// [changes]: io#platform-specific-behavior
848
868
///
849
869
/// # Examples
0 commit comments