Idevice::from_fd only on unix

This commit is contained in:
Jackson Coxson
2025-10-23 09:52:51 -06:00
parent a297eed156
commit 20f00e38dd
3 changed files with 5 additions and 0 deletions

View File

@@ -32,7 +32,9 @@ using IdevicePtr = std::unique_ptr<IdeviceHandle, FnDeleter<IdeviceHandle, idevi
class Idevice { class Idevice {
public: public:
static Result<Idevice, FfiError> create(IdeviceSocketHandle* socket, const std::string& label); static Result<Idevice, FfiError> create(IdeviceSocketHandle* socket, const std::string& label);
#if defined(__unix__) || defined(__APPLE__)
static Result<Idevice, FfiError> from_fd(int fd, const std::string& label); static Result<Idevice, FfiError> from_fd(int fd, const std::string& label);
#endif
static Result<Idevice, FfiError> static Result<Idevice, FfiError>
create_tcp(const sockaddr* addr, socklen_t addr_len, const std::string& label); create_tcp(const sockaddr* addr, socklen_t addr_len, const std::string& label);

View File

@@ -13,6 +13,7 @@ Result<Idevice, FfiError> Idevice::create(IdeviceSocketHandle* socket, const std
return Ok(Idevice(h)); return Ok(Idevice(h));
} }
#if defined(__unix__) || defined(__APPLE__)
Result<Idevice, FfiError> Idevice::from_fd(int fd, const std::string& label) { Result<Idevice, FfiError> Idevice::from_fd(int fd, const std::string& label) {
IdeviceHandle* h = nullptr; IdeviceHandle* h = nullptr;
FfiError e(idevice_from_fd(fd, label.c_str(), &h)); FfiError e(idevice_from_fd(fd, label.c_str(), &h));
@@ -21,6 +22,7 @@ Result<Idevice, FfiError> Idevice::from_fd(int fd, const std::string& label) {
} }
return Ok(Idevice(h)); return Ok(Idevice(h));
} }
#endif
Result<Idevice, FfiError> Result<Idevice, FfiError>
Idevice::create_tcp(const sockaddr* addr, socklen_t addr_len, const std::string& label) { Idevice::create_tcp(const sockaddr* addr, socklen_t addr_len, const std::string& label) {

View File

@@ -128,6 +128,7 @@ pub unsafe extern "C" fn idevice_new(
/// # Safety /// # Safety
/// The socket FD must be valid. /// The socket FD must be valid.
/// The pointers must be valid and non-null. /// The pointers must be valid and non-null.
#[cfg(unix)]
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
pub unsafe extern "C" fn idevice_from_fd( pub unsafe extern "C" fn idevice_from_fd(
fd: i32, fd: i32,