Remove cpp 17 features and implement Rust into CPP

This commit is contained in:
Jackson Coxson
2025-08-29 14:19:28 -06:00
parent 4fde7cf06b
commit 1169408da1
41 changed files with 1638 additions and 1212 deletions

View File

@@ -9,7 +9,6 @@
#include <idevice++/readwrite.hpp>
#include <idevice++/rsd.hpp>
#include <memory>
#include <optional>
#include <string>
#include <vector>
@@ -19,17 +18,17 @@ using AppServicePtr =
std::unique_ptr<AppServiceHandle, FnDeleter<AppServiceHandle, app_service_free>>;
struct AppInfo {
bool is_removable{};
std::string name;
bool is_first_party{};
std::string path;
std::string bundle_identifier;
bool is_developer_app{};
std::optional<std::string> bundle_version;
bool is_internal{};
bool is_hidden{};
bool is_app_clip{};
std::optional<std::string> version;
bool is_removable{};
std::string name;
bool is_first_party{};
std::string path;
std::string bundle_identifier;
bool is_developer_app{};
Option<std::string> bundle_version;
bool is_internal{};
bool is_hidden{};
bool is_app_clip{};
Option<std::string> version;
};
struct LaunchResponse {
@@ -40,15 +39,15 @@ struct LaunchResponse {
};
struct ProcessToken {
uint32_t pid{};
std::optional<std::string> executable_url;
uint32_t pid{};
Option<std::string> executable_url;
};
struct SignalResponse {
uint32_t pid{};
std::optional<std::string> executable_url;
uint64_t device_timestamp_ms{};
uint32_t signal{};
uint32_t pid{};
Option<std::string> executable_url;
uint64_t device_timestamp_ms{};
uint32_t signal{};
};
struct IconData {
@@ -62,41 +61,34 @@ struct IconData {
class AppService {
public:
// Factory: connect via RSD (borrows adapter & handshake)
static std::optional<AppService>
connect_rsd(Adapter& adapter, RsdHandshake& rsd, FfiError& err);
static Result<AppService, FfiError> connect_rsd(Adapter& adapter, RsdHandshake& rsd);
// Factory: from socket Box<dyn ReadWrite> (consumes it).
static std::optional<AppService> from_readwrite_ptr(ReadWriteOpaque* consumed, FfiError& err);
static Result<AppService, FfiError> from_readwrite_ptr(ReadWriteOpaque* consumed);
// nice ergonomic overload: consume a C++ ReadWrite by releasing it
static std::optional<AppService> from_readwrite(ReadWrite&& rw, FfiError& err);
static Result<AppService, FfiError> from_readwrite(ReadWrite&& rw);
// API
std::optional<std::vector<AppInfo>> list_apps(bool app_clips,
bool removable,
bool hidden,
bool internal,
bool default_apps,
FfiError& err) const;
Result<std::vector<AppInfo>, FfiError>
list_apps(bool app_clips, bool removable, bool hidden, bool internal, bool default_apps) const;
std::optional<LaunchResponse> launch(const std::string& bundle_id,
const std::vector<std::string>& argv,
bool kill_existing,
bool start_suspended,
FfiError& err);
Result<LaunchResponse, FfiError> launch(const std::string& bundle_id,
const std::vector<std::string>& argv,
bool kill_existing,
bool start_suspended);
std::optional<std::vector<ProcessToken>> list_processes(FfiError& err) const;
Result<std::vector<ProcessToken>, FfiError> list_processes() const;
bool uninstall(const std::string& bundle_id, FfiError& err);
Result<void, FfiError> uninstall(const std::string& bundle_id);
std::optional<SignalResponse> send_signal(uint32_t pid, uint32_t signal, FfiError& err);
Result<SignalResponse, FfiError> send_signal(uint32_t pid, uint32_t signal);
std::optional<IconData> fetch_icon(const std::string& bundle_id,
float width,
float height,
float scale,
bool allow_placeholder,
FfiError& err);
Result<IconData, FfiError> fetch_icon(const std::string& bundle_id,
float width,
float height,
float scale,
bool allow_placeholder);
// RAII / moves
~AppService() noexcept = default;