Skip to main content

SharedHandle

Struct SharedHandle 

Source
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§

Source§

impl SharedHandle

Source

pub fn new(handle: OwnedHandle) -> SharedHandle

Take ownership of handle, as the first of its holders.

Source

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.

Source

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§

impl AsHandle for SharedHandle

Source§

fn as_handle(&self) -> BorrowedHandle<'_>

Borrows the handle. Read more
Source§

impl AsRawHandle for SharedHandle

Source§

fn as_raw_handle(&self) -> *mut c_void

Extracts the raw handle. Read more
Source§

impl Clone for SharedHandle

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for SharedHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl FileTarget for SharedHandle

A SharedHandle is how a caller gives this crate a file it does not have to prove outlives every operation pushed against it (M8; D-82). One handle is legitimately the target of many concurrent pushes, so what must survive until every one of them completes is a reference, not sole ownership. Every safe push (e.g. Batch::read_owned, as opposed to its _raw sibling) clones it into the same inventory entry that tracks the operation’s own payload, so the handle survives until the ring returns that entry at its pop (D-4), whatever the caller does with its own clone.

Source§

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

How this target addresses its file.
Source§

fn guard(&self) -> <SharedHandle as FileTarget>::Guard

Produce the value the ring will hold for the operation’s duration.
Source§

impl From<File> for SharedHandle

Source§

fn from(file: File) -> SharedHandle

Converts to this type from the input type.
Source§

impl From<OwnedHandle> for SharedHandle

Source§

fn from(handle: OwnedHandle) -> SharedHandle

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.