Struct std::os::windows::io::BorrowedHandle[−][src]

#[repr(transparent)]
pub struct BorrowedHandle<'handle> { /* fields omitted */ }
🔬 This is a nightly-only experimental API. (io_safety #87074)
This is supported on Windows only.
Expand description

借来的句柄。

它有一个生命周期参数,将它与拥有句柄的事物的生命周期联系起来。

这使用 repr(transparent) 并具有主机句柄的表示形式,因此它可以在 FFI 中将句柄作为参数传递的地方使用,它不会被捕获或消耗。

请注意,它可能具有值 INVALID_HANDLE_VALUE (-1),有时这是一个有效的句柄值。有关完整故事,请参见 这个。

并且,它可能具有值 NULL (0),当控制台与进程分离或使用 windows_subsystem 时,可能会发生这种情况。

Implementations

🔬 This is a nightly-only experimental API. (io_safety #87074)

返回一个 BorrowedHandle 持有给定的原始句柄。

Safety

handle 指向的资源必须是有效的打开句柄,它必须在返回的 BorrowedHandle 期间保持打开状态。

请注意,它可能具有值 INVALID_HANDLE_VALUE (-1),有时这是一个有效的句柄值。有关完整故事,请参见 这个。

并且,它可能具有值 NULL (0),当控制台与进程分离或使用 windows_subsystem 时,可能会发生这种情况。

Trait Implementations

🔬 This is a nightly-only experimental API. (io_safety #87074)

借用句柄。 Read more

提取原始句柄,无需任何所有权。

返回值的副本。 Read more

从 source 执行复制分配。 Read more

使用给定的格式化程序格式化该值。 Read more

Auto Trait Implementations

Blanket Implementations

获取 self 的 TypeId。 Read more

从拥有的值中一成不变地借用。 Read more

从拥有的值中借用。 Read more

执行转换。

执行转换。

获得所有权后的结果类型。

从借用的数据创建拥有的数据,通常是通过克隆。 Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into #41263)

使用借来的数据来替换拥有的数据,通常是通过克隆。 Read more

发生转换错误时返回的类型。

执行转换。

发生转换错误时返回的类型。

执行转换。