mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Implement creating an Idevice with a file descriptor
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user