From 6bb6d49967ec8e80f7b869e2bc09a75e5b7c6526 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:28:53 -0400 Subject: [PATCH 1/2] Add IntoRawHandle impl for FFI ownership transfer --- src/windows/com.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/windows/com.rs b/src/windows/com.rs index 0985bf5d..20e243fb 100644 --- a/src/windows/com.rs +++ b/src/windows/com.rs @@ -176,6 +176,14 @@ impl FromRawHandle for COMPort { } } +impl IntoRawHandle for COMPort { + fn into_raw_handle(self) -> RawHandle { + let Self { handle, .. } = self; + + handle as RawHandle + } +} + impl io::Read for COMPort { fn read(&mut self, buf: &mut [u8]) -> io::Result { let mut len: DWORD = 0; From 25787e49e1933a42ffed723b10f77279ec18f8c5 Mon Sep 17 00:00:00 2001 From: Ross Smyth <18294397+RossSmyth@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:14:44 -0400 Subject: [PATCH 2/2] Add IntoHandle impl to changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae086834..3407de07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] ### Added + +* Add `IntoRawHandle` implementation for `COMPort` + [#199](https://github.com/serialport/serialport-rs/pull/199) + ### Changed ### Fixed ### Removed