pub struct SharedHandle(/* private fields */);Expand description
A shared owner of a Windows handle: an OwnedHandle behind a reference count.
Cloning is cheap and shares the one handle; the handle closes when the last clone drops. See the crate documentation for what it does and does not do.
Implementations§
Sourcepub fn new(handle: OwnedHandle) -> SharedHandle
pub fn new(handle: OwnedHandle) -> SharedHandle
Take ownership of handle, as the first of its holders.
Sourcepub fn same_handle(&self, other: &SharedHandle) -> bool
pub fn same_handle(&self, other: &SharedHandle) -> bool
Whether self and other share one handle – that is, whether one is a clone of the
other, directly or not.
Two handles opened separately on the same file are not the same handle, even though they name the same file.
Sourcepub fn try_into_owned(self) -> Result<OwnedHandle, SharedHandle>
pub fn try_into_owned(self) -> Result<OwnedHandle, SharedHandle>
The handle, as an OwnedHandle, if self is its only holder.
§Errors
If any clone still holds the handle, returns self unchanged, so nothing is lost and the
caller can try again once the others have dropped.
Trait Implementations§
Source§fn as_handle(&self) -> BorrowedHandle<'_>
fn as_handle(&self) -> BorrowedHandle<'_>
Borrows the handle. Read more
Source§fn clone(&self) -> SharedHandle
fn clone(&self) -> SharedHandle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§type Guard = SharedHandle
type Guard = SharedHandle
What the ring must hold for the operation until its completion is
observed.
What keeps the file valid while the operation runs. Read more
Source§fn as_file_ref(&self) -> FileRef
fn as_file_ref(&self) -> FileRef
How this target addresses its file.
Source§fn guard(&self) -> <SharedHandle as FileTarget>::Guard
fn guard(&self) -> <SharedHandle as FileTarget>::Guard
Produce the value the ring will hold for the operation’s
duration.
Source§fn from(file: File) -> SharedHandle
fn from(file: File) -> SharedHandle
Converts to this type from the input type.
Source§fn from(handle: OwnedHandle) -> SharedHandle
fn from(handle: OwnedHandle) -> SharedHandle
Converts to this type from the input type.
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more