tipc-rust: Implement IntoRawFd on Handle
The current pattern for transferring ownership of a raw handle_t is to
call Handle::as_raw_fd and then mem::forget the Handle. This is error
prone because it does not prevent the handle from being used after the
call to mem::forget. It's also not ideal that we leak the resource.
This change implements IntoRawFd which allows for extracting a RawFd
from a Handle while also:
- consuming the Handle so it can't be used after calling into_raw_fd()
- ensuring that trusty_sys::close is not called twice on drop()
- aligning with the semantic expectations of transferring ownership of a
RawFd in Rust
Bug: 395847127
Test: trusty/vendor/google/aosp/scripts/build.py \
qemu-generic-arm64-gicv3-test-debug \
--test="boot-test:com.android.trusty.rust.tipc.test"
Change-Id: Ibd4b452090bfe0080214988c6c2cb8121c09685a
1 file changed