[tipc] Expose Handle::from_raw in TIPC rust
Background:
We sometimes, in user code, need to create a handle from a raw file
dezcriptor that is passed to us from C. Therfore, we need to expose the
`from_raw` function as public.
New Stuff:
* `from_raw` is now fully public, added docs
Bug: 314013565
Change-Id: I33fffe3cd6153bba1ad646f8e56fc93177b2e4b2
Signed-off-by: Ross Kettleson <kettro@google.com>
diff --git a/lib/tipc/rust/src/handle.rs b/lib/tipc/rust/src/handle.rs
index 01130af..b99389d 100644
--- a/lib/tipc/rust/src/handle.rs
+++ b/lib/tipc/rust/src/handle.rs
@@ -98,7 +98,11 @@
Self::from_raw(rc.try_into().or(Err(TipcError::InvalidHandle))?)
}
- pub(crate) fn from_raw(fd: i32) -> crate::Result<Self> {
+ /// Construct a Handle from a raw file descriptor
+ ///
+ /// Conditionally creates a Handle from the return value of a C FFI function.
+ /// If the integer value is < 0, then we will refuse to create the Handle.
+ pub fn from_raw(fd: i32) -> crate::Result<Self> {
if fd < 0 {
Err(TipcError::from_uapi(fd as c_long))
} else {