Implement creating an Idevice with a file descriptor

This commit is contained in:
Jackson Coxson
2025-10-22 10:26:57 -06:00
parent 7805f943af
commit 0ccec70ed8
3 changed files with 51 additions and 0 deletions

View File

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

View File

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