mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
// Jackson Coxson
|
|
|
|
#ifndef IDEVICE_PAIRING_FILE
|
|
#define IDEVICE_PAIRING_FILE
|
|
|
|
#pragma once
|
|
|
|
#include <idevice++/ffi.hpp>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace IdeviceFFI {
|
|
struct PairingFileDeleter {
|
|
void operator()(IdevicePairingFile* p) const noexcept;
|
|
};
|
|
|
|
using PairingFilePtr = std::unique_ptr<IdevicePairingFile, PairingFileDeleter>;
|
|
|
|
class PairingFile {
|
|
public:
|
|
static std::optional<PairingFile> read(const std::string& path, FfiError& err);
|
|
static std::optional<PairingFile> from_bytes(const uint8_t* data, size_t size, FfiError& err);
|
|
|
|
~PairingFile() noexcept = default; // unique_ptr handles destruction
|
|
|
|
PairingFile(const PairingFile&) = delete;
|
|
PairingFile& operator=(const PairingFile&) = delete;
|
|
|
|
PairingFile(PairingFile&&) noexcept = default; // move is correct by default
|
|
PairingFile& operator=(PairingFile&&) noexcept = default;
|
|
|
|
std::optional<std::vector<uint8_t>> serialize(FfiError& err) const;
|
|
|
|
explicit PairingFile(IdevicePairingFile* ptr) noexcept : ptr_(ptr) {}
|
|
IdevicePairingFile* raw() const noexcept { return ptr_.get(); }
|
|
IdevicePairingFile* release() noexcept { return ptr_.release(); }
|
|
|
|
private:
|
|
PairingFilePtr ptr_{}; // owns the handle
|
|
};
|
|
|
|
} // namespace IdeviceFFI
|
|
#endif
|