From 25882e0e7273b9ee776a1ffdf88fcd3ff6540c52 Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 06:44:47 -0700 Subject: [PATCH 01/13] docs(go-binding): define failure model and acceptance contract --- .../active/2026-10-07-go-binding.md | 59 +++++++++++++++++++ docs/exec-plans/active/index.md | 1 + 2 files changed, 60 insertions(+) create mode 100644 docs/exec-plans/active/2026-10-07-go-binding.md diff --git a/docs/exec-plans/active/2026-10-07-go-binding.md b/docs/exec-plans/active/2026-10-07-go-binding.md new file mode 100644 index 00000000..bb282a09 --- /dev/null +++ b/docs/exec-plans/active/2026-10-07-go-binding.md @@ -0,0 +1,59 @@ +# Go binding 基础 + +状态:失败模型与验收契约已先行;实现按本文顺序分片。关联研究:t-0196。基线:main `e86f94cebcec46c1b3a6f49f88cce7a833777640`。 + +## 目标与边界 + +Engine 仓库拥有一个可重复生成、可 `import` 的版本化 Go module(`bindings/go`),让后续 Go daemon 在同一进程内托管真实 Rust Engine。Rust Engine、Iroh、加密、持久化和业务流程的负责人不变;Go 只做宿主:一次 Start、调用 `uc-engine` 既有完整动作、读取事件、确定性 Close。 + +不在本片:移除或改写现有 Rust daemon、改变产品退出语义、修改移动 pin 或移动公开 API、直接授权 daemon。Go daemon 的常驻、GUI 退出存活、CLI 复用、单实例、HTTP/WS 与平台服务生命周期仍是后续计划;本片只提供其所需的 Engine 生命周期事件与能力映射(见“能力映射与未完成范围”)。 + +完整负责人:`bindings/uc-engine-uniffi`(既有薄绑定)拥有 start、命令分发、事件队列与 shutdown/join;`bindings/go/engine` 只负责 Go 侧所有权(调用与 Close 的互斥、输入校验、错误归一)。Go 不拼接底层业务流程,不依赖 Application 内部。 + +## 工具链选择 + +- UniFFI 固定 `=0.31.1`(既有)。Go 生成器采用 NordSecurity `uniffi-bindgen-go` 固定 revision `0b7fb4ceef12021bd7f790cc516fa9133e001813`(tag `v0.7.1+v0.31.0`),生成器自身 `Cargo.lock` 固定,不加入本仓 workspace,不改本仓 `Cargo.lock`。 +- 第一片不修改 Rust 源码,使被测 native 库可直接追溯到 main 提交。 +- 生成物提交入库(`go get` 不能运行生成器)。CI 重新生成并要求零差异。 +- 模板补丁:研究只改了 callback 的 `handle`。本片对所有由模板引入、且与用户方法参数名同一作用域的局部变量统一加保留前缀 `_uniffi`,并用完整组件编译覆盖;补丁文件与其 sha256 记入来源清单。MPL-2.0 许可证头与生成器 LICENSE 随生成物保留。 + +## 失败模型(实现前) + +| # | 失败 | 契约 | +|---|---|---| +| F1 | 上游原样生成器因局部变量撞名无法编译 | 原失败证据保留;补丁只通过生成器源码补丁交付,禁止手改生成后的 Go 文件;重新生成必须字节一致 | +| F2 | 补丁只修已知撞名,其他模板局部变量仍可能与用户参数同名 | 审计 VTableImpl/callback/async 模板的全部局部名;验收为完整组件编译,不称通用卫生修复 | +| F3 | 生成物与 native 库错配(版本、UniFFI contract、API checksum) | 生成包 init 的 checksum 检查必须失败即 panic;facade 另在 Open 时核对 `core_version` 与来源清单 | +| F4 | 加载了非预期的动态库(路径、替换、旧库) | facade 通过 `dladdr` 取实际加载路径,对其计算 sha256 并与来源清单比对;不一致返回 `ErrNativeMismatch`。Windows 暂不支持该校验,明确返回不支持而非静默通过 | +| F5 | 来源清单缺失或字段不符 | 校验失败即拒绝启动,不降级为未验证模式;清单含 Engine revision、`Cargo.lock` sha256、目标、profile、toolchain、features、生成器 revision 与补丁 hash、库 sha256/size | +| F6 | Go 零值枚举/必填字段转 Rust 时 panic | facade 在越界前校验所有输入枚举与必填字段,返回 `ErrInvalidInput`;不得依赖生成层 panic | +| F7 | Rust release `panic=abort`、段错误或 OOM | Go `recover` 无效,进程直接退出;契约明确声明。嵌入后宿主与 Engine 同生共死,不再有进程隔离。崩溃隔离作为 daemon 重写评审时的显式取舍,不默认嵌入更优。GUI 仍可保持为独立进程经 HTTP 连接 daemon | +| F8 | Close 与进行中的调用并发 | Close 先标记关闭,不持锁调用 `shutdown(deadline)`(这会关闭事件队列并唤醒 `next_event`),再取写锁等待在途调用排空,最后 Destroy。重复 Close 幂等;Close 后调用返回 `ErrClosed`,不 panic | +| F9 | Go `context` 取消被误当作 Rust 取消 | 只让调用方停止等待;Rust 调用继续,Close 仍等待被放弃的调用。文档与测试明确 | +| F10 | `Destroy` 被误当作 shutdown | `Destroy` 只释放引用。唯一关闭边界是 `shutdown(deadline)` 成功返回与 worker join;deadline 超时返回错误且不声称已停止,可重试 | +| F11 | 事件消费者落后 | Rust 侧容量 256,丢最旧并给出 `RefreshRequired(ConsumerLagged)`;Go 不再设第二层丢弃缓冲。消费者收到后重新查询权威状态 | +| F12 | 宿主回调重入同一 Engine 的阻塞 API 造成环形等待 | 回调只能返回能力结果;facade 文档禁止在回调内调用同一实例。E2E 用带超时的真实进程断言重入被拒绝或有界失败,不允许无限挂起 | +| F13 | 回调返回的类型化宿主错误丢失 | 往返断言 `PermissionDenied`、`Unavailable` 映射到 `BindingError` 且 `errors.Is` 成立 | +| F14 | 重启后加密 profile 不可读 | 安全存储以临时文件持久化,第二个进程用同一 profile 重启并断言同一本地设备身份 | +| F15 | 测试触碰真实 profile、钥匙串、剪贴板或网络 | 全部使用临时目录和内存/文件 host;剪贴板与文件回调返回 Unavailable;E2E 在 macOS `sandbox-exec` 的拒绝网络配置下运行,网络不可达本身即证据 | +| F16 | 日志泄露内容或秘密 | 观测只写本地文件到临时目录;E2E 在日志与 stdout/stderr 中扫描哨兵字符串,必须零命中 | +| F17 | 并发调用过载 | Engine 命令队列无界;本片不引入限流,文档声明并发调用语义,调用方负责背压 | +| F18 | 跨目标构建被当作原生验证 | 仅 macOS arm64 做本机链接与真实进程;其他目标只记录实际执行的生成/编译/link 检查,交叉编译不记通过 | +| F19 | 公共 UniFFI 表面变化破坏 Swift/Kotlin | 第一片不改 Rust 表面。任何后续新增必须加性,并运行 `bindings/uc-engine-uniffi` 契约测试 | +| F20 | 生成物许可证头丢失 | 生成包保留模板 MPL header,并随附生成器 LICENSE;检查脚本断言存在 | + +## 验收契约 + +1. 来源:`just cargo build` 的 native 库对应不可变 main 提交与干净工作区;清单记录上表 F5 全部字段。重新冻结干净来源后重建并重复关键链。 +2. 生成:固定生成器 + 补丁 → 完整 Go package;二次生成与入库内容字节一致;Go 1.24.0 与 Go 1.27.1 均编译通过。 +3. 真实进程 E2E(独立临时 profile/密钥/内存或文件 host,网络隔离)依序: + start → query(本地设备、空间状态)→ 类型化 Engine 错误 → 成功的 host 回调 → 事件(suspend/resume 触发 `StateChanged`)→ `shutdown(deadline)` 与 join → 同一 profile 重启并断言身份一致 → 最终退出码 0。 +4. 负向:释放后调用、零值枚举、重复 Close、并发调用与 Close、Close 中 `next_event`、校验和错配(篡改库)、清单缺失,各自得到明确 Go 错误而非挂起或 panic。 +5. 证据:可验证 JSON、原始日志、命令、provenance 保存在本任务 library 目录;E2E 无产品单元测试补写,失败也要保留。 +6. 门禁:`node scripts/architecture/check-engine-repository.mjs`、`check-rust-style.mjs`、`cargo fmt --check`、`git diff --check` 通过;新增检查纳入 PR Check。 + +## 能力映射与未完成范围 + +既有 `MobileEngine` 是 `uc-engine` Operation 的子集。第一片只暴露 start、`query_local_device`、`query_space_state`、`list_devices`、生命周期(suspend/resume/lifecycle_state/shutdown)与 `next_event`。其余 Desktop 需要的历史、设置、搜索、诊断、解锁与恢复、升级、LAN 兼容等能力,只能经 `uc-engine` 的 Operation 加性补入统一绑定,并同时核对 Swift/Kotlin。完整清单见研究的 `api-inventory.json`。本片不声称覆盖 Desktop 的 62 个宿主命令。 + +后续独立计划:Go daemon 的常驻与单实例、GUI 退出存活、CLI 复用、HTTP/WS、平台服务生命周期、真实 keyring/剪贴板的 Go 或复用 Rust 适配、崩溃隔离取舍评审、Linux/Windows 原生验证与签名分发。 diff --git a/docs/exec-plans/active/index.md b/docs/exec-plans/active/index.md index eef370bf..01dfe933 100644 --- a/docs/exec-plans/active/index.md +++ b/docs/exec-plans/active/index.md @@ -32,3 +32,4 @@ 计划完成时先更新稳定设计/ADR 和验收证据,再移入 `../completed/`。 - [剪贴板启动核对与宿主导入恢复](2026-10-07-clipboard-startup-recovery.md)(实施中,关联 #1886) +- [Go binding 基础](2026-10-07-go-binding.md)(失败模型与验收契约已定,实施中) From f57511a8c9221cd954c7f6d0e281127890f18f1b Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:08:31 -0700 Subject: [PATCH 02/13] feat(go-binding): add generated Go package, facade and acceptance host --- bindings/go/engine/engine.go | 304 + bindings/go/engine/errors.go | 115 + bindings/go/engine/events.go | 97 + bindings/go/engine/host.go | 103 + bindings/go/generator/PIN.env | 7 + bindings/go/generator/build-generator.sh | 48 + bindings/go/generator/generate.sh | 21 + .../go/generator/template-local-names.patch | 139 + bindings/go/go.mod | 3 + bindings/go/native/loaded_other.go | 8 + bindings/go/native/loaded_unix.go | 35 + bindings/go/native/stage-native.sh | 89 + bindings/go/native/verify.go | 142 + .../LICENSE-uniffi-bindgen-go | 373 + bindings/go/uc_engine_uniffi/link.go | 10 + .../go/uc_engine_uniffi/uc_engine_uniffi.go | 10095 ++++++++++++++++ .../go/uc_engine_uniffi/uc_engine_uniffi.h | 1853 +++ tests/hosts/go/go.mod | 7 + tests/hosts/go/host.go | 108 + tests/hosts/go/lifecycle.go | 124 + tests/hosts/go/main.go | 71 + tests/hosts/go/negative.go | 146 + tests/hosts/go/observability.go | 108 + tests/hosts/go/util.go | 7 + 24 files changed, 14013 insertions(+) create mode 100644 bindings/go/engine/engine.go create mode 100644 bindings/go/engine/errors.go create mode 100644 bindings/go/engine/events.go create mode 100644 bindings/go/engine/host.go create mode 100644 bindings/go/generator/PIN.env create mode 100755 bindings/go/generator/build-generator.sh create mode 100755 bindings/go/generator/generate.sh create mode 100644 bindings/go/generator/template-local-names.patch create mode 100644 bindings/go/go.mod create mode 100644 bindings/go/native/loaded_other.go create mode 100644 bindings/go/native/loaded_unix.go create mode 100755 bindings/go/native/stage-native.sh create mode 100644 bindings/go/native/verify.go create mode 100644 bindings/go/uc_engine_uniffi/LICENSE-uniffi-bindgen-go create mode 100644 bindings/go/uc_engine_uniffi/link.go create mode 100644 bindings/go/uc_engine_uniffi/uc_engine_uniffi.go create mode 100644 bindings/go/uc_engine_uniffi/uc_engine_uniffi.h create mode 100644 tests/hosts/go/go.mod create mode 100644 tests/hosts/go/host.go create mode 100644 tests/hosts/go/lifecycle.go create mode 100644 tests/hosts/go/main.go create mode 100644 tests/hosts/go/negative.go create mode 100644 tests/hosts/go/observability.go create mode 100644 tests/hosts/go/util.go diff --git a/bindings/go/engine/engine.go b/bindings/go/engine/engine.go new file mode 100644 index 00000000..925aa77e --- /dev/null +++ b/bindings/go/engine/engine.go @@ -0,0 +1,304 @@ +// Package engine 是 UniClipboard Engine 的 Go 门面:一次 Open、查询、事件、确定性 Close。 +// +// 所有权与并发契约: +// - Open 先核对原生库来源清单(native.Verify),失败即拒绝,没有跳过校验的模式。 +// - 所有方法可并发调用;Rust 的命令队列无界,限流由调用方负责。 +// - Close 先拒绝新调用,再请求 Rust 在期限内关闭并 join,然后等待在途调用排空,最后释放生成层对象。 +// Close 之后的调用返回 ErrClosed,不会 panic。Close 可重复调用。 +// - context 取消只让调用方停止等待:Rust 调用继续执行,Close 仍会等待它结束。 +// - 事件队列容量有限,溢出时 Rust 丢弃最旧事件并给出 RefreshRequired(ConsumerLagged); +// 门面不再设第二层缓冲,消费者应在收到后重新查询权威状态。 +// - Rust 在发布构建中 panic=abort:Rust 崩溃会直接终止整个宿主进程,Go 的 recover 无效。 +package engine + +import ( + "context" + "errors" + "sync" + "time" + + "github.com/UniClipboard/Engine/bindings/go/native" + ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" +) + +// eventPollSlice 是 NextEvent 每次进入 Rust 等待的时长,使 context 取消和 Close 能及时生效。 +const eventPollSlice = 200 * time.Millisecond + +// Config 是 Open 的输入。 +type Config struct { + AppVersion string + ProfileID string + // NativeManifest 是与原生库一同交付的 native-manifest.json 路径,必填。 + NativeManifest string +} + +// LocalDevice 是本机设备身份。 +type LocalDevice struct { + DeviceID string + DisplayName string +} + +// SpaceState 是当前空间状态的摘要;不含邀请内容。 +type SpaceState struct { + HasCompleted bool + RePairingRequired bool + SpaceID string + HasInvitation bool + DeviceName string +} + +// Device 是设备组中的一台设备。 +type Device struct { + DeviceID string + DisplayName string + IsLocal bool + Online bool +} + +// Opportunity 是触发网络恢复的外部时机。零值非法。 +type Opportunity int + +const ( + OpportunityForeground Opportunity = iota + 1 + OpportunitySystemWake + OpportunityNetworkChanged +) + +// Engine 是一个运行中的 Engine 实例。 +type Engine struct { + inner *ffi.MobileEngine + + mu sync.Mutex + inflight int + closing bool + idle chan struct{} // 关闭后在途调用排空时关闭 + closed bool // 生成层对象已释放 +} + +// Open 核对原生库并启动 Engine。host 不得为空,回调规则见 Host。 +func Open(config Config, host Host) (*Engine, error) { + if config.AppVersion == "" || config.ProfileID == "" || config.NativeManifest == "" || host == nil { + return nil, ErrInvalidInput + } + if _, err := native.Verify(config.NativeManifest); err != nil { + return nil, err + } + inner, err := ffi.MobileEngineStart( + ffi.BindingConfig{AppVersion: config.AppVersion, ProfileId: config.ProfileID}, + hostAdapter{host: host}, + ) + if err != nil { + return nil, convertError(err) + } + return &Engine{inner: inner, idle: make(chan struct{})}, nil +} + +func (e *Engine) begin() error { + e.mu.Lock() + defer e.mu.Unlock() + if e.closing { + return ErrClosed + } + e.inflight++ + return nil +} + +func (e *Engine) end() { + e.mu.Lock() + defer e.mu.Unlock() + e.inflight-- + if e.closing && e.inflight == 0 { + close(e.idle) + } +} + +// call 在 Rust 调用期间登记在途状态。ctx 先结束时返回 ctx.Err(),调用本身继续执行到完成。 +func call[T any](ctx context.Context, e *Engine, fn func(*ffi.MobileEngine) (T, error)) (T, error) { + var zero T + if err := ctx.Err(); err != nil { + return zero, err + } + if err := e.begin(); err != nil { + return zero, err + } + type outcome struct { + value T + err error + } + done := make(chan outcome, 1) + go func() { + defer e.end() + value, err := fn(e.inner) + done <- outcome{value, convertError(err)} + }() + select { + case result := <-done: + return result.value, result.err + case <-ctx.Done(): + return zero, ctx.Err() + } +} + +// LocalDevice 查询本机设备身份。 +func (e *Engine) LocalDevice(ctx context.Context) (LocalDevice, error) { + return call(ctx, e, func(inner *ffi.MobileEngine) (LocalDevice, error) { + device, err := inner.QueryLocalDevice() + return LocalDevice{DeviceID: device.DeviceId, DisplayName: device.DisplayName}, err + }) +} + +// SpaceState 查询当前空间状态。 +func (e *Engine) SpaceState(ctx context.Context) (SpaceState, error) { + return call(ctx, e, func(inner *ffi.MobileEngine) (SpaceState, error) { + state, err := inner.QuerySpaceState() + result := SpaceState{ + HasCompleted: state.HasCompleted, + RePairingRequired: state.RePairingRequired, + HasInvitation: state.CurrentInvitation != nil, + } + if state.SpaceId != nil { + result.SpaceID = *state.SpaceId + } + if state.DeviceName != nil { + result.DeviceName = *state.DeviceName + } + return result, err + }) +} + +// Devices 列出设备组。 +func (e *Engine) Devices(ctx context.Context) ([]Device, error) { + return call(ctx, e, func(inner *ffi.MobileEngine) ([]Device, error) { + devices, err := inner.ListDevices() + result := make([]Device, 0, len(devices)) + for _, device := range devices { + result = append(result, Device{ + DeviceID: device.DeviceId, + DisplayName: device.DisplayName, + IsLocal: device.IsLocal, + Online: device.Online, + }) + } + return result, err + }) +} + +// LeaveSpace 退出当前空间;没有可退出的空间时返回 EngineError。 +func (e *Engine) LeaveSpace(ctx context.Context) error { + _, err := call(ctx, e, func(inner *ffi.MobileEngine) (struct{}, error) { + return struct{}{}, inner.LeaveSpace() + }) + return err +} + +// NotifyConnectivityOpportunity 通知 Engine 前台、系统唤醒或网络变化。 +// 非法的 Opportunity(包括零值)返回 ErrInvalidInput,不会进入 Rust。 +func (e *Engine) NotifyConnectivityOpportunity(ctx context.Context, opportunity Opportunity) error { + var reason ffi.ConnectivityOpportunity + switch opportunity { + case OpportunityForeground: + reason = ffi.ConnectivityOpportunityForeground + case OpportunitySystemWake: + reason = ffi.ConnectivityOpportunitySystemWake + case OpportunityNetworkChanged: + reason = ffi.ConnectivityOpportunityNetworkChanged + default: + return ErrInvalidInput + } + _, err := call(ctx, e, func(inner *ffi.MobileEngine) (struct{}, error) { + return struct{}{}, inner.NotifyConnectivityOpportunity(reason) + }) + return err +} + +// State 查询生命周期状态。 +func (e *Engine) State(ctx context.Context) (State, error) { + return call(ctx, e, func(inner *ffi.MobileEngine) (State, error) { + state, err := inner.LifecycleState() + return stateFrom(state), err + }) +} + +// Suspend 把 Engine 暂停到可安全后台的状态;成功返回即暂停完成。 +func (e *Engine) Suspend(ctx context.Context) error { + _, err := call(ctx, e, func(inner *ffi.MobileEngine) (struct{}, error) { + return struct{}{}, inner.Suspend() + }) + return err +} + +// Resume 从暂停恢复。 +func (e *Engine) Resume(ctx context.Context) error { + _, err := call(ctx, e, func(inner *ffi.MobileEngine) (struct{}, error) { + return struct{}{}, inner.Resume() + }) + return err +} + +// NextEvent 阻塞到下一个事件、ctx 结束或 Engine 关闭。关闭后返回 ErrClosed。 +func (e *Engine) NextEvent(ctx context.Context) (Event, error) { + for { + event, err := call(ctx, e, func(inner *ffi.MobileEngine) (Event, error) { + next := inner.NextEvent(uint64(eventPollSlice / time.Millisecond)) + if next == nil { + return nil, nil + } + return eventFrom(*next), nil + }) + if err != nil { + return nil, err + } + if event != nil { + return event, nil + } + } +} + +// Close 请求 Rust 在 deadline 内关闭并 join,排空在途调用后释放对象。 +// +// 期限内未完成时返回 ErrCloseIncomplete(或 Rust 的 DeadlineExceeded EngineError), +// 此后新调用仍被拒绝,可再次调用 Close 继续收尾。Close 成功后重复调用返回 nil。 +func (e *Engine) Close(deadline time.Duration) error { + if deadline <= 0 { + return ErrInvalidInput + } + started := time.Now() + e.mu.Lock() + if e.closed { + e.mu.Unlock() + return nil + } + if !e.closing { + e.closing = true + if e.inflight == 0 { + close(e.idle) + } + } + e.mu.Unlock() + + // 不持锁:关闭会结束事件队列,唤醒阻塞中的 NextEvent。 + if err := e.inner.Shutdown(uint64(deadline / time.Millisecond)); err != nil { + converted := convertError(err) + if errors.Is(converted, ErrAlreadyStopped) { + converted = nil + } + if converted != nil { + return converted + } + } + + timer := time.NewTimer(max(deadline-time.Since(started), 0)) + defer timer.Stop() + select { + case <-e.idle: + case <-timer.C: + return ErrCloseIncomplete + } + e.mu.Lock() + defer e.mu.Unlock() + if !e.closed { + e.closed = true + e.inner.Destroy() + } + return nil +} diff --git a/bindings/go/engine/errors.go b/bindings/go/engine/errors.go new file mode 100644 index 00000000..e1bee3fb --- /dev/null +++ b/bindings/go/engine/errors.go @@ -0,0 +1,115 @@ +package engine + +import ( + "errors" + "fmt" + + ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" +) + +var ( + // ErrClosed 表示 Engine 已关闭或正在关闭;不会进入 Rust。 + ErrClosed = errors.New("engine is closed") + // ErrInvalidInput 表示调用方输入在进入 Rust 之前就被拒绝。 + ErrInvalidInput = errors.New("invalid input") + // ErrCloseIncomplete 表示 Close 的期限先耗尽:关闭已请求,但 Rust 关闭或在途调用尚未结束。 + // 引擎不会被标记为已停止,可以用新的期限再次调用 Close。 + ErrCloseIncomplete = errors.New("engine close did not complete within its deadline") + // ErrRuntimeUnavailable 与 ErrAlreadyStopped 对应 Rust 绑定的同名稳定错误。 + ErrRuntimeUnavailable = errors.New("engine runtime unavailable") + ErrAlreadyStopped = errors.New("engine already stopped") + // ErrUnexpectedResult 表示 Rust 返回了绑定无法解释的结果。 + ErrUnexpectedResult = errors.New("engine returned an unexpected result") +) + +// 宿主能力错误:Host 实现返回这些值之一,Rust 侧据此得到稳定的宿主错误分类。 +var ( + ErrHostUnavailable = errors.New("host capability unavailable") + ErrHostPermissionDenied = errors.New("host capability permission denied") + ErrHostInvalidHandle = errors.New("host file handle invalid") + ErrHostIO = errors.New("host input/output failed") +) + +// ErrorCategory 是 Engine 稳定错误的粗分类。 +type ErrorCategory int + +const ( + CategoryInvalidInput ErrorCategory = iota + 1 + CategoryInvalidState + CategoryUnauthorized + CategoryNotFound + CategoryConflict + CategoryUnavailable + CategoryDeadlineExceeded + CategoryInternal +) + +// EngineError 是 Engine 业务失败的稳定形态:只有错误码、分类与可重试性,不含任何内容、路径或设备信息。 +type EngineError struct { + Code uint32 + Category ErrorCategory + Retryable bool +} + +func (e *EngineError) Error() string { + return fmt.Sprintf("engine error %d (category %d)", e.Code, e.Category) +} + +// convertError 把生成层错误归一为本包的稳定错误;未识别的错误按 ErrUnexpectedResult 处理。 +func convertError(err error) error { + if err == nil { + return nil + } + var binding *ffi.BindingError + if !errors.As(err, &binding) { + var value ffi.BindingError + if !errors.As(err, &value) { + return err + } + binding = &value + } + var engine *ffi.BindingErrorEngine + switch { + case errors.As(binding, &engine): + return &EngineError{ + Code: engine.Code, + Category: categoryFrom(engine.Category), + Retryable: engine.Retryable, + } + case errors.Is(binding, ffi.ErrBindingErrorHostUnavailable): + return ErrHostUnavailable + case errors.Is(binding, ffi.ErrBindingErrorHostPermissionDenied): + return ErrHostPermissionDenied + case errors.Is(binding, ffi.ErrBindingErrorHostInvalidHandle): + return ErrHostInvalidHandle + case errors.Is(binding, ffi.ErrBindingErrorHostIo): + return ErrHostIO + case errors.Is(binding, ffi.ErrBindingErrorRuntimeUnavailable): + return ErrRuntimeUnavailable + case errors.Is(binding, ffi.ErrBindingErrorAlreadyStopped): + return ErrAlreadyStopped + default: + return ErrUnexpectedResult + } +} + +func categoryFrom(category ffi.BindingErrorCategory) ErrorCategory { + switch category { + case ffi.BindingErrorCategoryInvalidInput: + return CategoryInvalidInput + case ffi.BindingErrorCategoryInvalidState: + return CategoryInvalidState + case ffi.BindingErrorCategoryUnauthorized: + return CategoryUnauthorized + case ffi.BindingErrorCategoryNotFound: + return CategoryNotFound + case ffi.BindingErrorCategoryConflict: + return CategoryConflict + case ffi.BindingErrorCategoryUnavailable: + return CategoryUnavailable + case ffi.BindingErrorCategoryDeadlineExceeded: + return CategoryDeadlineExceeded + default: + return CategoryInternal + } +} diff --git a/bindings/go/engine/events.go b/bindings/go/engine/events.go new file mode 100644 index 00000000..ca0052eb --- /dev/null +++ b/bindings/go/engine/events.go @@ -0,0 +1,97 @@ +package engine + +import ( + "fmt" + "strings" + + ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" +) + +// State 是 Engine 的生命周期状态。 +type State int + +const ( + StateRunning State = iota + 1 + StateQuiescing + StateQuiesced + StateSuspended + StateShuttingDown + StateStopped +) + +// RefreshReason 说明为什么消费者必须重新查询权威状态。 +type RefreshReason int + +const ( + // RefreshConsumerLagged 表示事件队列溢出,中间事件已被丢弃。 + RefreshConsumerLagged RefreshReason = iota + 1 + RefreshStateInvalidated +) + +// Event 是 Engine 事件。本片只解释生命周期与刷新事件;其余事件只报告种类(Unmapped), +// 不携带载荷,因为载荷可能含剪贴板预览、设备名或文件名。 +type Event interface{ isEvent() } + +// StateChanged 表示生命周期状态变化。 +type StateChanged struct{ State State } + +// RefreshRequired 要求消费者重新查询权威状态。 +type RefreshRequired struct{ Reason RefreshReason } + +// Fatal 表示 Engine 遇到不可恢复错误。 +type Fatal struct{ Failure *EngineError } + +// Unmapped 表示一个本片尚未映射的事件;Kind 是固定的事件种类名。 +type Unmapped struct{ Kind string } + +func (StateChanged) isEvent() {} +func (RefreshRequired) isEvent() {} +func (Fatal) isEvent() {} +func (Unmapped) isEvent() {} + +func stateFrom(state ffi.BindingEngineState) State { + switch state { + case ffi.BindingEngineStateRunning: + return StateRunning + case ffi.BindingEngineStateQuiescing: + return StateQuiescing + case ffi.BindingEngineStateQuiesced: + return StateQuiesced + case ffi.BindingEngineStateSuspended: + return StateSuspended + case ffi.BindingEngineStateShuttingDown: + return StateShuttingDown + default: + return StateStopped + } +} + +func eventFrom(event ffi.BindingEvent) Event { + switch value := event.(type) { + case ffi.BindingEventStateChanged: + return StateChanged{State: stateFrom(value.State)} + case ffi.BindingEventRefreshRequired: + reason := RefreshStateInvalidated + if value.Reason == ffi.BindingRefreshReasonConsumerLagged { + reason = RefreshConsumerLagged + } + return RefreshRequired{Reason: reason} + case ffi.BindingEventFatal: + return Fatal{Failure: &EngineError{ + Code: value.Failure.Code, + Category: categoryFrom(value.Failure.Category), + Retryable: value.Failure.Retryable, + }} + default: + return Unmapped{Kind: eventKind(event)} + } +} + +// eventKind 返回生成层变体名(如 IncomingEntry),只读类型名,不触碰载荷。 +func eventKind(event ffi.BindingEvent) string { + name := fmt.Sprintf("%T", event) + if index := strings.LastIndex(name, "BindingEvent"); index >= 0 { + return name[index+len("BindingEvent"):] + } + return name +} diff --git a/bindings/go/engine/host.go b/bindings/go/engine/host.go new file mode 100644 index 00000000..851a31dc --- /dev/null +++ b/bindings/go/engine/host.go @@ -0,0 +1,103 @@ +package engine + +import ( + "errors" + + ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" +) + +// Host 是 Go 宿主向 Engine 提供的平台能力。 +// +// 回调由 Rust 的 Engine 线程调用,只能返回能力结果;不得在回调内调用同一个 Engine 的任何方法 +// (同步请求会等待正在执行回调的同一个线程,造成环形等待)。失败返回本包的 ErrHost* 之一, +// 其他错误按 ErrHostIO 处理。 +// +// 本片只开放启动所需的目录与安全存储;剪贴板与文件句柄能力固定返回“不可用”, +// 随后续 Engine 能力一起补入。 +type Host interface { + PrivateDataDirectory() (string, error) + CacheDirectory() (string, error) + TemporaryDirectory() (string, error) + // SecureStorageGet 返回 (nil, nil) 表示键不存在。 + SecureStorageGet(key string) ([]byte, error) + SecureStorageSet(key string, value []byte) error + SecureStorageDelete(key string) error +} + +// hostAdapter 把 Host 适配为生成层的回调接口,并把 Go 错误映射为稳定的宿主错误分类。 +type hostAdapter struct { + host Host +} + +func hostError(err error) error { + switch { + case err == nil: + return nil + case errors.Is(err, ErrHostUnavailable): + return ffi.NewHostBindingErrorUnavailable() + case errors.Is(err, ErrHostPermissionDenied): + return ffi.NewHostBindingErrorPermissionDenied() + case errors.Is(err, ErrHostInvalidHandle): + return ffi.NewHostBindingErrorInvalidHandle() + default: + return ffi.NewHostBindingErrorIo() + } +} + +func (a hostAdapter) PrivateDataDirectory() (string, error) { + value, err := a.host.PrivateDataDirectory() + return value, hostError(err) +} + +func (a hostAdapter) CacheDirectory() (string, error) { + value, err := a.host.CacheDirectory() + return value, hostError(err) +} + +func (a hostAdapter) TemporaryDirectory() (string, error) { + value, err := a.host.TemporaryDirectory() + return value, hostError(err) +} + +func (a hostAdapter) SecureStorageGet(key string) (*[]byte, error) { + value, err := a.host.SecureStorageGet(key) + if err != nil { + return nil, hostError(err) + } + if value == nil { + return nil, nil + } + return &value, nil +} + +func (a hostAdapter) SecureStorageSet(key string, value []byte) error { + return hostError(a.host.SecureStorageSet(key, value)) +} + +func (a hostAdapter) SecureStorageDelete(key string) error { + return hostError(a.host.SecureStorageDelete(key)) +} + +func (hostAdapter) FileMetadata(string) (ffi.BindingFileMetadata, error) { + return ffi.BindingFileMetadata{}, ffi.NewHostBindingErrorUnavailable() +} + +func (hostAdapter) FileReadChunk(string, uint64, uint32) ([]byte, error) { + return nil, ffi.NewHostBindingErrorUnavailable() +} + +func (hostAdapter) FileWriteChunk(string, uint64, []byte) error { + return ffi.NewHostBindingErrorUnavailable() +} + +func (hostAdapter) FileFinishWrite(string) error { + return ffi.NewHostBindingErrorUnavailable() +} + +func (hostAdapter) ClipboardRead() (ffi.BindingClipboardSnapshot, error) { + return ffi.BindingClipboardSnapshot{}, ffi.NewHostBindingErrorUnavailable() +} + +func (hostAdapter) ClipboardWrite(ffi.BindingClipboardSnapshot) error { + return ffi.NewHostBindingErrorUnavailable() +} diff --git a/bindings/go/generator/PIN.env b/bindings/go/generator/PIN.env new file mode 100644 index 00000000..7c7c389e --- /dev/null +++ b/bindings/go/generator/PIN.env @@ -0,0 +1,7 @@ +# Go 生成器的唯一来源声明;build-generator.sh 与来源清单都读取这里。 +UNIFFI_BINDGEN_GO_URL=https://github.com/NordSecurity/uniffi-bindgen-go.git +UNIFFI_BINDGEN_GO_TAG=v0.7.1+v0.31.0 +UNIFFI_BINDGEN_GO_REVISION=0b7fb4ceef12021bd7f790cc516fa9133e001813 +UNIFFI_BINDGEN_GO_LOCK_SHA256=538b9b06c20f13b42b47025d69d625d90e5082a349ef984078339a20d1869858 +UNIFFI_BINDGEN_GO_PATCH=template-local-names.patch +UNIFFI_BINDGEN_GO_PATCH_SHA256=0c8ff53bf30a0567495e88bbd93c6b13ae675fca45353344bfc4f32e3b84afdf diff --git a/bindings/go/generator/build-generator.sh b/bindings/go/generator/build-generator.sh new file mode 100755 index 00000000..4cf26ef7 --- /dev/null +++ b/bindings/go/generator/build-generator.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# 从固定 revision 取得 uniffi-bindgen-go,核对上游 Cargo.lock,应用名称卫生补丁并构建。 +# +# build-generator.sh <外置可再生构建目录> +# +# 目录必须不存在或为空;脚本不删除它,调用方在确认无活动构建进程后回收。输出: +# <目录>/bin/uniffi-bindgen-go 与 <目录>/generator-build.json(来源与哈希)。 +set -euo pipefail + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +repo_root="$(cd "$here/../../.." && pwd)" +work="${1:?usage: build-generator.sh }" +source "$here/PIN.env" +source "$repo_root/scripts/build-cache/env.sh" + +if [[ -e "$work" && -n "$(ls -A "$work")" ]]; then + echo "build dir must be empty: $work" >&2 + exit 2 +fi +mkdir -p "$work" +work="$(cd "$work" && pwd)" + +sha256_of() { shasum -a 256 "$1" | cut -d' ' -f1; } + +[[ "$(sha256_of "$here/$UNIFFI_BINDGEN_GO_PATCH")" == "$UNIFFI_BINDGEN_GO_PATCH_SHA256" ]] \ + || { echo "patch hash differs from PIN.env" >&2; exit 1; } + +git clone --quiet "$UNIFFI_BINDGEN_GO_URL" "$work/src" +git -C "$work/src" checkout --quiet "$UNIFFI_BINDGEN_GO_REVISION" +[[ "$(git -C "$work/src" rev-parse HEAD)" == "$UNIFFI_BINDGEN_GO_REVISION" ]] +[[ "$(sha256_of "$work/src/Cargo.lock")" == "$UNIFFI_BINDGEN_GO_LOCK_SHA256" ]] \ + || { echo "upstream Cargo.lock differs from PIN.env" >&2; exit 1; } +git -C "$work/src" apply --check "$here/$UNIFFI_BINDGEN_GO_PATCH" +git -C "$work/src" apply "$here/$UNIFFI_BINDGEN_GO_PATCH" + +# 上游自带 rust-toolchain.toml(1.87);统一使用本仓固定工具链,记录在构建清单中。 +toolchain_version="$(cd "$repo_root" && rustc --version)" +(cd "$repo_root" && cargo build --manifest-path "$work/src/Cargo.toml" -p uniffi-bindgen-go \ + --release --locked --target-dir "$work/target") + +mkdir -p "$work/bin" +cp "$work/target/release/uniffi-bindgen-go" "$work/bin/uniffi-bindgen-go" +cp "$work/src/LICENSE" "$work/LICENSE" +printf '{\n "revision": "%s",\n "tag": "%s",\n "lock_sha256": "%s",\n "patch": "%s",\n "patch_sha256": "%s",\n "binary_sha256": "%s",\n "rustc": "%s"\n}\n' \ + "$UNIFFI_BINDGEN_GO_REVISION" "$UNIFFI_BINDGEN_GO_TAG" "$UNIFFI_BINDGEN_GO_LOCK_SHA256" \ + "$UNIFFI_BINDGEN_GO_PATCH" "$UNIFFI_BINDGEN_GO_PATCH_SHA256" \ + "$(sha256_of "$work/bin/uniffi-bindgen-go")" "$toolchain_version" > "$work/generator-build.json" +echo "generator ready: $work/bin/uniffi-bindgen-go" diff --git a/bindings/go/generator/generate.sh b/bindings/go/generator/generate.sh new file mode 100755 index 00000000..7fdf0fca --- /dev/null +++ b/bindings/go/generator/generate.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# 用固定生成器从 uc-engine-uniffi 动态库的接口元数据生成 Go 包到 bindings/go/uc_engine_uniffi。 +# +# generate.sh +# +# 元数据来自库,不依赖库的 profile;dev 与 release 构建生成的结果必须一致。 +# 只改写两个生成文件,同目录的手写文件(link.go)保持不变。生成结果提交入库, +# CI 重新生成后要求零差异;禁止手改生成文件,修正只能走 generator/*.patch。 +set -euo pipefail + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +module_dir="$(cd "$here/.." && pwd)" +generator="${1:?usage: generate.sh }" +library="${2:?usage: generate.sh }" + +work="$(mktemp -d "${TMPDIR:-/tmp}/uc-go-generate.XXXXXX")" +trap 'rm -rf "$work"' EXIT +"$generator" --library "$library" --out-dir "$work" +for file in uc_engine_uniffi.go uc_engine_uniffi.h; do + cp "$work/uc_engine_uniffi/$file" "$module_dir/uc_engine_uniffi/$file" +done diff --git a/bindings/go/generator/template-local-names.patch b/bindings/go/generator/template-local-names.patch new file mode 100644 index 00000000..77083b64 --- /dev/null +++ b/bindings/go/generator/template-local-names.patch @@ -0,0 +1,139 @@ +diff --git a/bindgen/templates/VTableImpl.go b/bindgen/templates/VTableImpl.go +index 3c55cee..6beec99 100644 +--- a/bindgen/templates/VTableImpl.go ++++ b/bindgen/templates/VTableImpl.go +@@ -14,48 +14,48 @@ func {{ callback_name }}( + callStatus *C.RustCallStatus, + {%- endif -%} + ) { +- handle := uint64(uniffiHandle) +- uniffiObj, ok := {{ ffi_converter_instance }}.handleMap.tryGet(handle) +- if !ok { +- panic(fmt.Errorf("no callback in handle map: %d", handle)) ++ _uniffiCallbackHandle := uint64(uniffiHandle) ++ _uniffiObj, _uniffiOk := {{ ffi_converter_instance }}.handleMap.tryGet(_uniffiCallbackHandle) ++ if !_uniffiOk { ++ panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + {% if meth.is_async() %} + {%- let result_struct = meth.foreign_future_ffi_result_struct().name()|ffi_struct_name %} +- result := make(chan C.{{ result_struct }}, 1) +- cancel := make(chan struct{}, 1) +- guardHandle := cgo.NewHandle(cancel) ++ _uniffiResult := make(chan C.{{ result_struct }}, 1) ++ _uniffiCancel := make(chan struct{}, 1) ++ _uniffiGuardHandle := cgo.NewHandle(_uniffiCancel) + *uniffiOutDroppedCallback = C.UniffiForeignFutureDroppedCallbackStruct { +- handle: C.uint64_t(guardHandle), ++ handle: C.uint64_t(_uniffiGuardHandle), + free: C.UniffiForeignFutureDroppedCallback(C.{{ config|free_gorutine_callback }}), + } + + // Wait for compleation or cancel + go func() { + select { +- case <-cancel: +- case res := <-result: ++ case <-_uniffiCancel: ++ case _uniffiRes := <-_uniffiResult: + {{ ffi_callback|find_ffi_callback_helper -}} +- (uniffiFutureCallback, uniffiCallbackData, res) ++ (uniffiFutureCallback, uniffiCallbackData, _uniffiRes) + } + }() + + // Eval callback asynchroniously + go func() { +- asyncResult := &C.{{ result_struct }}{}; ++ _uniffiAsyncResult := &C.{{ result_struct }}{}; + {%- if meth.return_type().is_some() %} +- uniffiOutReturn := &asyncResult.returnValue ++ uniffiOutReturn := &_uniffiAsyncResult.returnValue + {%- endif %} + {%- if meth.throws_type().is_some() %} +- callStatus := &asyncResult.callStatus ++ callStatus := &_uniffiAsyncResult.callStatus + {%- endif %} + defer func() { +- result <- *asyncResult ++ _uniffiResult <- *_uniffiAsyncResult + }() + {% endif %} + + {% call go::func_return_vars(meth, suffix = ":=") %} +- uniffiObj.{{ meth.name()|fn_name }}( ++ _uniffiObj.{{ meth.name()|fn_name }}( + {%- for arg in meth.arguments() %} + {%- let var = arg.name()|var_name %} + {{ arg|lift_fn(ci) }}({% call go::remap_ffi_val(arg.as_type(), var) %}), +@@ -64,12 +64,12 @@ func {{ callback_name }}( + + {% if let Some(error_type) = meth.throws_type() -%} + {{- self.add_import("errors") }} +- if err != nil { +- var actualError {{ error_type|type_name(ci) }} +- if errors.As(err, &actualError) { ++ if _uniffiErr != nil { ++ var _uniffiActualError {{ error_type|type_name(ci) }} ++ if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus { + code: C.int8_t(uniffiCallbackResultError), +- errorBuf: {{ error_type|lower_fn(ci) }}(actualError), ++ errorBuf: {{ error_type|lower_fn(ci) }}(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus { +@@ -82,7 +82,7 @@ func {{ callback_name }}( + + + {% if let Some(return_type) = meth.return_type() -%} +- *uniffiOutReturn = {{ return_type|lower_fn(ci) }}(res) ++ *uniffiOutReturn = {{ return_type|lower_fn(ci) }}(_uniffiRes) + {%- endif %} + + {%- if meth.is_async() %} +diff --git a/bindgen/templates/macros.go b/bindgen/templates/macros.go +index 4ede2df..a3638b6 100644 +--- a/bindgen/templates/macros.go ++++ b/bindgen/templates/macros.go +@@ -121,18 +121,18 @@ + + {%- macro func_return_vars_pairs(func, prefix = "", suffix = "") -%} + {%- match (func.return_type(), func.throws_type()) -%} +- {%- when (Some(_), Some(_)) -%} {{ prefix }} res, err {{ suffix }} +- {%- when (None, Some(_)) -%} {{ prefix }} _, err {{ suffix }} +- {%- when (Some(_), None) -%} {{ prefix }} res, _ {{ suffix }} ++ {%- when (Some(_), Some(_)) -%} {{ prefix }} _uniffiRes, _uniffiErr {{ suffix }} ++ {%- when (None, Some(_)) -%} {{ prefix }} _, _uniffiErr {{ suffix }} ++ {%- when (Some(_), None) -%} {{ prefix }} _uniffiRes, _ {{ suffix }} + {%- when (None, None) -%} + {%- endmatch -%} {# space -#} + {%- endmacro -%} + + {%- macro func_return_vars(func, prefix = "", suffix = "") -%} + {% match (func.return_type(), func.throws_type()) -%} +- {%- when (Some(_), Some(_)) -%} {{ prefix }} res, err {{ suffix }} +- {%- when (None, Some(_)) -%} {{ prefix }} err {{ suffix }} +- {%- when (Some(_), None) -%} {{ prefix }} res {{ suffix }} ++ {%- when (Some(_), Some(_)) -%} {{ prefix }} _uniffiRes, _uniffiErr {{ suffix }} ++ {%- when (None, Some(_)) -%} {{ prefix }} _uniffiErr {{ suffix }} ++ {%- when (Some(_), None) -%} {{ prefix }} _uniffiRes {{ suffix }} + {%- when (None, None) -%} + {%- endmatch -%} + {%- endmacro -%} +@@ -140,11 +140,11 @@ + {%- macro func_nil_err_check(func) -%} + {% match (func.return_type(), func.throws_type()) -%} + {%- when (Some(_), Some(_)) -%} +- if err == nil { +- return res, nil ++ if _uniffiErr == nil { ++ return _uniffiRes, nil + } + {%- when (None, Some(_)) -%} +- if err == nil { ++ if _uniffiErr == nil { + return nil + } + {%- when (Some(_), None) -%} diff --git a/bindings/go/go.mod b/bindings/go/go.mod new file mode 100644 index 00000000..61dbf0a2 --- /dev/null +++ b/bindings/go/go.mod @@ -0,0 +1,3 @@ +module github.com/UniClipboard/Engine/bindings/go + +go 1.24.0 diff --git a/bindings/go/native/loaded_other.go b/bindings/go/native/loaded_other.go new file mode 100644 index 00000000..a4189eab --- /dev/null +++ b/bindings/go/native/loaded_other.go @@ -0,0 +1,8 @@ +//go:build !(cgo && (darwin || linux)) + +package native + +// 其他平台尚无已验证的加载路径解析;明确失败而不是静默通过。 +func loadedLibraryPath() (string, error) { + return "", ErrUnsupported +} diff --git a/bindings/go/native/loaded_unix.go b/bindings/go/native/loaded_unix.go new file mode 100644 index 00000000..cede3fc8 --- /dev/null +++ b/bindings/go/native/loaded_unix.go @@ -0,0 +1,35 @@ +//go:build cgo && (darwin || linux) + +package native + +/* +#cgo LDFLAGS: -luc_engine_uniffi +#define _GNU_SOURCE +#include +#include + +extern uint32_t ffi_uc_engine_uniffi_uniffi_contract_version(void); + +static const char *uc_loaded_library_path(void) { + Dl_info info; + if (dladdr((void *)ffi_uc_engine_uniffi_uniffi_contract_version, &info) == 0) { + return 0; + } + return info.dli_fname; +} +*/ +import "C" + +import ( + "fmt" + "path/filepath" +) + +// loadedLibraryPath 通过原生库内的符号向动态链接器查询实际映射的文件,而不是信任 rpath 配置。 +func loadedLibraryPath() (string, error) { + name := C.uc_loaded_library_path() + if name == nil { + return "", fmt.Errorf("%w: loader did not report the library path", ErrMismatch) + } + return filepath.Clean(C.GoString(name)), nil +} diff --git a/bindings/go/native/stage-native.sh b/bindings/go/native/stage-native.sh new file mode 100755 index 00000000..3fe2536b --- /dev/null +++ b/bindings/go/native/stage-native.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# 把 cargo 产出的 uc-engine-uniffi 动态库整理成 Go 宿主可链接的交付目录,并写入来源清单。 +# +# stage-native.sh <输出目录> +# +# 从仓库根目录的源码构建(`just cargo build -p uc-engine-uniffi --profile --locked`)后运行。 +# 输出目录必须不存在或为空,包含: +# libuc_engine_uniffi. install_name/soname 已改为 @rpath(macOS 重新 ad-hoc 签名) +# native-manifest.json 来源、构建参数与产物 sha256;Go 侧 native.Verify 逐项核对 +# +# 工作区有未提交改动时拒绝运行:清单里的 revision 必须能唯一还原源码。 +set -euo pipefail + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +repo_root="$(cd "$here/../../.." && pwd)" +profile="${1:?usage: stage-native.sh }" +out="${2:?usage: stage-native.sh }" +source "$here/../generator/PIN.env" + +case "$profile" in + dev) profile_dir=debug ;; + release) profile_dir=release ;; + *) echo "profile must be dev or release" >&2; exit 2 ;; +esac +if [[ -e "$out" && -n "$(ls -A "$out")" ]]; then + echo "output dir must be empty: $out" >&2 + exit 2 +fi + +cd "$repo_root" +if [[ -n "$(git status --porcelain)" ]]; then + echo "working tree is not clean; refusing to record provenance" >&2 + exit 1 +fi + +case "$(uname -s)" in + Darwin) ext=dylib ;; + Linux) ext=so ;; + *) echo "unsupported host: $(uname -s)" >&2; exit 1 ;; +esac +target_dir="${CARGO_TARGET_DIR:-$repo_root/target}" +source_lib="$target_dir/$profile_dir/libuc_engine_uniffi.$ext" +[[ -f "$source_lib" ]] || { echo "missing $source_lib; build first" >&2; exit 1; } + +sha256_of() { shasum -a 256 "$1" | cut -d' ' -f1; } +mkdir -p "$out" +staged="$out/libuc_engine_uniffi.$ext" +cp "$source_lib" "$staged" +raw_sha256="$(sha256_of "$staged")" +if [[ "$ext" == dylib ]]; then + install_name_tool -id "@rpath/libuc_engine_uniffi.dylib" "$staged" + codesign --force --sign - "$staged" +else + patchelf --set-soname libuc_engine_uniffi.so "$staged" +fi + +version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" +uniffi_version="$(sed -n 's/^uniffi = "=\(.*\)"/\1/p' bindings/uc-engine-uniffi/Cargo.toml)" +generated_sha256="$(cd bindings/go/uc_engine_uniffi && shasum -a 256 uc_engine_uniffi.go uc_engine_uniffi.h | shasum -a 256 | cut -d' ' -f1)" +python3 - "$out/native-manifest.json" </dev/null || stat -c%s "$staged"), + "cargo_artifact_sha256": "$raw_sha256", + }, +} +open(sys.argv[1], "w").write(json.dumps(manifest, indent=2) + "\n") +PY +echo "staged $staged" diff --git a/bindings/go/native/verify.go b/bindings/go/native/verify.go new file mode 100644 index 00000000..887c27b2 --- /dev/null +++ b/bindings/go/native/verify.go @@ -0,0 +1,142 @@ +// Package native 在启动 Engine 之前核对实际加载的原生库与来源清单一致。 +// +// 清单由 stage-native.sh 与原生库一同生成。Verify 不提供“跳过校验”的模式: +// 清单缺失、字段不符、库被替换或版本错配都返回 ErrMismatch。 +package native + +import ( + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "io" + "os" + "path/filepath" + "sync" + + ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" +) + +const manifestSchema = 1 + +var ( + // ErrMismatch 表示清单缺失、无法解析,或其内容与实际加载的原生库不一致。 + ErrMismatch = errors.New("native library does not match its provenance manifest") + // ErrUnsupported 表示当前平台没有加载路径解析,无法完成校验;调用方不得当作通过。 + ErrUnsupported = errors.New("native library identity check is not supported on this platform") +) + +// Manifest 是 native-manifest.json 的内容。 +type Manifest struct { + Schema int `json:"schema"` + EngineRevision string `json:"engine_revision"` + EngineVersion string `json:"engine_version"` + CargoLockSHA256 string `json:"cargo_lock_sha256"` + UniffiVersion string `json:"uniffi_version"` + Target string `json:"target"` + Profile string `json:"profile"` + Features []string `json:"features"` + Rustc string `json:"rustc"` + Cargo string `json:"cargo"` + Generator struct { + Revision string `json:"revision"` + Tag string `json:"tag"` + LockSHA256 string `json:"lock_sha256"` + PatchSHA256 string `json:"patch_sha256"` + } `json:"generator"` + GeneratedSourcesSHA256 string `json:"generated_sources_sha256"` + Library struct { + File string `json:"file"` + SHA256 string `json:"sha256"` + Size int64 `json:"size"` + CargoArtifactSHA256 string `json:"cargo_artifact_sha256"` + } `json:"library"` +} + +var ( + verifyMu sync.Mutex + verified = map[string]*Manifest{} +) + +// Verify 读取清单并核对实际加载的原生库;同一路径在进程内只做一次完整校验。 +func Verify(manifestPath string) (*Manifest, error) { + absolute, err := filepath.Abs(manifestPath) + if err != nil { + return nil, fmt.Errorf("%w: manifest path", ErrMismatch) + } + verifyMu.Lock() + defer verifyMu.Unlock() + if manifest, ok := verified[absolute]; ok { + return manifest, nil + } + manifest, err := readManifest(absolute) + if err != nil { + return nil, err + } + if err := checkLoadedLibrary(manifest); err != nil { + return nil, err + } + verified[absolute] = manifest + return manifest, nil +} + +func readManifest(path string) (*Manifest, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, fmt.Errorf("%w: manifest unreadable", ErrMismatch) + } + var manifest Manifest + if err := json.Unmarshal(data, &manifest); err != nil { + return nil, fmt.Errorf("%w: manifest malformed", ErrMismatch) + } + if manifest.Schema != manifestSchema { + return nil, fmt.Errorf("%w: manifest schema %d", ErrMismatch, manifest.Schema) + } + for field, value := range map[string]string{ + "engine_revision": manifest.EngineRevision, + "engine_version": manifest.EngineVersion, + "library.file": manifest.Library.File, + "library.sha256": manifest.Library.SHA256, + } { + if value == "" { + return nil, fmt.Errorf("%w: manifest field %s is empty", ErrMismatch, field) + } + } + return &manifest, nil +} + +func checkLoadedLibrary(manifest *Manifest) error { + if got, want := ffi.CoreVersion(), "v"+manifest.EngineVersion; got != want { + return fmt.Errorf("%w: core version %s, manifest %s", ErrMismatch, got, want) + } + loaded, err := loadedLibraryPath() + if err != nil { + return err + } + if filepath.Base(loaded) != manifest.Library.File { + return fmt.Errorf("%w: loaded library name differs from manifest", ErrMismatch) + } + sum, size, err := hashFile(loaded) + if err != nil { + return fmt.Errorf("%w: loaded library unreadable", ErrMismatch) + } + if size != manifest.Library.Size || sum != manifest.Library.SHA256 { + return fmt.Errorf("%w: loaded library digest differs from manifest", ErrMismatch) + } + return nil +} + +func hashFile(path string) (string, int64, error) { + file, err := os.Open(path) + if err != nil { + return "", 0, err + } + defer file.Close() + digest := sha256.New() + size, err := io.Copy(digest, file) + if err != nil { + return "", 0, err + } + return hex.EncodeToString(digest.Sum(nil)), size, nil +} diff --git a/bindings/go/uc_engine_uniffi/LICENSE-uniffi-bindgen-go b/bindings/go/uc_engine_uniffi/LICENSE-uniffi-bindgen-go new file mode 100644 index 00000000..fa0086a9 --- /dev/null +++ b/bindings/go/uc_engine_uniffi/LICENSE-uniffi-bindgen-go @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. \ No newline at end of file diff --git a/bindings/go/uc_engine_uniffi/link.go b/bindings/go/uc_engine_uniffi/link.go new file mode 100644 index 00000000..8679fd04 --- /dev/null +++ b/bindings/go/uc_engine_uniffi/link.go @@ -0,0 +1,10 @@ +// 手写文件:cgo 编译与链接指令。生成文件由 generator/generate.sh 重写,本文件不受影响。 +// +// 头文件随模块分发;原生库不在 Go module 内,由宿主构建环境经 CGO_LDFLAGS 提供 -L 与 rpath, +// 见 ../native/README.md。动态库身份由 ../native 的清单校验。 + +package uc_engine_uniffi + +// #cgo CFLAGS: -I${SRCDIR} +// #cgo LDFLAGS: -luc_engine_uniffi +import "C" diff --git a/bindings/go/uc_engine_uniffi/uc_engine_uniffi.go b/bindings/go/uc_engine_uniffi/uc_engine_uniffi.go new file mode 100644 index 00000000..49abe04d --- /dev/null +++ b/bindings/go/uc_engine_uniffi/uc_engine_uniffi.go @@ -0,0 +1,10095 @@ +package uc_engine_uniffi + +// #include +import "C" + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "io" + "math" + "runtime" + "sync" + "sync/atomic" + "unsafe" +) + +// This is needed, because as of go 1.24 +// type RustBuffer C.RustBuffer cannot have methods, +// RustBuffer is treated as non-local type +type GoRustBuffer struct { + inner C.RustBuffer +} + +type RustBufferI interface { + AsReader() *bytes.Reader + Free() + ToGoBytes() []byte + Data() unsafe.Pointer + Len() uint64 + Capacity() uint64 +} + +// C.RustBuffer fields exposed as an interface so they can be accessed in different Go packages. +// See https://github.com/golang/go/issues/13467 +type ExternalCRustBuffer interface { + Data() unsafe.Pointer + Len() uint64 + Capacity() uint64 +} + +func RustBufferFromC(b C.RustBuffer) ExternalCRustBuffer { + return GoRustBuffer{ + inner: b, + } +} + +func CFromRustBuffer(b ExternalCRustBuffer) C.RustBuffer { + return C.RustBuffer{ + capacity: C.uint64_t(b.Capacity()), + len: C.uint64_t(b.Len()), + data: (*C.uchar)(b.Data()), + } +} + +func RustBufferFromExternal(b ExternalCRustBuffer) GoRustBuffer { + return GoRustBuffer{ + inner: C.RustBuffer{ + capacity: C.uint64_t(b.Capacity()), + len: C.uint64_t(b.Len()), + data: (*C.uchar)(b.Data()), + }, + } +} + +func (cb GoRustBuffer) Capacity() uint64 { + return uint64(cb.inner.capacity) +} + +func (cb GoRustBuffer) Len() uint64 { + return uint64(cb.inner.len) +} + +func (cb GoRustBuffer) Data() unsafe.Pointer { + return unsafe.Pointer(cb.inner.data) +} + +func (cb GoRustBuffer) AsReader() *bytes.Reader { + b := unsafe.Slice((*byte)(cb.inner.data), C.uint64_t(cb.inner.len)) + return bytes.NewReader(b) +} + +func (cb GoRustBuffer) Free() { + rustCall(func(status *C.RustCallStatus) bool { + C.ffi_uc_engine_uniffi_rustbuffer_free(cb.inner, status) + return false + }) +} + +func (cb GoRustBuffer) ToGoBytes() []byte { + return C.GoBytes(unsafe.Pointer(cb.inner.data), C.int(cb.inner.len)) +} + +func stringToRustBuffer(str string) C.RustBuffer { + return bytesToRustBuffer([]byte(str)) +} + +func bytesToRustBuffer(b []byte) C.RustBuffer { + if len(b) == 0 { + return C.RustBuffer{} + } + // We can pass the pointer along here, as it is pinned + // for the duration of this call + foreign := C.ForeignBytes{ + len: C.int(len(b)), + data: (*C.uchar)(unsafe.Pointer(&b[0])), + } + + return rustCall(func(status *C.RustCallStatus) C.RustBuffer { + return C.ffi_uc_engine_uniffi_rustbuffer_from_bytes(foreign, status) + }) +} + +type BufLifter[GoType any] interface { + Lift(value RustBufferI) GoType +} + +type BufLowerer[GoType any] interface { + Lower(value GoType) C.RustBuffer +} + +type BufReader[GoType any] interface { + Read(reader io.Reader) GoType +} + +type BufWriter[GoType any] interface { + Write(writer io.Writer, value GoType) +} + +func LowerIntoRustBuffer[GoType any](bufWriter BufWriter[GoType], value GoType) C.RustBuffer { + // This might be not the most efficient way but it does not require knowing allocation size + // beforehand + var buffer bytes.Buffer + bufWriter.Write(&buffer, value) + + bytes, err := io.ReadAll(&buffer) + if err != nil { + panic(fmt.Errorf("reading written data: %w", err)) + } + return bytesToRustBuffer(bytes) +} + +func LiftFromRustBuffer[GoType any](bufReader BufReader[GoType], rbuf RustBufferI) GoType { + defer rbuf.Free() + reader := rbuf.AsReader() + item := bufReader.Read(reader) + if reader.Len() > 0 { + // TODO: Remove this + leftover, _ := io.ReadAll(reader) + panic(fmt.Errorf("Junk remaining in buffer after lifting: %s", string(leftover))) + } + return item +} + +func rustCallWithError[E any, U any](converter BufReader[E], callback func(*C.RustCallStatus) U) (U, E) { + var status C.RustCallStatus + returnValue := callback(&status) + err := checkCallStatus(converter, status) + return returnValue, err +} + +func checkCallStatus[E any](converter BufReader[E], status C.RustCallStatus) E { + switch status.code { + case 0: + var zero E + return zero + case 1: + return LiftFromRustBuffer(converter, GoRustBuffer{inner: status.errorBuf}) + case 2: + // when the rust code sees a panic, it tries to construct a rustBuffer + // with the message. but if that code panics, then it just sends back + // an empty buffer. + if status.errorBuf.len > 0 { + panic(fmt.Errorf("%s", FfiConverterStringINSTANCE.Lift(GoRustBuffer{inner: status.errorBuf}))) + } else { + panic(fmt.Errorf("Rust panicked while handling Rust panic")) + } + default: + panic(fmt.Errorf("unknown status code: %d", status.code)) + } +} + +func checkCallStatusUnknown(status C.RustCallStatus) error { + switch status.code { + case 0: + return nil + case 1: + panic(fmt.Errorf("function not returning an error returned an error")) + case 2: + // when the rust code sees a panic, it tries to construct a C.RustBuffer + // with the message. but if that code panics, then it just sends back + // an empty buffer. + if status.errorBuf.len > 0 { + panic(fmt.Errorf("%s", FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: status.errorBuf, + }))) + } else { + panic(fmt.Errorf("Rust panicked while handling Rust panic")) + } + default: + return fmt.Errorf("unknown status code: %d", status.code) + } +} + +func rustCall[U any](callback func(*C.RustCallStatus) U) U { + returnValue, err := rustCallWithError[error](nil, callback) + if err != nil { + panic(err) + } + return returnValue +} + +type NativeError interface { + AsError() error +} + +func writeInt8(writer io.Writer, value int8) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeUint8(writer io.Writer, value uint8) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeInt16(writer io.Writer, value int16) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeUint16(writer io.Writer, value uint16) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeInt32(writer io.Writer, value int32) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeUint32(writer io.Writer, value uint32) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeInt64(writer io.Writer, value int64) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeUint64(writer io.Writer, value uint64) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeFloat32(writer io.Writer, value float32) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func writeFloat64(writer io.Writer, value float64) { + if err := binary.Write(writer, binary.BigEndian, value); err != nil { + panic(err) + } +} + +func readInt8(reader io.Reader) int8 { + var result int8 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readUint8(reader io.Reader) uint8 { + var result uint8 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readInt16(reader io.Reader) int16 { + var result int16 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readUint16(reader io.Reader) uint16 { + var result uint16 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readInt32(reader io.Reader) int32 { + var result int32 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readUint32(reader io.Reader) uint32 { + var result uint32 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readInt64(reader io.Reader) int64 { + var result int64 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readUint64(reader io.Reader) uint64 { + var result uint64 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readFloat32(reader io.Reader) float32 { + var result float32 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func readFloat64(reader io.Reader) float64 { + var result float64 + if err := binary.Read(reader, binary.BigEndian, &result); err != nil { + panic(err) + } + return result +} + +func init() { + + FfiConverterBindingAnalyticsHostINSTANCE.register() + FfiConverterBindingHostINSTANCE.register() + uniffiCheckChecksums() +} + +func uniffiCheckChecksums() { + // Get the bindings contract version from our ComponentInterface + bindingsContractVersion := 30 + // Get the scaffolding contract version by calling the into the dylib + scaffoldingContractVersion := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint32_t { + return C.ffi_uc_engine_uniffi_uniffi_contract_version() + }) + if bindingsContractVersion != int(scaffoldingContractVersion) { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: UniFFI contract version mismatch") + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_core_version() + }) + if checksum != 33681 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_core_version: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_flush_process_observability() + }) + if checksum != 21070 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_flush_process_observability: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_install_process_observability() + }) + if checksum != 47740 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_install_process_observability: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_query_process_observability_health() + }) + if checksum != 17532 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_query_process_observability_health: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_shutdown_process_observability() + }) + if checksum != 50929 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_shutdown_process_observability: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_prepare_local_diagnostic_export() + }) + if checksum != 64660 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_prepare_local_diagnostic_export: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_query_local_diagnostic_status() + }) + if checksum != 19411 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_query_local_diagnostic_status: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_record_host_diagnostic() + }) + if checksum != 28654 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_record_host_diagnostic: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_register_host_diagnostic_source() + }) + if checksum != 16115 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_register_host_diagnostic_source: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_start_local_diagnostic_capture() + }) + if checksum != 58064 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_start_local_diagnostic_capture: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_func_stop_local_diagnostic_capture() + }) + if checksum != 42842 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_func_stop_local_diagnostic_capture: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_capture() + }) + if checksum != 46569 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_capture: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_identify() + }) + if checksum != 31782 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_identify: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_group_identify() + }) + if checksum != 63274 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_group_identify: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_adopt_space_person() + }) + if checksum != 46798 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_adopt_space_person: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_release_space_person() + }) + if checksum != 46412 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_release_space_person: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_current_space_person_id() + }) + if checksum != 15586 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_current_space_person_id: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_reset_telemetry_identity() + }) + if checksum != 26792 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_reset_telemetry_identity: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_private_data_directory() + }) + if checksum != 2874 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_private_data_directory: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_cache_directory() + }) + if checksum != 2193 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_cache_directory: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_temporary_directory() + }) + if checksum != 23970 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_temporary_directory: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_get() + }) + if checksum != 19843 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_get: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_set() + }) + if checksum != 45581 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_set: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_delete() + }) + if checksum != 5374 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_delete: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_metadata() + }) + if checksum != 30202 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_metadata: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_read_chunk() + }) + if checksum != 40871 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_read_chunk: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_write_chunk() + }) + if checksum != 15520 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_write_chunk: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_finish_write() + }) + if checksum != 10603 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_finish_write: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_clipboard_read() + }) + if checksum != 44572 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_clipboard_read: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_bindinghost_clipboard_write() + }) + if checksum != 22129 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_bindinghost_clipboard_write: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_add_custom_relay() + }) + if checksum != 36381 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_add_custom_relay: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_cancel_join_space() + }) + if checksum != 49819 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_cancel_join_space: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_capture_current_clipboard() + }) + if checksum != 59446 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_capture_current_clipboard: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_change_encryption_passphrase() + }) + if checksum != 40324 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_change_encryption_passphrase: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_choose_device_group() + }) + if checksum != 2594 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_choose_device_group: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_create_space() + }) + if checksum != 21380 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_create_space: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_delete_custom_relay() + }) + if checksum != 1733 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_delete_custom_relay: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_edit_custom_relay() + }) + if checksum != 37096 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_edit_custom_relay: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_export_entry() + }) + if checksum != 3505 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_export_entry: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_issue_invitation() + }) + if checksum != 43331 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_issue_invitation: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_join_space() + }) + if checksum != 61423 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_join_space: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_leave_space() + }) + if checksum != 53173 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_leave_space: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_lifecycle_state() + }) + if checksum != 54350 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_lifecycle_state: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_list_devices() + }) + if checksum != 42635 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_list_devices: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_next_event() + }) + if checksum != 60947 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_next_event: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_notify_connectivity_opportunity() + }) + if checksum != 47459 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_notify_connectivity_opportunity: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_observe_clipboard_change() + }) + if checksum != 48343 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_observe_clipboard_change: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_active_clipboard() + }) + if checksum != 11249 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_active_clipboard: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_custom_relays() + }) + if checksum != 17925 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_custom_relays: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_device_group_choices() + }) + if checksum != 23271 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_device_group_choices: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_local_device() + }) + if checksum != 6632 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_local_device: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_network_recovery_status() + }) + if checksum != 43747 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_network_recovery_status: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_relay_overview() + }) + if checksum != 52676 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_relay_overview: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_space_state() + }) + if checksum != 25195 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_space_state: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_recover_network() + }) + if checksum != 42154 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_recover_network: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_recover_session() + }) + if checksum != 26112 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_recover_session: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_refresh_peer_connections() + }) + if checksum != 32331 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_refresh_peer_connections: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_remove_member() + }) + if checksum != 23868 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_remove_member: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_resend_entry() + }) + if checksum != 19924 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_resend_entry: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_restore_clipboard() + }) + if checksum != 59783 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_restore_clipboard: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_resume() + }) + if checksum != 12890 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_resume: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_save_custom_relay() + }) + if checksum != 38821 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_save_custom_relay: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_files() + }) + if checksum != 35463 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_files: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_image() + }) + if checksum != 2933 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_image: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_text() + }) + if checksum != 44276 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_text: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_shutdown() + }) + if checksum != 40531 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_shutdown: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_suspend() + }) + if checksum != 27030 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_suspend: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobileengine_suspend_with_deadline() + }) + if checksum != 2817 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobileengine_suspend_with_deadline: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_resume() + }) + if checksum != 48315 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_resume: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_suspend() + }) + if checksum != 15241 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_suspend: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_suspend_with_deadline() + }) + if checksum != 61789 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_suspend_with_deadline: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start() + }) + if checksum != 63033 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_analytics() + }) + if checksum != 35192 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_analytics: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_analytics_and_lifecycle() + }) + if checksum != 25026 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_analytics_and_lifecycle: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_lifecycle() + }) + if checksum != 16941 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_lifecycle: UniFFI API checksum mismatch") + } + } + { + checksum := rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint16_t { + return C.uniffi_uc_engine_uniffi_checksum_constructor_mobilestartuplifecycle_new() + }) + if checksum != 4465 { + // If this happens try cleaning and rebuilding your project + panic("uc_engine_uniffi: uniffi_uc_engine_uniffi_checksum_constructor_mobilestartuplifecycle_new: UniFFI API checksum mismatch") + } + } +} + +type FfiConverterUint32 struct{} + +var FfiConverterUint32INSTANCE = FfiConverterUint32{} + +func (FfiConverterUint32) Lower(value uint32) C.uint32_t { + return C.uint32_t(value) +} + +func (FfiConverterUint32) Write(writer io.Writer, value uint32) { + writeUint32(writer, value) +} + +func (FfiConverterUint32) Lift(value C.uint32_t) uint32 { + return uint32(value) +} + +func (FfiConverterUint32) Read(reader io.Reader) uint32 { + return readUint32(reader) +} + +type FfiDestroyerUint32 struct{} + +func (FfiDestroyerUint32) Destroy(_ uint32) {} + +type FfiConverterUint64 struct{} + +var FfiConverterUint64INSTANCE = FfiConverterUint64{} + +func (FfiConverterUint64) Lower(value uint64) C.uint64_t { + return C.uint64_t(value) +} + +func (FfiConverterUint64) Write(writer io.Writer, value uint64) { + writeUint64(writer, value) +} + +func (FfiConverterUint64) Lift(value C.uint64_t) uint64 { + return uint64(value) +} + +func (FfiConverterUint64) Read(reader io.Reader) uint64 { + return readUint64(reader) +} + +type FfiDestroyerUint64 struct{} + +func (FfiDestroyerUint64) Destroy(_ uint64) {} + +type FfiConverterInt64 struct{} + +var FfiConverterInt64INSTANCE = FfiConverterInt64{} + +func (FfiConverterInt64) Lower(value int64) C.int64_t { + return C.int64_t(value) +} + +func (FfiConverterInt64) Write(writer io.Writer, value int64) { + writeInt64(writer, value) +} + +func (FfiConverterInt64) Lift(value C.int64_t) int64 { + return int64(value) +} + +func (FfiConverterInt64) Read(reader io.Reader) int64 { + return readInt64(reader) +} + +type FfiDestroyerInt64 struct{} + +func (FfiDestroyerInt64) Destroy(_ int64) {} + +type FfiConverterBool struct{} + +var FfiConverterBoolINSTANCE = FfiConverterBool{} + +func (FfiConverterBool) Lower(value bool) C.int8_t { + if value { + return C.int8_t(1) + } + return C.int8_t(0) +} + +func (FfiConverterBool) Write(writer io.Writer, value bool) { + if value { + writeInt8(writer, 1) + } else { + writeInt8(writer, 0) + } +} + +func (FfiConverterBool) Lift(value C.int8_t) bool { + return value != 0 +} + +func (FfiConverterBool) Read(reader io.Reader) bool { + return readInt8(reader) != 0 +} + +type FfiDestroyerBool struct{} + +func (FfiDestroyerBool) Destroy(_ bool) {} + +type FfiConverterString struct{} + +var FfiConverterStringINSTANCE = FfiConverterString{} + +func (FfiConverterString) Lift(rb RustBufferI) string { + defer rb.Free() + reader := rb.AsReader() + b, err := io.ReadAll(reader) + if err != nil { + panic(fmt.Errorf("reading reader: %w", err)) + } + return string(b) +} + +func (FfiConverterString) Read(reader io.Reader) string { + length := readInt32(reader) + buffer := make([]byte, length) + read_length, err := reader.Read(buffer) + if err != nil && err != io.EOF { + panic(err) + } + if read_length != int(length) { + panic(fmt.Errorf("bad read length when reading string, expected %d, read %d", length, read_length)) + } + return string(buffer) +} + +func (FfiConverterString) Lower(value string) C.RustBuffer { + return stringToRustBuffer(value) +} + +func (c FfiConverterString) LowerExternal(value string) ExternalCRustBuffer { + return RustBufferFromC(stringToRustBuffer(value)) +} + +func (FfiConverterString) Write(writer io.Writer, value string) { + if len(value) > math.MaxInt32 { + panic("String is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + write_length, err := io.WriteString(writer, value) + if err != nil { + panic(err) + } + if write_length != len(value) { + panic(fmt.Errorf("bad write length when writing string, expected %d, written %d", len(value), write_length)) + } +} + +type FfiDestroyerString struct{} + +func (FfiDestroyerString) Destroy(_ string) {} + +type FfiConverterBytes struct{} + +var FfiConverterBytesINSTANCE = FfiConverterBytes{} + +func (c FfiConverterBytes) Lower(value []byte) C.RustBuffer { + return LowerIntoRustBuffer[[]byte](c, value) +} + +func (c FfiConverterBytes) LowerExternal(value []byte) ExternalCRustBuffer { + return RustBufferFromC(c.Lower(value)) +} + +func (c FfiConverterBytes) Write(writer io.Writer, value []byte) { + if len(value) > math.MaxInt32 { + panic("[]byte is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + write_length, err := writer.Write(value) + if err != nil { + panic(err) + } + if write_length != len(value) { + panic(fmt.Errorf("bad write length when writing []byte, expected %d, written %d", len(value), write_length)) + } +} + +func (c FfiConverterBytes) Lift(rb RustBufferI) []byte { + return LiftFromRustBuffer[[]byte](c, rb) +} + +func (c FfiConverterBytes) Read(reader io.Reader) []byte { + length := readInt32(reader) + buffer := make([]byte, length) + read_length, err := reader.Read(buffer) + if err != nil && err != io.EOF { + panic(err) + } + if read_length != int(length) { + panic(fmt.Errorf("bad read length when reading []byte, expected %d, read %d", length, read_length)) + } + return buffer +} + +type FfiDestroyerBytes struct{} + +func (FfiDestroyerBytes) Destroy(_ []byte) {} + +// Below is an implementation of synchronization requirements outlined in the link. +// https://github.com/mozilla/uniffi-rs/blob/0dc031132d9493ca812c3af6e7dd60ad2ea95bf0/uniffi_bindgen/src/bindings/kotlin/templates/ObjectRuntime.kt#L31 + +type FfiObject struct { + handle C.uint64_t + callCounter atomic.Int64 + cloneFunction func(C.uint64_t, *C.RustCallStatus) C.uint64_t + freeFunction func(C.uint64_t, *C.RustCallStatus) + destroyed atomic.Bool +} + +func newFfiObject( + handle C.uint64_t, + cloneFunction func(C.uint64_t, *C.RustCallStatus) C.uint64_t, + freeFunction func(C.uint64_t, *C.RustCallStatus), +) FfiObject { + return FfiObject{ + handle: handle, + cloneFunction: cloneFunction, + freeFunction: freeFunction, + } +} + +func (ffiObject *FfiObject) incrementPointer(debugName string) C.uint64_t { + for { + counter := ffiObject.callCounter.Load() + if counter <= -1 { + panic(fmt.Errorf("%v object has already been destroyed", debugName)) + } + if counter == math.MaxInt64 { + panic(fmt.Errorf("%v object call counter would overflow", debugName)) + } + if ffiObject.callCounter.CompareAndSwap(counter, counter+1) { + break + } + } + + return rustCall(func(status *C.RustCallStatus) C.uint64_t { + return ffiObject.cloneFunction(ffiObject.handle, status) + }) +} + +func (ffiObject *FfiObject) decrementPointer() { + if ffiObject.callCounter.Add(-1) == -1 { + ffiObject.freeRustArcPtr() + } +} + +func (ffiObject *FfiObject) destroy() { + if ffiObject.destroyed.CompareAndSwap(false, true) { + if ffiObject.callCounter.Add(-1) == -1 { + ffiObject.freeRustArcPtr() + } + } +} + +func (ffiObject *FfiObject) freeRustArcPtr() { + if ffiObject.handle == 0 { + return + } + rustCall(func(status *C.RustCallStatus) int32 { + ffiObject.freeFunction(ffiObject.handle, status) + return 0 + }) +} + +type BindingAnalyticsHost interface { + Capture(event BindingAnalyticsEvent) error + Identify(payload BindingAnalyticsIdentify) error + GroupIdentify(payload BindingAnalyticsGroupIdentify) error + AdoptSpacePerson(spacePersonId string) (BindingAnalyticsIdentityChange, error) + ReleaseSpacePerson() (BindingAnalyticsIdentityChange, error) + CurrentSpacePersonId() (*string, error) + ResetTelemetryIdentity() (BindingAnalyticsIdentityChange, error) +} +type BindingAnalyticsHostImpl struct { + ffiObject FfiObject +} + +func (_self *BindingAnalyticsHostImpl) Capture(event BindingAnalyticsEvent) error { + _pointer := _self.ffiObject.incrementPointer("BindingAnalyticsHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingAnalyticsHostError](FfiConverterBindingAnalyticsHostError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_capture( + _pointer, FfiConverterBindingAnalyticsEventINSTANCE.Lower(event), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *BindingAnalyticsHostImpl) Identify(payload BindingAnalyticsIdentify) error { + _pointer := _self.ffiObject.incrementPointer("BindingAnalyticsHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingAnalyticsHostError](FfiConverterBindingAnalyticsHostError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_identify( + _pointer, FfiConverterBindingAnalyticsIdentifyINSTANCE.Lower(payload), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *BindingAnalyticsHostImpl) GroupIdentify(payload BindingAnalyticsGroupIdentify) error { + _pointer := _self.ffiObject.incrementPointer("BindingAnalyticsHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingAnalyticsHostError](FfiConverterBindingAnalyticsHostError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_group_identify( + _pointer, FfiConverterBindingAnalyticsGroupIdentifyINSTANCE.Lower(payload), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *BindingAnalyticsHostImpl) AdoptSpacePerson(spacePersonId string) (BindingAnalyticsIdentityChange, error) { + _pointer := _self.ffiObject.incrementPointer("BindingAnalyticsHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingAnalyticsHostError](FfiConverterBindingAnalyticsHostError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_adopt_space_person( + _pointer, FfiConverterStringINSTANCE.Lower(spacePersonId), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingAnalyticsIdentityChange + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingAnalyticsIdentityChangeINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingAnalyticsHostImpl) ReleaseSpacePerson() (BindingAnalyticsIdentityChange, error) { + _pointer := _self.ffiObject.incrementPointer("BindingAnalyticsHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingAnalyticsHostError](FfiConverterBindingAnalyticsHostError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_release_space_person( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingAnalyticsIdentityChange + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingAnalyticsIdentityChangeINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingAnalyticsHostImpl) CurrentSpacePersonId() (*string, error) { + _pointer := _self.ffiObject.incrementPointer("BindingAnalyticsHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingAnalyticsHostError](FfiConverterBindingAnalyticsHostError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_current_space_person_id( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterOptionalStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingAnalyticsHostImpl) ResetTelemetryIdentity() (BindingAnalyticsIdentityChange, error) { + _pointer := _self.ffiObject.incrementPointer("BindingAnalyticsHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingAnalyticsHostError](FfiConverterBindingAnalyticsHostError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_reset_telemetry_identity( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingAnalyticsIdentityChange + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingAnalyticsIdentityChangeINSTANCE.Lift(_uniffiRV), nil + } +} +func (object *BindingAnalyticsHostImpl) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterBindingAnalyticsHost struct { + handleMap *concurrentHandleMap[BindingAnalyticsHost] +} + +var FfiConverterBindingAnalyticsHostINSTANCE = FfiConverterBindingAnalyticsHost{ + handleMap: newConcurrentHandleMap[BindingAnalyticsHost](), +} + +func (c FfiConverterBindingAnalyticsHost) Lift(handle C.uint64_t) BindingAnalyticsHost { + if uint64(handle)&1 == 0 { + // Rust-generated handle (even), construct a new object wrapping the handle + result := &BindingAnalyticsHostImpl{ + newFfiObject( + handle, + func(handle C.uint64_t, status *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_clone_bindinganalyticshost(handle, status) + }, + func(handle C.uint64_t, status *C.RustCallStatus) { + C.uniffi_uc_engine_uniffi_fn_free_bindinganalyticshost(handle, status) + }, + ), + } + runtime.SetFinalizer(result, (*BindingAnalyticsHostImpl).Destroy) + return result + } else { + // Go-generated handle (odd), retrieve from the handle map + val, ok := c.handleMap.tryGet(uint64(handle)) + if !ok { + panic(fmt.Errorf("no callback in handle map: %d", handle)) + } + c.handleMap.remove(uint64(handle)) + return val + } +} + +func (c FfiConverterBindingAnalyticsHost) Read(reader io.Reader) BindingAnalyticsHost { + return c.Lift(C.uint64_t(readUint64(reader))) +} + +func (c FfiConverterBindingAnalyticsHost) Lower(value BindingAnalyticsHost) C.uint64_t { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the handle will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked handle. + if val, ok := value.(*BindingAnalyticsHostImpl); ok { + // Rust-backed object, clone the handle + handle := val.ffiObject.incrementPointer("BindingAnalyticsHost") + defer val.ffiObject.decrementPointer() + return handle + } else { + // Go-backed object, insert into handle map + return C.uint64_t(c.handleMap.insert(value)) + } +} + +func (c FfiConverterBindingAnalyticsHost) Write(writer io.Writer, value BindingAnalyticsHost) { + writeUint64(writer, uint64(c.Lower(value))) +} + +func LiftFromExternalBindingAnalyticsHost(handle uint64) BindingAnalyticsHost { + return FfiConverterBindingAnalyticsHostINSTANCE.Lift(C.uint64_t(handle)) +} + +func LowerToExternalBindingAnalyticsHost(value BindingAnalyticsHost) uint64 { + return uint64(FfiConverterBindingAnalyticsHostINSTANCE.Lower(value)) +} + +type FfiDestroyerBindingAnalyticsHost struct{} + +func (_ FfiDestroyerBindingAnalyticsHost) Destroy(value BindingAnalyticsHost) { + if val, ok := value.(*BindingAnalyticsHostImpl); ok { + val.Destroy() + } +} + +type uniffiCallbackResult C.int8_t + +const ( + uniffiIdxCallbackFree uniffiCallbackResult = 0 + uniffiCallbackResultSuccess uniffiCallbackResult = 0 + uniffiCallbackResultError uniffiCallbackResult = 1 + uniffiCallbackUnexpectedResultError uniffiCallbackResult = 2 + uniffiCallbackCancelled uniffiCallbackResult = 3 +) + +type concurrentHandleMap[T any] struct { + handles map[uint64]T + currentHandle uint64 + lock sync.RWMutex +} + +func newConcurrentHandleMap[T any]() *concurrentHandleMap[T] { + return &concurrentHandleMap[T]{ + handles: map[uint64]T{}, + currentHandle: 1, + } +} + +func (cm *concurrentHandleMap[T]) insert(obj T) uint64 { + cm.lock.Lock() + defer cm.lock.Unlock() + + handle := cm.currentHandle + cm.currentHandle = cm.currentHandle + 2 + cm.handles[handle] = obj + return handle +} + +func (cm *concurrentHandleMap[T]) remove(handle uint64) { + cm.lock.Lock() + defer cm.lock.Unlock() + + delete(cm.handles, handle) +} + +func (cm *concurrentHandleMap[T]) tryGet(handle uint64) (T, bool) { + cm.lock.RLock() + defer cm.lock.RUnlock() + + val, ok := cm.handles[handle] + return val, ok +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod0 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod0(uniffiHandle C.uint64_t, event C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.Capture( + FfiConverterBindingAnalyticsEventINSTANCE.Lift(GoRustBuffer{ + inner: event, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *BindingAnalyticsHostError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterBindingAnalyticsHostErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod1 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod1(uniffiHandle C.uint64_t, payload C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.Identify( + FfiConverterBindingAnalyticsIdentifyINSTANCE.Lift(GoRustBuffer{ + inner: payload, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *BindingAnalyticsHostError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterBindingAnalyticsHostErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod2 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod2(uniffiHandle C.uint64_t, payload C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.GroupIdentify( + FfiConverterBindingAnalyticsGroupIdentifyINSTANCE.Lift(GoRustBuffer{ + inner: payload, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *BindingAnalyticsHostError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterBindingAnalyticsHostErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod3 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod3(uniffiHandle C.uint64_t, spacePersonId C.RustBuffer, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.AdoptSpacePerson( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: spacePersonId, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *BindingAnalyticsHostError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterBindingAnalyticsHostErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterBindingAnalyticsIdentityChangeINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod4 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod4(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.ReleaseSpacePerson() + + if _uniffiErr != nil { + var _uniffiActualError *BindingAnalyticsHostError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterBindingAnalyticsHostErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterBindingAnalyticsIdentityChangeINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod5 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod5(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.CurrentSpacePersonId() + + if _uniffiErr != nil { + var _uniffiActualError *BindingAnalyticsHostError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterBindingAnalyticsHostErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterOptionalStringINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod6 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod6(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.ResetTelemetryIdentity() + + if _uniffiErr != nil { + var _uniffiActualError *BindingAnalyticsHostError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterBindingAnalyticsHostErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterBindingAnalyticsIdentityChangeINSTANCE.Lower(_uniffiRes) +} + +var UniffiVTableCallbackInterfaceBindingAnalyticsHostINSTANCE = C.UniffiVTableCallbackInterfaceBindingAnalyticsHost{ + uniffiFree: (C.UniffiCallbackInterfaceFree)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostFree), + uniffiClone: (C.UniffiCallbackInterfaceClone)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostClone), + capture: (C.UniffiCallbackInterfaceBindingAnalyticsHostMethod0)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod0), + identify: (C.UniffiCallbackInterfaceBindingAnalyticsHostMethod1)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod1), + groupIdentify: (C.UniffiCallbackInterfaceBindingAnalyticsHostMethod2)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod2), + adoptSpacePerson: (C.UniffiCallbackInterfaceBindingAnalyticsHostMethod3)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod3), + releaseSpacePerson: (C.UniffiCallbackInterfaceBindingAnalyticsHostMethod4)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod4), + currentSpacePersonId: (C.UniffiCallbackInterfaceBindingAnalyticsHostMethod5)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod5), + resetTelemetryIdentity: (C.UniffiCallbackInterfaceBindingAnalyticsHostMethod6)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod6), +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostFree +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostFree(handle C.uint64_t) { + FfiConverterBindingAnalyticsHostINSTANCE.handleMap.remove(uint64(handle)) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostClone +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostClone(handle C.uint64_t) C.uint64_t { + val, ok := FfiConverterBindingAnalyticsHostINSTANCE.handleMap.tryGet(uint64(handle)) + if !ok { + panic(fmt.Errorf("no callback in handle map: %d", handle)) + } + return C.uint64_t(FfiConverterBindingAnalyticsHostINSTANCE.handleMap.insert(val)) +} + +func (c FfiConverterBindingAnalyticsHost) register() { + C.uniffi_uc_engine_uniffi_fn_init_callback_vtable_bindinganalyticshost(&UniffiVTableCallbackInterfaceBindingAnalyticsHostINSTANCE) +} + +type BindingHost interface { + PrivateDataDirectory() (string, error) + CacheDirectory() (string, error) + TemporaryDirectory() (string, error) + SecureStorageGet(key string) (*[]byte, error) + SecureStorageSet(key string, value []byte) error + SecureStorageDelete(key string) error + FileMetadata(handle string) (BindingFileMetadata, error) + FileReadChunk(handle string, offset uint64, maxBytes uint32) ([]byte, error) + FileWriteChunk(handle string, offset uint64, bytes []byte) error + FileFinishWrite(handle string) error + ClipboardRead() (BindingClipboardSnapshot, error) + ClipboardWrite(snapshot BindingClipboardSnapshot) error +} +type BindingHostImpl struct { + ffiObject FfiObject +} + +func (_self *BindingHostImpl) PrivateDataDirectory() (string, error) { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinghost_private_data_directory( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingHostImpl) CacheDirectory() (string, error) { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinghost_cache_directory( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingHostImpl) TemporaryDirectory() (string, error) { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinghost_temporary_directory( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingHostImpl) SecureStorageGet(key string) (*[]byte, error) { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinghost_secure_storage_get( + _pointer, FfiConverterStringINSTANCE.Lower(key), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *[]byte + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterOptionalBytesINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingHostImpl) SecureStorageSet(key string, value []byte) error { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinghost_secure_storage_set( + _pointer, FfiConverterStringINSTANCE.Lower(key), FfiConverterBytesINSTANCE.Lower(value), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *BindingHostImpl) SecureStorageDelete(key string) error { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinghost_secure_storage_delete( + _pointer, FfiConverterStringINSTANCE.Lower(key), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *BindingHostImpl) FileMetadata(handle string) (BindingFileMetadata, error) { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinghost_file_metadata( + _pointer, FfiConverterStringINSTANCE.Lower(handle), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingFileMetadata + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingFileMetadataINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingHostImpl) FileReadChunk(handle string, offset uint64, maxBytes uint32) ([]byte, error) { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinghost_file_read_chunk( + _pointer, FfiConverterStringINSTANCE.Lower(handle), FfiConverterUint64INSTANCE.Lower(offset), FfiConverterUint32INSTANCE.Lower(maxBytes), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue []byte + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBytesINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingHostImpl) FileWriteChunk(handle string, offset uint64, bytes []byte) error { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinghost_file_write_chunk( + _pointer, FfiConverterStringINSTANCE.Lower(handle), FfiConverterUint64INSTANCE.Lower(offset), FfiConverterBytesINSTANCE.Lower(bytes), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *BindingHostImpl) FileFinishWrite(handle string) error { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinghost_file_finish_write( + _pointer, FfiConverterStringINSTANCE.Lower(handle), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *BindingHostImpl) ClipboardRead() (BindingClipboardSnapshot, error) { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_bindinghost_clipboard_read( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingClipboardSnapshot + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingClipboardSnapshotINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *BindingHostImpl) ClipboardWrite(snapshot BindingClipboardSnapshot) error { + _pointer := _self.ffiObject.incrementPointer("BindingHost") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*HostBindingError](FfiConverterHostBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_bindinghost_clipboard_write( + _pointer, FfiConverterBindingClipboardSnapshotINSTANCE.Lower(snapshot), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} +func (object *BindingHostImpl) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterBindingHost struct { + handleMap *concurrentHandleMap[BindingHost] +} + +var FfiConverterBindingHostINSTANCE = FfiConverterBindingHost{ + handleMap: newConcurrentHandleMap[BindingHost](), +} + +func (c FfiConverterBindingHost) Lift(handle C.uint64_t) BindingHost { + if uint64(handle)&1 == 0 { + // Rust-generated handle (even), construct a new object wrapping the handle + result := &BindingHostImpl{ + newFfiObject( + handle, + func(handle C.uint64_t, status *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_clone_bindinghost(handle, status) + }, + func(handle C.uint64_t, status *C.RustCallStatus) { + C.uniffi_uc_engine_uniffi_fn_free_bindinghost(handle, status) + }, + ), + } + runtime.SetFinalizer(result, (*BindingHostImpl).Destroy) + return result + } else { + // Go-generated handle (odd), retrieve from the handle map + val, ok := c.handleMap.tryGet(uint64(handle)) + if !ok { + panic(fmt.Errorf("no callback in handle map: %d", handle)) + } + c.handleMap.remove(uint64(handle)) + return val + } +} + +func (c FfiConverterBindingHost) Read(reader io.Reader) BindingHost { + return c.Lift(C.uint64_t(readUint64(reader))) +} + +func (c FfiConverterBindingHost) Lower(value BindingHost) C.uint64_t { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the handle will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked handle. + if val, ok := value.(*BindingHostImpl); ok { + // Rust-backed object, clone the handle + handle := val.ffiObject.incrementPointer("BindingHost") + defer val.ffiObject.decrementPointer() + return handle + } else { + // Go-backed object, insert into handle map + return C.uint64_t(c.handleMap.insert(value)) + } +} + +func (c FfiConverterBindingHost) Write(writer io.Writer, value BindingHost) { + writeUint64(writer, uint64(c.Lower(value))) +} + +func LiftFromExternalBindingHost(handle uint64) BindingHost { + return FfiConverterBindingHostINSTANCE.Lift(C.uint64_t(handle)) +} + +func LowerToExternalBindingHost(value BindingHost) uint64 { + return uint64(FfiConverterBindingHostINSTANCE.Lower(value)) +} + +type FfiDestroyerBindingHost struct{} + +func (_ FfiDestroyerBindingHost) Destroy(value BindingHost) { + if val, ok := value.(*BindingHostImpl); ok { + val.Destroy() + } +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod0 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod0(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.PrivateDataDirectory() + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterStringINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod1 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod1(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.CacheDirectory() + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterStringINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod2 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod2(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.TemporaryDirectory() + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterStringINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod3 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod3(uniffiHandle C.uint64_t, key C.RustBuffer, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.SecureStorageGet( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: key, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterOptionalBytesINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod4 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod4(uniffiHandle C.uint64_t, key C.RustBuffer, value C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.SecureStorageSet( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: key, + }), + FfiConverterBytesINSTANCE.Lift(GoRustBuffer{ + inner: value, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod5 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod5(uniffiHandle C.uint64_t, key C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.SecureStorageDelete( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: key, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod6 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod6(uniffiHandle C.uint64_t, handle C.RustBuffer, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.FileMetadata( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: handle, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterBindingFileMetadataINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod7 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod7(uniffiHandle C.uint64_t, handle C.RustBuffer, offset C.uint64_t, maxBytes C.uint32_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.FileReadChunk( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: handle, + }), + FfiConverterUint64INSTANCE.Lift(offset), + FfiConverterUint32INSTANCE.Lift(maxBytes), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterBytesINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod8 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod8(uniffiHandle C.uint64_t, handle C.RustBuffer, offset C.uint64_t, bytes C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.FileWriteChunk( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: handle, + }), + FfiConverterUint64INSTANCE.Lift(offset), + FfiConverterBytesINSTANCE.Lift(GoRustBuffer{ + inner: bytes, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod9 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod9(uniffiHandle C.uint64_t, handle C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.FileFinishWrite( + FfiConverterStringINSTANCE.Lift(GoRustBuffer{ + inner: handle, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod10 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod10(uniffiHandle C.uint64_t, uniffiOutReturn *C.RustBuffer, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiRes, _uniffiErr := + _uniffiObj.ClipboardRead() + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + + *uniffiOutReturn = FfiConverterBindingClipboardSnapshotINSTANCE.Lower(_uniffiRes) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod11 +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod11(uniffiHandle C.uint64_t, snapshot C.RustBuffer, uniffiOutReturn *C.void, callStatus *C.RustCallStatus) { + _uniffiCallbackHandle := uint64(uniffiHandle) + _uniffiObj, _uniffiOk := FfiConverterBindingHostINSTANCE.handleMap.tryGet(_uniffiCallbackHandle) + if !_uniffiOk { + panic(fmt.Errorf("no callback in handle map: %d", _uniffiCallbackHandle)) + } + + _uniffiErr := + _uniffiObj.ClipboardWrite( + FfiConverterBindingClipboardSnapshotINSTANCE.Lift(GoRustBuffer{ + inner: snapshot, + }), + ) + + if _uniffiErr != nil { + var _uniffiActualError *HostBindingError + if errors.As(_uniffiErr, &_uniffiActualError) { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackResultError), + errorBuf: FfiConverterHostBindingErrorINSTANCE.Lower(_uniffiActualError), + } + } else { + *callStatus = C.RustCallStatus{ + code: C.int8_t(uniffiCallbackUnexpectedResultError), + } + } + return + } + +} + +var UniffiVTableCallbackInterfaceBindingHostINSTANCE = C.UniffiVTableCallbackInterfaceBindingHost{ + uniffiFree: (C.UniffiCallbackInterfaceFree)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostFree), + uniffiClone: (C.UniffiCallbackInterfaceClone)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostClone), + privateDataDirectory: (C.UniffiCallbackInterfaceBindingHostMethod0)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod0), + cacheDirectory: (C.UniffiCallbackInterfaceBindingHostMethod1)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod1), + temporaryDirectory: (C.UniffiCallbackInterfaceBindingHostMethod2)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod2), + secureStorageGet: (C.UniffiCallbackInterfaceBindingHostMethod3)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod3), + secureStorageSet: (C.UniffiCallbackInterfaceBindingHostMethod4)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod4), + secureStorageDelete: (C.UniffiCallbackInterfaceBindingHostMethod5)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod5), + fileMetadata: (C.UniffiCallbackInterfaceBindingHostMethod6)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod6), + fileReadChunk: (C.UniffiCallbackInterfaceBindingHostMethod7)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod7), + fileWriteChunk: (C.UniffiCallbackInterfaceBindingHostMethod8)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod8), + fileFinishWrite: (C.UniffiCallbackInterfaceBindingHostMethod9)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod9), + clipboardRead: (C.UniffiCallbackInterfaceBindingHostMethod10)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod10), + clipboardWrite: (C.UniffiCallbackInterfaceBindingHostMethod11)(C.uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod11), +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostFree +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostFree(handle C.uint64_t) { + FfiConverterBindingHostINSTANCE.handleMap.remove(uint64(handle)) +} + +//export uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostClone +func uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostClone(handle C.uint64_t) C.uint64_t { + val, ok := FfiConverterBindingHostINSTANCE.handleMap.tryGet(uint64(handle)) + if !ok { + panic(fmt.Errorf("no callback in handle map: %d", handle)) + } + return C.uint64_t(FfiConverterBindingHostINSTANCE.handleMap.insert(val)) +} + +func (c FfiConverterBindingHost) register() { + C.uniffi_uc_engine_uniffi_fn_init_callback_vtable_bindinghost(&UniffiVTableCallbackInterfaceBindingHostINSTANCE) +} + +type MobileEngineInterface interface { + AddCustomRelay(url string, accessToken string) (CustomRelayMutationResult, error) + CancelJoinSpace(joinId string) (JoinSpaceStatus, error) + CaptureCurrentClipboard() (*string, error) + ChangeEncryptionPassphrase(passphrase string, passphraseConfirmation string) error + ChooseDeviceGroup(issueId string, choiceId string, expectedRevision uint64, confirmLocalRemoval bool) (string, error) + CreateSpace(deviceName *string, passphrase string) (SpaceCreated, error) + DeleteCustomRelay(url string) (CustomRelayMutationResult, error) + EditCustomRelay(previousUrl string, url string, accessToken string) (CustomRelayMutationResult, error) + ExportEntry(entryId string, destinationHandle string) error + IssueInvitation() (InvitationIssued, error) + JoinSpace(invitationCode string, deviceName *string, passphrase string, preserveUnreadableHistory bool) (JoinSpaceStatus, error) + LeaveSpace() error + LifecycleState() (BindingEngineState, error) + ListDevices() ([]Device, error) + NextEvent(timeoutMs uint64) *BindingEvent + NotifyConnectivityOpportunity(reason ConnectivityOpportunity) error + ObserveClipboardChange(dispatch bool) (*SendReport, error) + QueryActiveClipboard() (*ActiveClipboard, error) + QueryCustomRelays() ([]CustomRelay, error) + QueryDeviceGroupChoices() (string, error) + QueryLocalDevice() (LocalDevice, error) + QueryNetworkRecoveryStatus() (NetworkRecoveryStatus, error) + QueryRelayOverview() (RelayOverview, error) + QuerySpaceState() (SpaceState, error) + RecoverNetwork() error + RecoverSession(allowSecureStorageUnlock bool) (SessionRecovery, error) + RefreshPeerConnections() (PeerConnectionRefresh, error) + RemoveMember(deviceId string) (WorkspaceConvergence, error) + ResendEntry(entryId string, targetDevices []string) (ResendEntryOutcome, error) + RestoreClipboard(entryId string, mode BindingClipboardRestoreMode) (BindingClipboardRestoreOutcome, error) + Resume() error + SaveCustomRelay(url string, accessToken string, previousUrl *string) (RelaySaveResult, error) + SendFiles(fileHandles []string, targetDevices []string) (SendReport, error) + SendImage(bytes []byte, mimeType string, targetDevices []string) (SendReport, error) + SendText(text string, targetDevices []string) (SendReport, error) + Shutdown(deadlineMs uint64) error + Suspend() error + SuspendWithDeadline(deadlineMs uint64) error +} +type MobileEngine struct { + ffiObject FfiObject +} + +func MobileEngineStart(config BindingConfig, host BindingHost) (*MobileEngine, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start(FfiConverterBindingConfigINSTANCE.Lower(config), FfiConverterBindingHostINSTANCE.Lower(host), _uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *MobileEngine + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterMobileEngineINSTANCE.Lift(_uniffiRV), nil + } +} + +func MobileEngineStartWithAnalytics(config BindingConfig, host BindingHost, analytics BindingAnalyticsHost, context BindingAnalyticsContext) (*MobileEngine, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start_with_analytics(FfiConverterBindingConfigINSTANCE.Lower(config), FfiConverterBindingHostINSTANCE.Lower(host), FfiConverterBindingAnalyticsHostINSTANCE.Lower(analytics), FfiConverterBindingAnalyticsContextINSTANCE.Lower(context), _uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *MobileEngine + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterMobileEngineINSTANCE.Lift(_uniffiRV), nil + } +} + +func MobileEngineStartWithAnalyticsAndLifecycle(config BindingConfig, host BindingHost, analytics BindingAnalyticsHost, context BindingAnalyticsContext, lifecycle *MobileStartupLifecycle) (*MobileEngine, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start_with_analytics_and_lifecycle(FfiConverterBindingConfigINSTANCE.Lower(config), FfiConverterBindingHostINSTANCE.Lower(host), FfiConverterBindingAnalyticsHostINSTANCE.Lower(analytics), FfiConverterBindingAnalyticsContextINSTANCE.Lower(context), FfiConverterMobileStartupLifecycleINSTANCE.Lower(lifecycle), _uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *MobileEngine + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterMobileEngineINSTANCE.Lift(_uniffiRV), nil + } +} + +func MobileEngineStartWithLifecycle(config BindingConfig, host BindingHost, lifecycle *MobileStartupLifecycle) (*MobileEngine, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start_with_lifecycle(FfiConverterBindingConfigINSTANCE.Lower(config), FfiConverterBindingHostINSTANCE.Lower(host), FfiConverterMobileStartupLifecycleINSTANCE.Lower(lifecycle), _uniffiStatus) + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *MobileEngine + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterMobileEngineINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) AddCustomRelay(url string, accessToken string) (CustomRelayMutationResult, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_add_custom_relay( + _pointer, FfiConverterStringINSTANCE.Lower(url), FfiConverterStringINSTANCE.Lower(accessToken), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue CustomRelayMutationResult + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterCustomRelayMutationResultINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) CancelJoinSpace(joinId string) (JoinSpaceStatus, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_cancel_join_space( + _pointer, FfiConverterStringINSTANCE.Lower(joinId), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue JoinSpaceStatus + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterJoinSpaceStatusINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) CaptureCurrentClipboard() (*string, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_capture_current_clipboard( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterOptionalStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) ChangeEncryptionPassphrase(passphrase string, passphraseConfirmation string) error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_change_encryption_passphrase( + _pointer, FfiConverterStringINSTANCE.Lower(passphrase), FfiConverterStringINSTANCE.Lower(passphraseConfirmation), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) ChooseDeviceGroup(issueId string, choiceId string, expectedRevision uint64, confirmLocalRemoval bool) (string, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_choose_device_group( + _pointer, FfiConverterStringINSTANCE.Lower(issueId), FfiConverterStringINSTANCE.Lower(choiceId), FfiConverterUint64INSTANCE.Lower(expectedRevision), FfiConverterBoolINSTANCE.Lower(confirmLocalRemoval), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) CreateSpace(deviceName *string, passphrase string) (SpaceCreated, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_create_space( + _pointer, FfiConverterOptionalStringINSTANCE.Lower(deviceName), FfiConverterStringINSTANCE.Lower(passphrase), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue SpaceCreated + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSpaceCreatedINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) DeleteCustomRelay(url string) (CustomRelayMutationResult, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_delete_custom_relay( + _pointer, FfiConverterStringINSTANCE.Lower(url), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue CustomRelayMutationResult + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterCustomRelayMutationResultINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) EditCustomRelay(previousUrl string, url string, accessToken string) (CustomRelayMutationResult, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_edit_custom_relay( + _pointer, FfiConverterStringINSTANCE.Lower(previousUrl), FfiConverterStringINSTANCE.Lower(url), FfiConverterStringINSTANCE.Lower(accessToken), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue CustomRelayMutationResult + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterCustomRelayMutationResultINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) ExportEntry(entryId string, destinationHandle string) error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_export_entry( + _pointer, FfiConverterStringINSTANCE.Lower(entryId), FfiConverterStringINSTANCE.Lower(destinationHandle), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) IssueInvitation() (InvitationIssued, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_issue_invitation( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue InvitationIssued + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterInvitationIssuedINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) JoinSpace(invitationCode string, deviceName *string, passphrase string, preserveUnreadableHistory bool) (JoinSpaceStatus, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_join_space( + _pointer, FfiConverterStringINSTANCE.Lower(invitationCode), FfiConverterOptionalStringINSTANCE.Lower(deviceName), FfiConverterStringINSTANCE.Lower(passphrase), FfiConverterBoolINSTANCE.Lower(preserveUnreadableHistory), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue JoinSpaceStatus + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterJoinSpaceStatusINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) LeaveSpace() error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_leave_space( + _pointer, _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) LifecycleState() (BindingEngineState, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_lifecycle_state( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingEngineState + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingEngineStateINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) ListDevices() ([]Device, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_list_devices( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue []Device + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSequenceDeviceINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) NextEvent(timeoutMs uint64) *BindingEvent { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + return FfiConverterOptionalBindingEventINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_next_event( + _pointer, FfiConverterUint64INSTANCE.Lower(timeoutMs), _uniffiStatus), + } + })) +} + +func (_self *MobileEngine) NotifyConnectivityOpportunity(reason ConnectivityOpportunity) error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_notify_connectivity_opportunity( + _pointer, FfiConverterConnectivityOpportunityINSTANCE.Lower(reason), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) ObserveClipboardChange(dispatch bool) (*SendReport, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_observe_clipboard_change( + _pointer, FfiConverterBoolINSTANCE.Lower(dispatch), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *SendReport + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterOptionalSendReportINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) QueryActiveClipboard() (*ActiveClipboard, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_query_active_clipboard( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue *ActiveClipboard + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterOptionalActiveClipboardINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) QueryCustomRelays() ([]CustomRelay, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_query_custom_relays( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue []CustomRelay + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSequenceCustomRelayINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) QueryDeviceGroupChoices() (string, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_query_device_group_choices( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue string + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterStringINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) QueryLocalDevice() (LocalDevice, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_query_local_device( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue LocalDevice + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterLocalDeviceINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) QueryNetworkRecoveryStatus() (NetworkRecoveryStatus, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_query_network_recovery_status( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue NetworkRecoveryStatus + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterNetworkRecoveryStatusINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) QueryRelayOverview() (RelayOverview, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_query_relay_overview( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue RelayOverview + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterRelayOverviewINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) QuerySpaceState() (SpaceState, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_query_space_state( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue SpaceState + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSpaceStateINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) RecoverNetwork() error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_recover_network( + _pointer, _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) RecoverSession(allowSecureStorageUnlock bool) (SessionRecovery, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_recover_session( + _pointer, FfiConverterBoolINSTANCE.Lower(allowSecureStorageUnlock), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue SessionRecovery + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSessionRecoveryINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) RefreshPeerConnections() (PeerConnectionRefresh, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_refresh_peer_connections( + _pointer, _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue PeerConnectionRefresh + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterPeerConnectionRefreshINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) RemoveMember(deviceId string) (WorkspaceConvergence, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_remove_member( + _pointer, FfiConverterStringINSTANCE.Lower(deviceId), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue WorkspaceConvergence + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterWorkspaceConvergenceINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) ResendEntry(entryId string, targetDevices []string) (ResendEntryOutcome, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_resend_entry( + _pointer, FfiConverterStringINSTANCE.Lower(entryId), FfiConverterSequenceStringINSTANCE.Lower(targetDevices), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue ResendEntryOutcome + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterResendEntryOutcomeINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) RestoreClipboard(entryId string, mode BindingClipboardRestoreMode) (BindingClipboardRestoreOutcome, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_restore_clipboard( + _pointer, FfiConverterStringINSTANCE.Lower(entryId), FfiConverterBindingClipboardRestoreModeINSTANCE.Lower(mode), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingClipboardRestoreOutcome + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingClipboardRestoreOutcomeINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) Resume() error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_resume( + _pointer, _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) SaveCustomRelay(url string, accessToken string, previousUrl *string) (RelaySaveResult, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_save_custom_relay( + _pointer, FfiConverterStringINSTANCE.Lower(url), FfiConverterStringINSTANCE.Lower(accessToken), FfiConverterOptionalStringINSTANCE.Lower(previousUrl), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue RelaySaveResult + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterRelaySaveResultINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) SendFiles(fileHandles []string, targetDevices []string) (SendReport, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_send_files( + _pointer, FfiConverterSequenceStringINSTANCE.Lower(fileHandles), FfiConverterSequenceStringINSTANCE.Lower(targetDevices), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue SendReport + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSendReportINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) SendImage(bytes []byte, mimeType string, targetDevices []string) (SendReport, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_send_image( + _pointer, FfiConverterBytesINSTANCE.Lower(bytes), FfiConverterStringINSTANCE.Lower(mimeType), FfiConverterSequenceStringINSTANCE.Lower(targetDevices), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue SendReport + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSendReportINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) SendText(text string, targetDevices []string) (SendReport, error) { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_method_mobileengine_send_text( + _pointer, FfiConverterStringINSTANCE.Lower(text), FfiConverterSequenceStringINSTANCE.Lower(targetDevices), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue SendReport + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterSendReportINSTANCE.Lift(_uniffiRV), nil + } +} + +func (_self *MobileEngine) Shutdown(deadlineMs uint64) error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_shutdown( + _pointer, FfiConverterUint64INSTANCE.Lower(deadlineMs), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) Suspend() error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_suspend( + _pointer, _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileEngine) SuspendWithDeadline(deadlineMs uint64) error { + _pointer := _self.ffiObject.incrementPointer("*MobileEngine") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobileengine_suspend_with_deadline( + _pointer, FfiConverterUint64INSTANCE.Lower(deadlineMs), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} +func (object *MobileEngine) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterMobileEngine struct{} + +var FfiConverterMobileEngineINSTANCE = FfiConverterMobileEngine{} + +func (c FfiConverterMobileEngine) Lift(handle C.uint64_t) *MobileEngine { + result := &MobileEngine{ + newFfiObject( + handle, + func(handle C.uint64_t, status *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_clone_mobileengine(handle, status) + }, + func(handle C.uint64_t, status *C.RustCallStatus) { + C.uniffi_uc_engine_uniffi_fn_free_mobileengine(handle, status) + }, + ), + } + runtime.SetFinalizer(result, (*MobileEngine).Destroy) + return result +} + +func (c FfiConverterMobileEngine) Read(reader io.Reader) *MobileEngine { + return c.Lift(C.uint64_t(readUint64(reader))) +} + +func (c FfiConverterMobileEngine) Lower(value *MobileEngine) C.uint64_t { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the handle will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked handle. + handle := value.ffiObject.incrementPointer("*MobileEngine") + defer value.ffiObject.decrementPointer() + return handle +} + +func (c FfiConverterMobileEngine) Write(writer io.Writer, value *MobileEngine) { + writeUint64(writer, uint64(c.Lower(value))) +} + +func LiftFromExternalMobileEngine(handle uint64) *MobileEngine { + return FfiConverterMobileEngineINSTANCE.Lift(C.uint64_t(handle)) +} + +func LowerToExternalMobileEngine(value *MobileEngine) uint64 { + return uint64(FfiConverterMobileEngineINSTANCE.Lower(value)) +} + +type FfiDestroyerMobileEngine struct{} + +func (_ FfiDestroyerMobileEngine) Destroy(value *MobileEngine) { + value.Destroy() +} + +// 宿主在启动调用尚未返回时转交暂停和恢复通知。 +type MobileStartupLifecycleInterface interface { + Resume() error + Suspend() error + SuspendWithDeadline(deadlineMs uint64) error +} + +// 宿主在启动调用尚未返回时转交暂停和恢复通知。 +type MobileStartupLifecycle struct { + ffiObject FfiObject +} + +func NewMobileStartupLifecycle() *MobileStartupLifecycle { + return FfiConverterMobileStartupLifecycleINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_constructor_mobilestartuplifecycle_new(_uniffiStatus) + })) +} + +func (_self *MobileStartupLifecycle) Resume() error { + _pointer := _self.ffiObject.incrementPointer("*MobileStartupLifecycle") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobilestartuplifecycle_resume( + _pointer, _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileStartupLifecycle) Suspend() error { + _pointer := _self.ffiObject.incrementPointer("*MobileStartupLifecycle") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobilestartuplifecycle_suspend( + _pointer, _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func (_self *MobileStartupLifecycle) SuspendWithDeadline(deadlineMs uint64) error { + _pointer := _self.ffiObject.incrementPointer("*MobileStartupLifecycle") + defer _self.ffiObject.decrementPointer() + _, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_method_mobilestartuplifecycle_suspend_with_deadline( + _pointer, FfiConverterUint64INSTANCE.Lower(deadlineMs), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} +func (object *MobileStartupLifecycle) Destroy() { + runtime.SetFinalizer(object, nil) + object.ffiObject.destroy() +} + +type FfiConverterMobileStartupLifecycle struct{} + +var FfiConverterMobileStartupLifecycleINSTANCE = FfiConverterMobileStartupLifecycle{} + +func (c FfiConverterMobileStartupLifecycle) Lift(handle C.uint64_t) *MobileStartupLifecycle { + result := &MobileStartupLifecycle{ + newFfiObject( + handle, + func(handle C.uint64_t, status *C.RustCallStatus) C.uint64_t { + return C.uniffi_uc_engine_uniffi_fn_clone_mobilestartuplifecycle(handle, status) + }, + func(handle C.uint64_t, status *C.RustCallStatus) { + C.uniffi_uc_engine_uniffi_fn_free_mobilestartuplifecycle(handle, status) + }, + ), + } + runtime.SetFinalizer(result, (*MobileStartupLifecycle).Destroy) + return result +} + +func (c FfiConverterMobileStartupLifecycle) Read(reader io.Reader) *MobileStartupLifecycle { + return c.Lift(C.uint64_t(readUint64(reader))) +} + +func (c FfiConverterMobileStartupLifecycle) Lower(value *MobileStartupLifecycle) C.uint64_t { + // TODO: this is bad - all synchronization from ObjectRuntime.go is discarded here, + // because the handle will be decremented immediately after this function returns, + // and someone will be left holding onto a non-locked handle. + handle := value.ffiObject.incrementPointer("*MobileStartupLifecycle") + defer value.ffiObject.decrementPointer() + return handle +} + +func (c FfiConverterMobileStartupLifecycle) Write(writer io.Writer, value *MobileStartupLifecycle) { + writeUint64(writer, uint64(c.Lower(value))) +} + +func LiftFromExternalMobileStartupLifecycle(handle uint64) *MobileStartupLifecycle { + return FfiConverterMobileStartupLifecycleINSTANCE.Lift(C.uint64_t(handle)) +} + +func LowerToExternalMobileStartupLifecycle(value *MobileStartupLifecycle) uint64 { + return uint64(FfiConverterMobileStartupLifecycleINSTANCE.Lower(value)) +} + +type FfiDestroyerMobileStartupLifecycle struct{} + +func (_ FfiDestroyerMobileStartupLifecycle) Destroy(value *MobileStartupLifecycle) { + value.Destroy() +} + +type ActiveClipboard struct { + EntryId string + ActivatedBy string +} + +func (r *ActiveClipboard) Destroy() { + FfiDestroyerString{}.Destroy(r.EntryId) + FfiDestroyerString{}.Destroy(r.ActivatedBy) +} + +type FfiConverterActiveClipboard struct{} + +var FfiConverterActiveClipboardINSTANCE = FfiConverterActiveClipboard{} + +func (c FfiConverterActiveClipboard) Lift(rb RustBufferI) ActiveClipboard { + return LiftFromRustBuffer[ActiveClipboard](c, rb) +} + +func (c FfiConverterActiveClipboard) Read(reader io.Reader) ActiveClipboard { + return ActiveClipboard{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterActiveClipboard) Lower(value ActiveClipboard) C.RustBuffer { + return LowerIntoRustBuffer[ActiveClipboard](c, value) +} + +func (c FfiConverterActiveClipboard) LowerExternal(value ActiveClipboard) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[ActiveClipboard](c, value)) +} + +func (c FfiConverterActiveClipboard) Write(writer io.Writer, value ActiveClipboard) { + FfiConverterStringINSTANCE.Write(writer, value.EntryId) + FfiConverterStringINSTANCE.Write(writer, value.ActivatedBy) +} + +type FfiDestroyerActiveClipboard struct{} + +func (_ FfiDestroyerActiveClipboard) Destroy(value ActiveClipboard) { + value.Destroy() +} + +// Platform attributes that the host supplies once for all analytics events. +type BindingAnalyticsContext struct { + Os BindingAnalyticsOs + OsVersion string + DeviceType BindingAnalyticsDeviceType + Arch string + AppChannel string +} + +func (r *BindingAnalyticsContext) Destroy() { + FfiDestroyerBindingAnalyticsOs{}.Destroy(r.Os) + FfiDestroyerString{}.Destroy(r.OsVersion) + FfiDestroyerBindingAnalyticsDeviceType{}.Destroy(r.DeviceType) + FfiDestroyerString{}.Destroy(r.Arch) + FfiDestroyerString{}.Destroy(r.AppChannel) +} + +type FfiConverterBindingAnalyticsContext struct{} + +var FfiConverterBindingAnalyticsContextINSTANCE = FfiConverterBindingAnalyticsContext{} + +func (c FfiConverterBindingAnalyticsContext) Lift(rb RustBufferI) BindingAnalyticsContext { + return LiftFromRustBuffer[BindingAnalyticsContext](c, rb) +} + +func (c FfiConverterBindingAnalyticsContext) Read(reader io.Reader) BindingAnalyticsContext { + return BindingAnalyticsContext{ + FfiConverterBindingAnalyticsOsINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBindingAnalyticsDeviceTypeINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingAnalyticsContext) Lower(value BindingAnalyticsContext) C.RustBuffer { + return LowerIntoRustBuffer[BindingAnalyticsContext](c, value) +} + +func (c FfiConverterBindingAnalyticsContext) LowerExternal(value BindingAnalyticsContext) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingAnalyticsContext](c, value)) +} + +func (c FfiConverterBindingAnalyticsContext) Write(writer io.Writer, value BindingAnalyticsContext) { + FfiConverterBindingAnalyticsOsINSTANCE.Write(writer, value.Os) + FfiConverterStringINSTANCE.Write(writer, value.OsVersion) + FfiConverterBindingAnalyticsDeviceTypeINSTANCE.Write(writer, value.DeviceType) + FfiConverterStringINSTANCE.Write(writer, value.Arch) + FfiConverterStringINSTANCE.Write(writer, value.AppChannel) +} + +type FfiDestroyerBindingAnalyticsContext struct{} + +func (_ FfiDestroyerBindingAnalyticsContext) Destroy(value BindingAnalyticsContext) { + value.Destroy() +} + +type BindingAnalyticsEvent struct { + Name string + PropertiesJson string +} + +func (r *BindingAnalyticsEvent) Destroy() { + FfiDestroyerString{}.Destroy(r.Name) + FfiDestroyerString{}.Destroy(r.PropertiesJson) +} + +type FfiConverterBindingAnalyticsEvent struct{} + +var FfiConverterBindingAnalyticsEventINSTANCE = FfiConverterBindingAnalyticsEvent{} + +func (c FfiConverterBindingAnalyticsEvent) Lift(rb RustBufferI) BindingAnalyticsEvent { + return LiftFromRustBuffer[BindingAnalyticsEvent](c, rb) +} + +func (c FfiConverterBindingAnalyticsEvent) Read(reader io.Reader) BindingAnalyticsEvent { + return BindingAnalyticsEvent{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingAnalyticsEvent) Lower(value BindingAnalyticsEvent) C.RustBuffer { + return LowerIntoRustBuffer[BindingAnalyticsEvent](c, value) +} + +func (c FfiConverterBindingAnalyticsEvent) LowerExternal(value BindingAnalyticsEvent) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingAnalyticsEvent](c, value)) +} + +func (c FfiConverterBindingAnalyticsEvent) Write(writer io.Writer, value BindingAnalyticsEvent) { + FfiConverterStringINSTANCE.Write(writer, value.Name) + FfiConverterStringINSTANCE.Write(writer, value.PropertiesJson) +} + +type FfiDestroyerBindingAnalyticsEvent struct{} + +func (_ FfiDestroyerBindingAnalyticsEvent) Destroy(value BindingAnalyticsEvent) { + value.Destroy() +} + +type BindingAnalyticsGroupIdentify struct { + GroupType string + GroupKey string + SetJson string +} + +func (r *BindingAnalyticsGroupIdentify) Destroy() { + FfiDestroyerString{}.Destroy(r.GroupType) + FfiDestroyerString{}.Destroy(r.GroupKey) + FfiDestroyerString{}.Destroy(r.SetJson) +} + +type FfiConverterBindingAnalyticsGroupIdentify struct{} + +var FfiConverterBindingAnalyticsGroupIdentifyINSTANCE = FfiConverterBindingAnalyticsGroupIdentify{} + +func (c FfiConverterBindingAnalyticsGroupIdentify) Lift(rb RustBufferI) BindingAnalyticsGroupIdentify { + return LiftFromRustBuffer[BindingAnalyticsGroupIdentify](c, rb) +} + +func (c FfiConverterBindingAnalyticsGroupIdentify) Read(reader io.Reader) BindingAnalyticsGroupIdentify { + return BindingAnalyticsGroupIdentify{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingAnalyticsGroupIdentify) Lower(value BindingAnalyticsGroupIdentify) C.RustBuffer { + return LowerIntoRustBuffer[BindingAnalyticsGroupIdentify](c, value) +} + +func (c FfiConverterBindingAnalyticsGroupIdentify) LowerExternal(value BindingAnalyticsGroupIdentify) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingAnalyticsGroupIdentify](c, value)) +} + +func (c FfiConverterBindingAnalyticsGroupIdentify) Write(writer io.Writer, value BindingAnalyticsGroupIdentify) { + FfiConverterStringINSTANCE.Write(writer, value.GroupType) + FfiConverterStringINSTANCE.Write(writer, value.GroupKey) + FfiConverterStringINSTANCE.Write(writer, value.SetJson) +} + +type FfiDestroyerBindingAnalyticsGroupIdentify struct{} + +func (_ FfiDestroyerBindingAnalyticsGroupIdentify) Destroy(value BindingAnalyticsGroupIdentify) { + value.Destroy() +} + +type BindingAnalyticsIdentify struct { + OldDistinctId string + NewDistinctId string + SetJson string + SetOnceJson string +} + +func (r *BindingAnalyticsIdentify) Destroy() { + FfiDestroyerString{}.Destroy(r.OldDistinctId) + FfiDestroyerString{}.Destroy(r.NewDistinctId) + FfiDestroyerString{}.Destroy(r.SetJson) + FfiDestroyerString{}.Destroy(r.SetOnceJson) +} + +type FfiConverterBindingAnalyticsIdentify struct{} + +var FfiConverterBindingAnalyticsIdentifyINSTANCE = FfiConverterBindingAnalyticsIdentify{} + +func (c FfiConverterBindingAnalyticsIdentify) Lift(rb RustBufferI) BindingAnalyticsIdentify { + return LiftFromRustBuffer[BindingAnalyticsIdentify](c, rb) +} + +func (c FfiConverterBindingAnalyticsIdentify) Read(reader io.Reader) BindingAnalyticsIdentify { + return BindingAnalyticsIdentify{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingAnalyticsIdentify) Lower(value BindingAnalyticsIdentify) C.RustBuffer { + return LowerIntoRustBuffer[BindingAnalyticsIdentify](c, value) +} + +func (c FfiConverterBindingAnalyticsIdentify) LowerExternal(value BindingAnalyticsIdentify) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingAnalyticsIdentify](c, value)) +} + +func (c FfiConverterBindingAnalyticsIdentify) Write(writer io.Writer, value BindingAnalyticsIdentify) { + FfiConverterStringINSTANCE.Write(writer, value.OldDistinctId) + FfiConverterStringINSTANCE.Write(writer, value.NewDistinctId) + FfiConverterStringINSTANCE.Write(writer, value.SetJson) + FfiConverterStringINSTANCE.Write(writer, value.SetOnceJson) +} + +type FfiDestroyerBindingAnalyticsIdentify struct{} + +func (_ FfiDestroyerBindingAnalyticsIdentify) Destroy(value BindingAnalyticsIdentify) { + value.Destroy() +} + +type BindingAnalyticsIdentityChange struct { + PreviousDistinctId string + NewDistinctId string +} + +func (r *BindingAnalyticsIdentityChange) Destroy() { + FfiDestroyerString{}.Destroy(r.PreviousDistinctId) + FfiDestroyerString{}.Destroy(r.NewDistinctId) +} + +type FfiConverterBindingAnalyticsIdentityChange struct{} + +var FfiConverterBindingAnalyticsIdentityChangeINSTANCE = FfiConverterBindingAnalyticsIdentityChange{} + +func (c FfiConverterBindingAnalyticsIdentityChange) Lift(rb RustBufferI) BindingAnalyticsIdentityChange { + return LiftFromRustBuffer[BindingAnalyticsIdentityChange](c, rb) +} + +func (c FfiConverterBindingAnalyticsIdentityChange) Read(reader io.Reader) BindingAnalyticsIdentityChange { + return BindingAnalyticsIdentityChange{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingAnalyticsIdentityChange) Lower(value BindingAnalyticsIdentityChange) C.RustBuffer { + return LowerIntoRustBuffer[BindingAnalyticsIdentityChange](c, value) +} + +func (c FfiConverterBindingAnalyticsIdentityChange) LowerExternal(value BindingAnalyticsIdentityChange) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingAnalyticsIdentityChange](c, value)) +} + +func (c FfiConverterBindingAnalyticsIdentityChange) Write(writer io.Writer, value BindingAnalyticsIdentityChange) { + FfiConverterStringINSTANCE.Write(writer, value.PreviousDistinctId) + FfiConverterStringINSTANCE.Write(writer, value.NewDistinctId) +} + +type FfiDestroyerBindingAnalyticsIdentityChange struct{} + +func (_ FfiDestroyerBindingAnalyticsIdentityChange) Destroy(value BindingAnalyticsIdentityChange) { + value.Destroy() +} + +type BindingClipboardSnapshot struct { + ObservedAtMs int64 + Representations []BindingClipboardRepresentation +} + +func (r *BindingClipboardSnapshot) Destroy() { + FfiDestroyerInt64{}.Destroy(r.ObservedAtMs) + FfiDestroyerSequenceBindingClipboardRepresentation{}.Destroy(r.Representations) +} + +type FfiConverterBindingClipboardSnapshot struct{} + +var FfiConverterBindingClipboardSnapshotINSTANCE = FfiConverterBindingClipboardSnapshot{} + +func (c FfiConverterBindingClipboardSnapshot) Lift(rb RustBufferI) BindingClipboardSnapshot { + return LiftFromRustBuffer[BindingClipboardSnapshot](c, rb) +} + +func (c FfiConverterBindingClipboardSnapshot) Read(reader io.Reader) BindingClipboardSnapshot { + return BindingClipboardSnapshot{ + FfiConverterInt64INSTANCE.Read(reader), + FfiConverterSequenceBindingClipboardRepresentationINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingClipboardSnapshot) Lower(value BindingClipboardSnapshot) C.RustBuffer { + return LowerIntoRustBuffer[BindingClipboardSnapshot](c, value) +} + +func (c FfiConverterBindingClipboardSnapshot) LowerExternal(value BindingClipboardSnapshot) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingClipboardSnapshot](c, value)) +} + +func (c FfiConverterBindingClipboardSnapshot) Write(writer io.Writer, value BindingClipboardSnapshot) { + FfiConverterInt64INSTANCE.Write(writer, value.ObservedAtMs) + FfiConverterSequenceBindingClipboardRepresentationINSTANCE.Write(writer, value.Representations) +} + +type FfiDestroyerBindingClipboardSnapshot struct{} + +func (_ FfiDestroyerBindingClipboardSnapshot) Destroy(value BindingClipboardSnapshot) { + value.Destroy() +} + +type BindingCollectorConfig struct { + TraceEndpoint string + LogEndpoint string + AuthHeaderName *string + AuthHeaderValue *string +} + +func (r *BindingCollectorConfig) Destroy() { + FfiDestroyerString{}.Destroy(r.TraceEndpoint) + FfiDestroyerString{}.Destroy(r.LogEndpoint) + FfiDestroyerOptionalString{}.Destroy(r.AuthHeaderName) + FfiDestroyerOptionalString{}.Destroy(r.AuthHeaderValue) +} + +type FfiConverterBindingCollectorConfig struct{} + +var FfiConverterBindingCollectorConfigINSTANCE = FfiConverterBindingCollectorConfig{} + +func (c FfiConverterBindingCollectorConfig) Lift(rb RustBufferI) BindingCollectorConfig { + return LiftFromRustBuffer[BindingCollectorConfig](c, rb) +} + +func (c FfiConverterBindingCollectorConfig) Read(reader io.Reader) BindingCollectorConfig { + return BindingCollectorConfig{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingCollectorConfig) Lower(value BindingCollectorConfig) C.RustBuffer { + return LowerIntoRustBuffer[BindingCollectorConfig](c, value) +} + +func (c FfiConverterBindingCollectorConfig) LowerExternal(value BindingCollectorConfig) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingCollectorConfig](c, value)) +} + +func (c FfiConverterBindingCollectorConfig) Write(writer io.Writer, value BindingCollectorConfig) { + FfiConverterStringINSTANCE.Write(writer, value.TraceEndpoint) + FfiConverterStringINSTANCE.Write(writer, value.LogEndpoint) + FfiConverterOptionalStringINSTANCE.Write(writer, value.AuthHeaderName) + FfiConverterOptionalStringINSTANCE.Write(writer, value.AuthHeaderValue) +} + +type FfiDestroyerBindingCollectorConfig struct{} + +func (_ FfiDestroyerBindingCollectorConfig) Destroy(value BindingCollectorConfig) { + value.Destroy() +} + +type BindingConfig struct { + AppVersion string + ProfileId string +} + +func (r *BindingConfig) Destroy() { + FfiDestroyerString{}.Destroy(r.AppVersion) + FfiDestroyerString{}.Destroy(r.ProfileId) +} + +type FfiConverterBindingConfig struct{} + +var FfiConverterBindingConfigINSTANCE = FfiConverterBindingConfig{} + +func (c FfiConverterBindingConfig) Lift(rb RustBufferI) BindingConfig { + return LiftFromRustBuffer[BindingConfig](c, rb) +} + +func (c FfiConverterBindingConfig) Read(reader io.Reader) BindingConfig { + return BindingConfig{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingConfig) Lower(value BindingConfig) C.RustBuffer { + return LowerIntoRustBuffer[BindingConfig](c, value) +} + +func (c FfiConverterBindingConfig) LowerExternal(value BindingConfig) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingConfig](c, value)) +} + +func (c FfiConverterBindingConfig) Write(writer io.Writer, value BindingConfig) { + FfiConverterStringINSTANCE.Write(writer, value.AppVersion) + FfiConverterStringINSTANCE.Write(writer, value.ProfileId) +} + +type FfiDestroyerBindingConfig struct{} + +func (_ FfiDestroyerBindingConfig) Destroy(value BindingConfig) { + value.Destroy() +} + +type BindingFailure struct { + Code uint32 + Category BindingErrorCategory + Retryable bool +} + +func (r *BindingFailure) Destroy() { + FfiDestroyerUint32{}.Destroy(r.Code) + FfiDestroyerBindingErrorCategory{}.Destroy(r.Category) + FfiDestroyerBool{}.Destroy(r.Retryable) +} + +type FfiConverterBindingFailure struct{} + +var FfiConverterBindingFailureINSTANCE = FfiConverterBindingFailure{} + +func (c FfiConverterBindingFailure) Lift(rb RustBufferI) BindingFailure { + return LiftFromRustBuffer[BindingFailure](c, rb) +} + +func (c FfiConverterBindingFailure) Read(reader io.Reader) BindingFailure { + return BindingFailure{ + FfiConverterUint32INSTANCE.Read(reader), + FfiConverterBindingErrorCategoryINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingFailure) Lower(value BindingFailure) C.RustBuffer { + return LowerIntoRustBuffer[BindingFailure](c, value) +} + +func (c FfiConverterBindingFailure) LowerExternal(value BindingFailure) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingFailure](c, value)) +} + +func (c FfiConverterBindingFailure) Write(writer io.Writer, value BindingFailure) { + FfiConverterUint32INSTANCE.Write(writer, value.Code) + FfiConverterBindingErrorCategoryINSTANCE.Write(writer, value.Category) + FfiConverterBoolINSTANCE.Write(writer, value.Retryable) +} + +type FfiDestroyerBindingFailure struct{} + +func (_ FfiDestroyerBindingFailure) Destroy(value BindingFailure) { + value.Destroy() +} + +type BindingFileMetadata struct { + DisplayName string + SizeBytes uint64 + MimeType *string +} + +func (r *BindingFileMetadata) Destroy() { + FfiDestroyerString{}.Destroy(r.DisplayName) + FfiDestroyerUint64{}.Destroy(r.SizeBytes) + FfiDestroyerOptionalString{}.Destroy(r.MimeType) +} + +type FfiConverterBindingFileMetadata struct{} + +var FfiConverterBindingFileMetadataINSTANCE = FfiConverterBindingFileMetadata{} + +func (c FfiConverterBindingFileMetadata) Lift(rb RustBufferI) BindingFileMetadata { + return LiftFromRustBuffer[BindingFileMetadata](c, rb) +} + +func (c FfiConverterBindingFileMetadata) Read(reader io.Reader) BindingFileMetadata { + return BindingFileMetadata{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingFileMetadata) Lower(value BindingFileMetadata) C.RustBuffer { + return LowerIntoRustBuffer[BindingFileMetadata](c, value) +} + +func (c FfiConverterBindingFileMetadata) LowerExternal(value BindingFileMetadata) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingFileMetadata](c, value)) +} + +func (c FfiConverterBindingFileMetadata) Write(writer io.Writer, value BindingFileMetadata) { + FfiConverterStringINSTANCE.Write(writer, value.DisplayName) + FfiConverterUint64INSTANCE.Write(writer, value.SizeBytes) + FfiConverterOptionalStringINSTANCE.Write(writer, value.MimeType) +} + +type FfiDestroyerBindingFileMetadata struct{} + +func (_ FfiDestroyerBindingFileMetadata) Destroy(value BindingFileMetadata) { + value.Destroy() +} + +type BindingFileSourceCounts struct { + Source BindingLocalDiagnosticSource + AcceptedCount uint64 + WrittenCount uint64 + QueueDroppedCount uint64 + QuotaDroppedCount uint64 + WriteFailedCount uint64 + LastWrittenAtMs *uint64 +} + +func (r *BindingFileSourceCounts) Destroy() { + FfiDestroyerBindingLocalDiagnosticSource{}.Destroy(r.Source) + FfiDestroyerUint64{}.Destroy(r.AcceptedCount) + FfiDestroyerUint64{}.Destroy(r.WrittenCount) + FfiDestroyerUint64{}.Destroy(r.QueueDroppedCount) + FfiDestroyerUint64{}.Destroy(r.QuotaDroppedCount) + FfiDestroyerUint64{}.Destroy(r.WriteFailedCount) + FfiDestroyerOptionalUint64{}.Destroy(r.LastWrittenAtMs) +} + +type FfiConverterBindingFileSourceCounts struct{} + +var FfiConverterBindingFileSourceCountsINSTANCE = FfiConverterBindingFileSourceCounts{} + +func (c FfiConverterBindingFileSourceCounts) Lift(rb RustBufferI) BindingFileSourceCounts { + return LiftFromRustBuffer[BindingFileSourceCounts](c, rb) +} + +func (c FfiConverterBindingFileSourceCounts) Read(reader io.Reader) BindingFileSourceCounts { + return BindingFileSourceCounts{ + FfiConverterBindingLocalDiagnosticSourceINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterOptionalUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingFileSourceCounts) Lower(value BindingFileSourceCounts) C.RustBuffer { + return LowerIntoRustBuffer[BindingFileSourceCounts](c, value) +} + +func (c FfiConverterBindingFileSourceCounts) LowerExternal(value BindingFileSourceCounts) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingFileSourceCounts](c, value)) +} + +func (c FfiConverterBindingFileSourceCounts) Write(writer io.Writer, value BindingFileSourceCounts) { + FfiConverterBindingLocalDiagnosticSourceINSTANCE.Write(writer, value.Source) + FfiConverterUint64INSTANCE.Write(writer, value.AcceptedCount) + FfiConverterUint64INSTANCE.Write(writer, value.WrittenCount) + FfiConverterUint64INSTANCE.Write(writer, value.QueueDroppedCount) + FfiConverterUint64INSTANCE.Write(writer, value.QuotaDroppedCount) + FfiConverterUint64INSTANCE.Write(writer, value.WriteFailedCount) + FfiConverterOptionalUint64INSTANCE.Write(writer, value.LastWrittenAtMs) +} + +type FfiDestroyerBindingFileSourceCounts struct{} + +func (_ FfiDestroyerBindingFileSourceCounts) Destroy(value BindingFileSourceCounts) { + value.Destroy() +} + +type BindingHostDiagnosticReceipt struct { + Status BindingHostDiagnosticRecordStatus + Token *string +} + +func (r *BindingHostDiagnosticReceipt) Destroy() { + FfiDestroyerBindingHostDiagnosticRecordStatus{}.Destroy(r.Status) + FfiDestroyerOptionalString{}.Destroy(r.Token) +} + +type FfiConverterBindingHostDiagnosticReceipt struct{} + +var FfiConverterBindingHostDiagnosticReceiptINSTANCE = FfiConverterBindingHostDiagnosticReceipt{} + +func (c FfiConverterBindingHostDiagnosticReceipt) Lift(rb RustBufferI) BindingHostDiagnosticReceipt { + return LiftFromRustBuffer[BindingHostDiagnosticReceipt](c, rb) +} + +func (c FfiConverterBindingHostDiagnosticReceipt) Read(reader io.Reader) BindingHostDiagnosticReceipt { + return BindingHostDiagnosticReceipt{ + FfiConverterBindingHostDiagnosticRecordStatusINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingHostDiagnosticReceipt) Lower(value BindingHostDiagnosticReceipt) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostDiagnosticReceipt](c, value) +} + +func (c FfiConverterBindingHostDiagnosticReceipt) LowerExternal(value BindingHostDiagnosticReceipt) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostDiagnosticReceipt](c, value)) +} + +func (c FfiConverterBindingHostDiagnosticReceipt) Write(writer io.Writer, value BindingHostDiagnosticReceipt) { + FfiConverterBindingHostDiagnosticRecordStatusINSTANCE.Write(writer, value.Status) + FfiConverterOptionalStringINSTANCE.Write(writer, value.Token) +} + +type FfiDestroyerBindingHostDiagnosticReceipt struct{} + +func (_ FfiDestroyerBindingHostDiagnosticReceipt) Destroy(value BindingHostDiagnosticReceipt) { + value.Destroy() +} + +type BindingLocalCaptureStatus struct { + Mode BindingLocalCaptureMode + CaptureId *string + RemainingMs uint64 + StartedAtUtc *string + EndReason *BindingCaptureEndReason + LastCaptureId *string + Revision uint64 +} + +func (r *BindingLocalCaptureStatus) Destroy() { + FfiDestroyerBindingLocalCaptureMode{}.Destroy(r.Mode) + FfiDestroyerOptionalString{}.Destroy(r.CaptureId) + FfiDestroyerUint64{}.Destroy(r.RemainingMs) + FfiDestroyerOptionalString{}.Destroy(r.StartedAtUtc) + FfiDestroyerOptionalBindingCaptureEndReason{}.Destroy(r.EndReason) + FfiDestroyerOptionalString{}.Destroy(r.LastCaptureId) + FfiDestroyerUint64{}.Destroy(r.Revision) +} + +type FfiConverterBindingLocalCaptureStatus struct{} + +var FfiConverterBindingLocalCaptureStatusINSTANCE = FfiConverterBindingLocalCaptureStatus{} + +func (c FfiConverterBindingLocalCaptureStatus) Lift(rb RustBufferI) BindingLocalCaptureStatus { + return LiftFromRustBuffer[BindingLocalCaptureStatus](c, rb) +} + +func (c FfiConverterBindingLocalCaptureStatus) Read(reader io.Reader) BindingLocalCaptureStatus { + return BindingLocalCaptureStatus{ + FfiConverterBindingLocalCaptureModeINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalBindingCaptureEndReasonINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingLocalCaptureStatus) Lower(value BindingLocalCaptureStatus) C.RustBuffer { + return LowerIntoRustBuffer[BindingLocalCaptureStatus](c, value) +} + +func (c FfiConverterBindingLocalCaptureStatus) LowerExternal(value BindingLocalCaptureStatus) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingLocalCaptureStatus](c, value)) +} + +func (c FfiConverterBindingLocalCaptureStatus) Write(writer io.Writer, value BindingLocalCaptureStatus) { + FfiConverterBindingLocalCaptureModeINSTANCE.Write(writer, value.Mode) + FfiConverterOptionalStringINSTANCE.Write(writer, value.CaptureId) + FfiConverterUint64INSTANCE.Write(writer, value.RemainingMs) + FfiConverterOptionalStringINSTANCE.Write(writer, value.StartedAtUtc) + FfiConverterOptionalBindingCaptureEndReasonINSTANCE.Write(writer, value.EndReason) + FfiConverterOptionalStringINSTANCE.Write(writer, value.LastCaptureId) + FfiConverterUint64INSTANCE.Write(writer, value.Revision) +} + +type FfiDestroyerBindingLocalCaptureStatus struct{} + +func (_ FfiDestroyerBindingLocalCaptureStatus) Destroy(value BindingLocalCaptureStatus) { + value.Destroy() +} + +type BindingLocalDiagnosticExportReport struct { + Flush BindingObservabilitySignalResult + Status BindingLocalDiagnosticStatus + RequestedAtUtc string + CompletedAtUtc string + OtherProcessesFlushed bool + Files []BindingFileSourceCounts +} + +func (r *BindingLocalDiagnosticExportReport) Destroy() { + FfiDestroyerBindingObservabilitySignalResult{}.Destroy(r.Flush) + FfiDestroyerBindingLocalDiagnosticStatus{}.Destroy(r.Status) + FfiDestroyerString{}.Destroy(r.RequestedAtUtc) + FfiDestroyerString{}.Destroy(r.CompletedAtUtc) + FfiDestroyerBool{}.Destroy(r.OtherProcessesFlushed) + FfiDestroyerSequenceBindingFileSourceCounts{}.Destroy(r.Files) +} + +type FfiConverterBindingLocalDiagnosticExportReport struct{} + +var FfiConverterBindingLocalDiagnosticExportReportINSTANCE = FfiConverterBindingLocalDiagnosticExportReport{} + +func (c FfiConverterBindingLocalDiagnosticExportReport) Lift(rb RustBufferI) BindingLocalDiagnosticExportReport { + return LiftFromRustBuffer[BindingLocalDiagnosticExportReport](c, rb) +} + +func (c FfiConverterBindingLocalDiagnosticExportReport) Read(reader io.Reader) BindingLocalDiagnosticExportReport { + return BindingLocalDiagnosticExportReport{ + FfiConverterBindingObservabilitySignalResultINSTANCE.Read(reader), + FfiConverterBindingLocalDiagnosticStatusINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterSequenceBindingFileSourceCountsINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingLocalDiagnosticExportReport) Lower(value BindingLocalDiagnosticExportReport) C.RustBuffer { + return LowerIntoRustBuffer[BindingLocalDiagnosticExportReport](c, value) +} + +func (c FfiConverterBindingLocalDiagnosticExportReport) LowerExternal(value BindingLocalDiagnosticExportReport) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingLocalDiagnosticExportReport](c, value)) +} + +func (c FfiConverterBindingLocalDiagnosticExportReport) Write(writer io.Writer, value BindingLocalDiagnosticExportReport) { + FfiConverterBindingObservabilitySignalResultINSTANCE.Write(writer, value.Flush) + FfiConverterBindingLocalDiagnosticStatusINSTANCE.Write(writer, value.Status) + FfiConverterStringINSTANCE.Write(writer, value.RequestedAtUtc) + FfiConverterStringINSTANCE.Write(writer, value.CompletedAtUtc) + FfiConverterBoolINSTANCE.Write(writer, value.OtherProcessesFlushed) + FfiConverterSequenceBindingFileSourceCountsINSTANCE.Write(writer, value.Files) +} + +type FfiDestroyerBindingLocalDiagnosticExportReport struct{} + +func (_ FfiDestroyerBindingLocalDiagnosticExportReport) Destroy(value BindingLocalDiagnosticExportReport) { + value.Destroy() +} + +type BindingLocalDiagnosticStatus struct { + RunId string + Capture BindingLocalCaptureStatus + ObservedRecords uint64 + PolicyFilteredRecords uint64 + SchemaRejectedRecords uint64 + CorrelationLimitedRecords uint64 + EngineVersion string + SourceCommit string + CounterScope string + Sources []BindingSourceCoverage + LocalFile BindingObservabilitySetupStatus + Closed bool +} + +func (r *BindingLocalDiagnosticStatus) Destroy() { + FfiDestroyerString{}.Destroy(r.RunId) + FfiDestroyerBindingLocalCaptureStatus{}.Destroy(r.Capture) + FfiDestroyerUint64{}.Destroy(r.ObservedRecords) + FfiDestroyerUint64{}.Destroy(r.PolicyFilteredRecords) + FfiDestroyerUint64{}.Destroy(r.SchemaRejectedRecords) + FfiDestroyerUint64{}.Destroy(r.CorrelationLimitedRecords) + FfiDestroyerString{}.Destroy(r.EngineVersion) + FfiDestroyerString{}.Destroy(r.SourceCommit) + FfiDestroyerString{}.Destroy(r.CounterScope) + FfiDestroyerSequenceBindingSourceCoverage{}.Destroy(r.Sources) + FfiDestroyerBindingObservabilitySetupStatus{}.Destroy(r.LocalFile) + FfiDestroyerBool{}.Destroy(r.Closed) +} + +type FfiConverterBindingLocalDiagnosticStatus struct{} + +var FfiConverterBindingLocalDiagnosticStatusINSTANCE = FfiConverterBindingLocalDiagnosticStatus{} + +func (c FfiConverterBindingLocalDiagnosticStatus) Lift(rb RustBufferI) BindingLocalDiagnosticStatus { + return LiftFromRustBuffer[BindingLocalDiagnosticStatus](c, rb) +} + +func (c FfiConverterBindingLocalDiagnosticStatus) Read(reader io.Reader) BindingLocalDiagnosticStatus { + return BindingLocalDiagnosticStatus{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBindingLocalCaptureStatusINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterSequenceBindingSourceCoverageINSTANCE.Read(reader), + FfiConverterBindingObservabilitySetupStatusINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingLocalDiagnosticStatus) Lower(value BindingLocalDiagnosticStatus) C.RustBuffer { + return LowerIntoRustBuffer[BindingLocalDiagnosticStatus](c, value) +} + +func (c FfiConverterBindingLocalDiagnosticStatus) LowerExternal(value BindingLocalDiagnosticStatus) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingLocalDiagnosticStatus](c, value)) +} + +func (c FfiConverterBindingLocalDiagnosticStatus) Write(writer io.Writer, value BindingLocalDiagnosticStatus) { + FfiConverterStringINSTANCE.Write(writer, value.RunId) + FfiConverterBindingLocalCaptureStatusINSTANCE.Write(writer, value.Capture) + FfiConverterUint64INSTANCE.Write(writer, value.ObservedRecords) + FfiConverterUint64INSTANCE.Write(writer, value.PolicyFilteredRecords) + FfiConverterUint64INSTANCE.Write(writer, value.SchemaRejectedRecords) + FfiConverterUint64INSTANCE.Write(writer, value.CorrelationLimitedRecords) + FfiConverterStringINSTANCE.Write(writer, value.EngineVersion) + FfiConverterStringINSTANCE.Write(writer, value.SourceCommit) + FfiConverterStringINSTANCE.Write(writer, value.CounterScope) + FfiConverterSequenceBindingSourceCoverageINSTANCE.Write(writer, value.Sources) + FfiConverterBindingObservabilitySetupStatusINSTANCE.Write(writer, value.LocalFile) + FfiConverterBoolINSTANCE.Write(writer, value.Closed) +} + +type FfiDestroyerBindingLocalDiagnosticStatus struct{} + +func (_ FfiDestroyerBindingLocalDiagnosticStatus) Destroy(value BindingLocalDiagnosticStatus) { + value.Destroy() +} + +type BindingObservabilityConfig struct { + ServiceVersion string + Environment BindingDeploymentEnvironment + AppChannel string + RemoteDiagnosticsEnabled bool + Collector *BindingCollectorConfig +} + +func (r *BindingObservabilityConfig) Destroy() { + FfiDestroyerString{}.Destroy(r.ServiceVersion) + FfiDestroyerBindingDeploymentEnvironment{}.Destroy(r.Environment) + FfiDestroyerString{}.Destroy(r.AppChannel) + FfiDestroyerBool{}.Destroy(r.RemoteDiagnosticsEnabled) + FfiDestroyerOptionalBindingCollectorConfig{}.Destroy(r.Collector) +} + +type FfiConverterBindingObservabilityConfig struct{} + +var FfiConverterBindingObservabilityConfigINSTANCE = FfiConverterBindingObservabilityConfig{} + +func (c FfiConverterBindingObservabilityConfig) Lift(rb RustBufferI) BindingObservabilityConfig { + return LiftFromRustBuffer[BindingObservabilityConfig](c, rb) +} + +func (c FfiConverterBindingObservabilityConfig) Read(reader io.Reader) BindingObservabilityConfig { + return BindingObservabilityConfig{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBindingDeploymentEnvironmentINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterOptionalBindingCollectorConfigINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingObservabilityConfig) Lower(value BindingObservabilityConfig) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilityConfig](c, value) +} + +func (c FfiConverterBindingObservabilityConfig) LowerExternal(value BindingObservabilityConfig) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilityConfig](c, value)) +} + +func (c FfiConverterBindingObservabilityConfig) Write(writer io.Writer, value BindingObservabilityConfig) { + FfiConverterStringINSTANCE.Write(writer, value.ServiceVersion) + FfiConverterBindingDeploymentEnvironmentINSTANCE.Write(writer, value.Environment) + FfiConverterStringINSTANCE.Write(writer, value.AppChannel) + FfiConverterBoolINSTANCE.Write(writer, value.RemoteDiagnosticsEnabled) + FfiConverterOptionalBindingCollectorConfigINSTANCE.Write(writer, value.Collector) +} + +type FfiDestroyerBindingObservabilityConfig struct{} + +func (_ FfiDestroyerBindingObservabilityConfig) Destroy(value BindingObservabilityConfig) { + value.Destroy() +} + +type BindingObservabilityFlushSummary struct { + Traces BindingObservabilitySignalResult + Logs BindingObservabilitySignalResult +} + +func (r *BindingObservabilityFlushSummary) Destroy() { + FfiDestroyerBindingObservabilitySignalResult{}.Destroy(r.Traces) + FfiDestroyerBindingObservabilitySignalResult{}.Destroy(r.Logs) +} + +type FfiConverterBindingObservabilityFlushSummary struct{} + +var FfiConverterBindingObservabilityFlushSummaryINSTANCE = FfiConverterBindingObservabilityFlushSummary{} + +func (c FfiConverterBindingObservabilityFlushSummary) Lift(rb RustBufferI) BindingObservabilityFlushSummary { + return LiftFromRustBuffer[BindingObservabilityFlushSummary](c, rb) +} + +func (c FfiConverterBindingObservabilityFlushSummary) Read(reader io.Reader) BindingObservabilityFlushSummary { + return BindingObservabilityFlushSummary{ + FfiConverterBindingObservabilitySignalResultINSTANCE.Read(reader), + FfiConverterBindingObservabilitySignalResultINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingObservabilityFlushSummary) Lower(value BindingObservabilityFlushSummary) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilityFlushSummary](c, value) +} + +func (c FfiConverterBindingObservabilityFlushSummary) LowerExternal(value BindingObservabilityFlushSummary) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilityFlushSummary](c, value)) +} + +func (c FfiConverterBindingObservabilityFlushSummary) Write(writer io.Writer, value BindingObservabilityFlushSummary) { + FfiConverterBindingObservabilitySignalResultINSTANCE.Write(writer, value.Traces) + FfiConverterBindingObservabilitySignalResultINSTANCE.Write(writer, value.Logs) +} + +type FfiDestroyerBindingObservabilityFlushSummary struct{} + +func (_ FfiDestroyerBindingObservabilityFlushSummary) Destroy(value BindingObservabilityFlushSummary) { + value.Destroy() +} + +type BindingObservabilityHealth struct { + Remote BindingObservabilitySetupStatus + RemoteSetupFailure *BindingObservabilityRemoteSetupFailure + LocalFile BindingObservabilitySetupStatus + DroppedLocalRecords uint64 + DroppedRemoteSpans uint64 + DroppedRemoteLogs uint64 + FailedRemoteSpanBatches uint64 + FailedRemoteLogBatches uint64 +} + +func (r *BindingObservabilityHealth) Destroy() { + FfiDestroyerBindingObservabilitySetupStatus{}.Destroy(r.Remote) + FfiDestroyerOptionalBindingObservabilityRemoteSetupFailure{}.Destroy(r.RemoteSetupFailure) + FfiDestroyerBindingObservabilitySetupStatus{}.Destroy(r.LocalFile) + FfiDestroyerUint64{}.Destroy(r.DroppedLocalRecords) + FfiDestroyerUint64{}.Destroy(r.DroppedRemoteSpans) + FfiDestroyerUint64{}.Destroy(r.DroppedRemoteLogs) + FfiDestroyerUint64{}.Destroy(r.FailedRemoteSpanBatches) + FfiDestroyerUint64{}.Destroy(r.FailedRemoteLogBatches) +} + +type FfiConverterBindingObservabilityHealth struct{} + +var FfiConverterBindingObservabilityHealthINSTANCE = FfiConverterBindingObservabilityHealth{} + +func (c FfiConverterBindingObservabilityHealth) Lift(rb RustBufferI) BindingObservabilityHealth { + return LiftFromRustBuffer[BindingObservabilityHealth](c, rb) +} + +func (c FfiConverterBindingObservabilityHealth) Read(reader io.Reader) BindingObservabilityHealth { + return BindingObservabilityHealth{ + FfiConverterBindingObservabilitySetupStatusINSTANCE.Read(reader), + FfiConverterOptionalBindingObservabilityRemoteSetupFailureINSTANCE.Read(reader), + FfiConverterBindingObservabilitySetupStatusINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingObservabilityHealth) Lower(value BindingObservabilityHealth) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilityHealth](c, value) +} + +func (c FfiConverterBindingObservabilityHealth) LowerExternal(value BindingObservabilityHealth) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilityHealth](c, value)) +} + +func (c FfiConverterBindingObservabilityHealth) Write(writer io.Writer, value BindingObservabilityHealth) { + FfiConverterBindingObservabilitySetupStatusINSTANCE.Write(writer, value.Remote) + FfiConverterOptionalBindingObservabilityRemoteSetupFailureINSTANCE.Write(writer, value.RemoteSetupFailure) + FfiConverterBindingObservabilitySetupStatusINSTANCE.Write(writer, value.LocalFile) + FfiConverterUint64INSTANCE.Write(writer, value.DroppedLocalRecords) + FfiConverterUint64INSTANCE.Write(writer, value.DroppedRemoteSpans) + FfiConverterUint64INSTANCE.Write(writer, value.DroppedRemoteLogs) + FfiConverterUint64INSTANCE.Write(writer, value.FailedRemoteSpanBatches) + FfiConverterUint64INSTANCE.Write(writer, value.FailedRemoteLogBatches) +} + +type FfiDestroyerBindingObservabilityHealth struct{} + +func (_ FfiDestroyerBindingObservabilityHealth) Destroy(value BindingObservabilityHealth) { + value.Destroy() +} + +type BindingObservabilitySetup struct { + Reused bool + Remote BindingObservabilitySetupStatus + LocalFile BindingObservabilitySetupStatus + DroppedLocalRecords uint64 +} + +func (r *BindingObservabilitySetup) Destroy() { + FfiDestroyerBool{}.Destroy(r.Reused) + FfiDestroyerBindingObservabilitySetupStatus{}.Destroy(r.Remote) + FfiDestroyerBindingObservabilitySetupStatus{}.Destroy(r.LocalFile) + FfiDestroyerUint64{}.Destroy(r.DroppedLocalRecords) +} + +type FfiConverterBindingObservabilitySetup struct{} + +var FfiConverterBindingObservabilitySetupINSTANCE = FfiConverterBindingObservabilitySetup{} + +func (c FfiConverterBindingObservabilitySetup) Lift(rb RustBufferI) BindingObservabilitySetup { + return LiftFromRustBuffer[BindingObservabilitySetup](c, rb) +} + +func (c FfiConverterBindingObservabilitySetup) Read(reader io.Reader) BindingObservabilitySetup { + return BindingObservabilitySetup{ + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterBindingObservabilitySetupStatusINSTANCE.Read(reader), + FfiConverterBindingObservabilitySetupStatusINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingObservabilitySetup) Lower(value BindingObservabilitySetup) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilitySetup](c, value) +} + +func (c FfiConverterBindingObservabilitySetup) LowerExternal(value BindingObservabilitySetup) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilitySetup](c, value)) +} + +func (c FfiConverterBindingObservabilitySetup) Write(writer io.Writer, value BindingObservabilitySetup) { + FfiConverterBoolINSTANCE.Write(writer, value.Reused) + FfiConverterBindingObservabilitySetupStatusINSTANCE.Write(writer, value.Remote) + FfiConverterBindingObservabilitySetupStatusINSTANCE.Write(writer, value.LocalFile) + FfiConverterUint64INSTANCE.Write(writer, value.DroppedLocalRecords) +} + +type FfiDestroyerBindingObservabilitySetup struct{} + +func (_ FfiDestroyerBindingObservabilitySetup) Destroy(value BindingObservabilitySetup) { + value.Destroy() +} + +type BindingObservabilityShutdownSummary struct { + Traces BindingObservabilitySignalResult + Logs BindingObservabilitySignalResult +} + +func (r *BindingObservabilityShutdownSummary) Destroy() { + FfiDestroyerBindingObservabilitySignalResult{}.Destroy(r.Traces) + FfiDestroyerBindingObservabilitySignalResult{}.Destroy(r.Logs) +} + +type FfiConverterBindingObservabilityShutdownSummary struct{} + +var FfiConverterBindingObservabilityShutdownSummaryINSTANCE = FfiConverterBindingObservabilityShutdownSummary{} + +func (c FfiConverterBindingObservabilityShutdownSummary) Lift(rb RustBufferI) BindingObservabilityShutdownSummary { + return LiftFromRustBuffer[BindingObservabilityShutdownSummary](c, rb) +} + +func (c FfiConverterBindingObservabilityShutdownSummary) Read(reader io.Reader) BindingObservabilityShutdownSummary { + return BindingObservabilityShutdownSummary{ + FfiConverterBindingObservabilitySignalResultINSTANCE.Read(reader), + FfiConverterBindingObservabilitySignalResultINSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingObservabilityShutdownSummary) Lower(value BindingObservabilityShutdownSummary) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilityShutdownSummary](c, value) +} + +func (c FfiConverterBindingObservabilityShutdownSummary) LowerExternal(value BindingObservabilityShutdownSummary) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilityShutdownSummary](c, value)) +} + +func (c FfiConverterBindingObservabilityShutdownSummary) Write(writer io.Writer, value BindingObservabilityShutdownSummary) { + FfiConverterBindingObservabilitySignalResultINSTANCE.Write(writer, value.Traces) + FfiConverterBindingObservabilitySignalResultINSTANCE.Write(writer, value.Logs) +} + +type FfiDestroyerBindingObservabilityShutdownSummary struct{} + +func (_ FfiDestroyerBindingObservabilityShutdownSummary) Destroy(value BindingObservabilityShutdownSummary) { + value.Destroy() +} + +type BindingSourceCoverage struct { + Source BindingLocalDiagnosticSource + Capability BindingSourceCapability + Collection BindingSourceCollection + ObservedCount uint64 + PolicyFilteredCount uint64 +} + +func (r *BindingSourceCoverage) Destroy() { + FfiDestroyerBindingLocalDiagnosticSource{}.Destroy(r.Source) + FfiDestroyerBindingSourceCapability{}.Destroy(r.Capability) + FfiDestroyerBindingSourceCollection{}.Destroy(r.Collection) + FfiDestroyerUint64{}.Destroy(r.ObservedCount) + FfiDestroyerUint64{}.Destroy(r.PolicyFilteredCount) +} + +type FfiConverterBindingSourceCoverage struct{} + +var FfiConverterBindingSourceCoverageINSTANCE = FfiConverterBindingSourceCoverage{} + +func (c FfiConverterBindingSourceCoverage) Lift(rb RustBufferI) BindingSourceCoverage { + return LiftFromRustBuffer[BindingSourceCoverage](c, rb) +} + +func (c FfiConverterBindingSourceCoverage) Read(reader io.Reader) BindingSourceCoverage { + return BindingSourceCoverage{ + FfiConverterBindingLocalDiagnosticSourceINSTANCE.Read(reader), + FfiConverterBindingSourceCapabilityINSTANCE.Read(reader), + FfiConverterBindingSourceCollectionINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterBindingSourceCoverage) Lower(value BindingSourceCoverage) C.RustBuffer { + return LowerIntoRustBuffer[BindingSourceCoverage](c, value) +} + +func (c FfiConverterBindingSourceCoverage) LowerExternal(value BindingSourceCoverage) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingSourceCoverage](c, value)) +} + +func (c FfiConverterBindingSourceCoverage) Write(writer io.Writer, value BindingSourceCoverage) { + FfiConverterBindingLocalDiagnosticSourceINSTANCE.Write(writer, value.Source) + FfiConverterBindingSourceCapabilityINSTANCE.Write(writer, value.Capability) + FfiConverterBindingSourceCollectionINSTANCE.Write(writer, value.Collection) + FfiConverterUint64INSTANCE.Write(writer, value.ObservedCount) + FfiConverterUint64INSTANCE.Write(writer, value.PolicyFilteredCount) +} + +type FfiDestroyerBindingSourceCoverage struct{} + +func (_ FfiDestroyerBindingSourceCoverage) Destroy(value BindingSourceCoverage) { + value.Destroy() +} + +type CustomRelay struct { + Url string + CredentialConfigured bool +} + +func (r *CustomRelay) Destroy() { + FfiDestroyerString{}.Destroy(r.Url) + FfiDestroyerBool{}.Destroy(r.CredentialConfigured) +} + +type FfiConverterCustomRelay struct{} + +var FfiConverterCustomRelayINSTANCE = FfiConverterCustomRelay{} + +func (c FfiConverterCustomRelay) Lift(rb RustBufferI) CustomRelay { + return LiftFromRustBuffer[CustomRelay](c, rb) +} + +func (c FfiConverterCustomRelay) Read(reader io.Reader) CustomRelay { + return CustomRelay{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } +} + +func (c FfiConverterCustomRelay) Lower(value CustomRelay) C.RustBuffer { + return LowerIntoRustBuffer[CustomRelay](c, value) +} + +func (c FfiConverterCustomRelay) LowerExternal(value CustomRelay) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[CustomRelay](c, value)) +} + +func (c FfiConverterCustomRelay) Write(writer io.Writer, value CustomRelay) { + FfiConverterStringINSTANCE.Write(writer, value.Url) + FfiConverterBoolINSTANCE.Write(writer, value.CredentialConfigured) +} + +type FfiDestroyerCustomRelay struct{} + +func (_ FfiDestroyerCustomRelay) Destroy(value CustomRelay) { + value.Destroy() +} + +type CustomRelayMutationResult struct { + Relays []CustomRelay + Rejection *CustomRelayMutationRejection +} + +func (r *CustomRelayMutationResult) Destroy() { + FfiDestroyerSequenceCustomRelay{}.Destroy(r.Relays) + FfiDestroyerOptionalCustomRelayMutationRejection{}.Destroy(r.Rejection) +} + +type FfiConverterCustomRelayMutationResult struct{} + +var FfiConverterCustomRelayMutationResultINSTANCE = FfiConverterCustomRelayMutationResult{} + +func (c FfiConverterCustomRelayMutationResult) Lift(rb RustBufferI) CustomRelayMutationResult { + return LiftFromRustBuffer[CustomRelayMutationResult](c, rb) +} + +func (c FfiConverterCustomRelayMutationResult) Read(reader io.Reader) CustomRelayMutationResult { + return CustomRelayMutationResult{ + FfiConverterSequenceCustomRelayINSTANCE.Read(reader), + FfiConverterOptionalCustomRelayMutationRejectionINSTANCE.Read(reader), + } +} + +func (c FfiConverterCustomRelayMutationResult) Lower(value CustomRelayMutationResult) C.RustBuffer { + return LowerIntoRustBuffer[CustomRelayMutationResult](c, value) +} + +func (c FfiConverterCustomRelayMutationResult) LowerExternal(value CustomRelayMutationResult) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[CustomRelayMutationResult](c, value)) +} + +func (c FfiConverterCustomRelayMutationResult) Write(writer io.Writer, value CustomRelayMutationResult) { + FfiConverterSequenceCustomRelayINSTANCE.Write(writer, value.Relays) + FfiConverterOptionalCustomRelayMutationRejectionINSTANCE.Write(writer, value.Rejection) +} + +type FfiDestroyerCustomRelayMutationResult struct{} + +func (_ FfiDestroyerCustomRelayMutationResult) Destroy(value CustomRelayMutationResult) { + value.Destroy() +} + +type Device struct { + DeviceId string + DisplayName string + IsLocal bool + Online bool +} + +func (r *Device) Destroy() { + FfiDestroyerString{}.Destroy(r.DeviceId) + FfiDestroyerString{}.Destroy(r.DisplayName) + FfiDestroyerBool{}.Destroy(r.IsLocal) + FfiDestroyerBool{}.Destroy(r.Online) +} + +type FfiConverterDevice struct{} + +var FfiConverterDeviceINSTANCE = FfiConverterDevice{} + +func (c FfiConverterDevice) Lift(rb RustBufferI) Device { + return LiftFromRustBuffer[Device](c, rb) +} + +func (c FfiConverterDevice) Read(reader io.Reader) Device { + return Device{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } +} + +func (c FfiConverterDevice) Lower(value Device) C.RustBuffer { + return LowerIntoRustBuffer[Device](c, value) +} + +func (c FfiConverterDevice) LowerExternal(value Device) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[Device](c, value)) +} + +func (c FfiConverterDevice) Write(writer io.Writer, value Device) { + FfiConverterStringINSTANCE.Write(writer, value.DeviceId) + FfiConverterStringINSTANCE.Write(writer, value.DisplayName) + FfiConverterBoolINSTANCE.Write(writer, value.IsLocal) + FfiConverterBoolINSTANCE.Write(writer, value.Online) +} + +type FfiDestroyerDevice struct{} + +func (_ FfiDestroyerDevice) Destroy(value Device) { + value.Destroy() +} + +type InvitationIssued struct { + InvitationCode string + FullInvitation string + ExpiresAtMs int64 + Availability InvitationAvailability +} + +func (r *InvitationIssued) Destroy() { + FfiDestroyerString{}.Destroy(r.InvitationCode) + FfiDestroyerString{}.Destroy(r.FullInvitation) + FfiDestroyerInt64{}.Destroy(r.ExpiresAtMs) + FfiDestroyerInvitationAvailability{}.Destroy(r.Availability) +} + +type FfiConverterInvitationIssued struct{} + +var FfiConverterInvitationIssuedINSTANCE = FfiConverterInvitationIssued{} + +func (c FfiConverterInvitationIssued) Lift(rb RustBufferI) InvitationIssued { + return LiftFromRustBuffer[InvitationIssued](c, rb) +} + +func (c FfiConverterInvitationIssued) Read(reader io.Reader) InvitationIssued { + return InvitationIssued{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterInt64INSTANCE.Read(reader), + FfiConverterInvitationAvailabilityINSTANCE.Read(reader), + } +} + +func (c FfiConverterInvitationIssued) Lower(value InvitationIssued) C.RustBuffer { + return LowerIntoRustBuffer[InvitationIssued](c, value) +} + +func (c FfiConverterInvitationIssued) LowerExternal(value InvitationIssued) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[InvitationIssued](c, value)) +} + +func (c FfiConverterInvitationIssued) Write(writer io.Writer, value InvitationIssued) { + FfiConverterStringINSTANCE.Write(writer, value.InvitationCode) + FfiConverterStringINSTANCE.Write(writer, value.FullInvitation) + FfiConverterInt64INSTANCE.Write(writer, value.ExpiresAtMs) + FfiConverterInvitationAvailabilityINSTANCE.Write(writer, value.Availability) +} + +type FfiDestroyerInvitationIssued struct{} + +func (_ FfiDestroyerInvitationIssued) Destroy(value InvitationIssued) { + value.Destroy() +} + +type JoinedSpace struct { + SponsorDeviceId string + SponsorIdentityFingerprint string + SpaceId string + SelfDeviceId string + SelfIdentityFingerprint string + MigratedRecords *uint64 + PreservedUnreadableRecords *uint64 +} + +func (r *JoinedSpace) Destroy() { + FfiDestroyerString{}.Destroy(r.SponsorDeviceId) + FfiDestroyerString{}.Destroy(r.SponsorIdentityFingerprint) + FfiDestroyerString{}.Destroy(r.SpaceId) + FfiDestroyerString{}.Destroy(r.SelfDeviceId) + FfiDestroyerString{}.Destroy(r.SelfIdentityFingerprint) + FfiDestroyerOptionalUint64{}.Destroy(r.MigratedRecords) + FfiDestroyerOptionalUint64{}.Destroy(r.PreservedUnreadableRecords) +} + +type FfiConverterJoinedSpace struct{} + +var FfiConverterJoinedSpaceINSTANCE = FfiConverterJoinedSpace{} + +func (c FfiConverterJoinedSpace) Lift(rb RustBufferI) JoinedSpace { + return LiftFromRustBuffer[JoinedSpace](c, rb) +} + +func (c FfiConverterJoinedSpace) Read(reader io.Reader) JoinedSpace { + return JoinedSpace{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalUint64INSTANCE.Read(reader), + FfiConverterOptionalUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterJoinedSpace) Lower(value JoinedSpace) C.RustBuffer { + return LowerIntoRustBuffer[JoinedSpace](c, value) +} + +func (c FfiConverterJoinedSpace) LowerExternal(value JoinedSpace) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[JoinedSpace](c, value)) +} + +func (c FfiConverterJoinedSpace) Write(writer io.Writer, value JoinedSpace) { + FfiConverterStringINSTANCE.Write(writer, value.SponsorDeviceId) + FfiConverterStringINSTANCE.Write(writer, value.SponsorIdentityFingerprint) + FfiConverterStringINSTANCE.Write(writer, value.SpaceId) + FfiConverterStringINSTANCE.Write(writer, value.SelfDeviceId) + FfiConverterStringINSTANCE.Write(writer, value.SelfIdentityFingerprint) + FfiConverterOptionalUint64INSTANCE.Write(writer, value.MigratedRecords) + FfiConverterOptionalUint64INSTANCE.Write(writer, value.PreservedUnreadableRecords) +} + +type FfiDestroyerJoinedSpace struct{} + +func (_ FfiDestroyerJoinedSpace) Destroy(value JoinedSpace) { + value.Destroy() +} + +type LocalDevice struct { + DeviceId string + DisplayName string +} + +func (r *LocalDevice) Destroy() { + FfiDestroyerString{}.Destroy(r.DeviceId) + FfiDestroyerString{}.Destroy(r.DisplayName) +} + +type FfiConverterLocalDevice struct{} + +var FfiConverterLocalDeviceINSTANCE = FfiConverterLocalDevice{} + +func (c FfiConverterLocalDevice) Lift(rb RustBufferI) LocalDevice { + return LiftFromRustBuffer[LocalDevice](c, rb) +} + +func (c FfiConverterLocalDevice) Read(reader io.Reader) LocalDevice { + return LocalDevice{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterLocalDevice) Lower(value LocalDevice) C.RustBuffer { + return LowerIntoRustBuffer[LocalDevice](c, value) +} + +func (c FfiConverterLocalDevice) LowerExternal(value LocalDevice) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[LocalDevice](c, value)) +} + +func (c FfiConverterLocalDevice) Write(writer io.Writer, value LocalDevice) { + FfiConverterStringINSTANCE.Write(writer, value.DeviceId) + FfiConverterStringINSTANCE.Write(writer, value.DisplayName) +} + +type FfiDestroyerLocalDevice struct{} + +func (_ FfiDestroyerLocalDevice) Destroy(value LocalDevice) { + value.Destroy() +} + +type NetworkRecoveryStatus struct { + Phase string + Retryable bool + NextRetryInMs *uint64 +} + +func (r *NetworkRecoveryStatus) Destroy() { + FfiDestroyerString{}.Destroy(r.Phase) + FfiDestroyerBool{}.Destroy(r.Retryable) + FfiDestroyerOptionalUint64{}.Destroy(r.NextRetryInMs) +} + +type FfiConverterNetworkRecoveryStatus struct{} + +var FfiConverterNetworkRecoveryStatusINSTANCE = FfiConverterNetworkRecoveryStatus{} + +func (c FfiConverterNetworkRecoveryStatus) Lift(rb RustBufferI) NetworkRecoveryStatus { + return LiftFromRustBuffer[NetworkRecoveryStatus](c, rb) +} + +func (c FfiConverterNetworkRecoveryStatus) Read(reader io.Reader) NetworkRecoveryStatus { + return NetworkRecoveryStatus{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterOptionalUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterNetworkRecoveryStatus) Lower(value NetworkRecoveryStatus) C.RustBuffer { + return LowerIntoRustBuffer[NetworkRecoveryStatus](c, value) +} + +func (c FfiConverterNetworkRecoveryStatus) LowerExternal(value NetworkRecoveryStatus) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[NetworkRecoveryStatus](c, value)) +} + +func (c FfiConverterNetworkRecoveryStatus) Write(writer io.Writer, value NetworkRecoveryStatus) { + FfiConverterStringINSTANCE.Write(writer, value.Phase) + FfiConverterBoolINSTANCE.Write(writer, value.Retryable) + FfiConverterOptionalUint64INSTANCE.Write(writer, value.NextRetryInMs) +} + +type FfiDestroyerNetworkRecoveryStatus struct{} + +func (_ FfiDestroyerNetworkRecoveryStatus) Destroy(value NetworkRecoveryStatus) { + value.Destroy() +} + +type PeerConnectionRefresh struct { + Total uint64 + Online uint64 + Offline uint64 + Errors uint64 +} + +func (r *PeerConnectionRefresh) Destroy() { + FfiDestroyerUint64{}.Destroy(r.Total) + FfiDestroyerUint64{}.Destroy(r.Online) + FfiDestroyerUint64{}.Destroy(r.Offline) + FfiDestroyerUint64{}.Destroy(r.Errors) +} + +type FfiConverterPeerConnectionRefresh struct{} + +var FfiConverterPeerConnectionRefreshINSTANCE = FfiConverterPeerConnectionRefresh{} + +func (c FfiConverterPeerConnectionRefresh) Lift(rb RustBufferI) PeerConnectionRefresh { + return LiftFromRustBuffer[PeerConnectionRefresh](c, rb) +} + +func (c FfiConverterPeerConnectionRefresh) Read(reader io.Reader) PeerConnectionRefresh { + return PeerConnectionRefresh{ + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterPeerConnectionRefresh) Lower(value PeerConnectionRefresh) C.RustBuffer { + return LowerIntoRustBuffer[PeerConnectionRefresh](c, value) +} + +func (c FfiConverterPeerConnectionRefresh) LowerExternal(value PeerConnectionRefresh) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[PeerConnectionRefresh](c, value)) +} + +func (c FfiConverterPeerConnectionRefresh) Write(writer io.Writer, value PeerConnectionRefresh) { + FfiConverterUint64INSTANCE.Write(writer, value.Total) + FfiConverterUint64INSTANCE.Write(writer, value.Online) + FfiConverterUint64INSTANCE.Write(writer, value.Offline) + FfiConverterUint64INSTANCE.Write(writer, value.Errors) +} + +type FfiDestroyerPeerConnectionRefresh struct{} + +func (_ FfiDestroyerPeerConnectionRefresh) Destroy(value PeerConnectionRefresh) { + value.Destroy() +} + +type RelayOverview struct { + SavedMode RelayRoutingMode + AppliedMode *RelayRoutingMode + ChangePending bool + Entries []RelayOverviewEntry +} + +func (r *RelayOverview) Destroy() { + FfiDestroyerRelayRoutingMode{}.Destroy(r.SavedMode) + FfiDestroyerOptionalRelayRoutingMode{}.Destroy(r.AppliedMode) + FfiDestroyerBool{}.Destroy(r.ChangePending) + FfiDestroyerSequenceRelayOverviewEntry{}.Destroy(r.Entries) +} + +type FfiConverterRelayOverview struct{} + +var FfiConverterRelayOverviewINSTANCE = FfiConverterRelayOverview{} + +func (c FfiConverterRelayOverview) Lift(rb RustBufferI) RelayOverview { + return LiftFromRustBuffer[RelayOverview](c, rb) +} + +func (c FfiConverterRelayOverview) Read(reader io.Reader) RelayOverview { + return RelayOverview{ + FfiConverterRelayRoutingModeINSTANCE.Read(reader), + FfiConverterOptionalRelayRoutingModeINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterSequenceRelayOverviewEntryINSTANCE.Read(reader), + } +} + +func (c FfiConverterRelayOverview) Lower(value RelayOverview) C.RustBuffer { + return LowerIntoRustBuffer[RelayOverview](c, value) +} + +func (c FfiConverterRelayOverview) LowerExternal(value RelayOverview) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[RelayOverview](c, value)) +} + +func (c FfiConverterRelayOverview) Write(writer io.Writer, value RelayOverview) { + FfiConverterRelayRoutingModeINSTANCE.Write(writer, value.SavedMode) + FfiConverterOptionalRelayRoutingModeINSTANCE.Write(writer, value.AppliedMode) + FfiConverterBoolINSTANCE.Write(writer, value.ChangePending) + FfiConverterSequenceRelayOverviewEntryINSTANCE.Write(writer, value.Entries) +} + +type FfiDestroyerRelayOverview struct{} + +func (_ FfiDestroyerRelayOverview) Destroy(value RelayOverview) { + value.Destroy() +} + +// `in_effect` 表示运行中的节点按此地址配置,不代表已经连通。 +type RelayOverviewEntry struct { + Source RelayEntrySource + RegionId *string + Url string + CredentialConfigured bool + InEffect bool +} + +func (r *RelayOverviewEntry) Destroy() { + FfiDestroyerRelayEntrySource{}.Destroy(r.Source) + FfiDestroyerOptionalString{}.Destroy(r.RegionId) + FfiDestroyerString{}.Destroy(r.Url) + FfiDestroyerBool{}.Destroy(r.CredentialConfigured) + FfiDestroyerBool{}.Destroy(r.InEffect) +} + +type FfiConverterRelayOverviewEntry struct{} + +var FfiConverterRelayOverviewEntryINSTANCE = FfiConverterRelayOverviewEntry{} + +func (c FfiConverterRelayOverviewEntry) Lift(rb RustBufferI) RelayOverviewEntry { + return LiftFromRustBuffer[RelayOverviewEntry](c, rb) +} + +func (c FfiConverterRelayOverviewEntry) Read(reader io.Reader) RelayOverviewEntry { + return RelayOverviewEntry{ + FfiConverterRelayEntrySourceINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } +} + +func (c FfiConverterRelayOverviewEntry) Lower(value RelayOverviewEntry) C.RustBuffer { + return LowerIntoRustBuffer[RelayOverviewEntry](c, value) +} + +func (c FfiConverterRelayOverviewEntry) LowerExternal(value RelayOverviewEntry) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[RelayOverviewEntry](c, value)) +} + +func (c FfiConverterRelayOverviewEntry) Write(writer io.Writer, value RelayOverviewEntry) { + FfiConverterRelayEntrySourceINSTANCE.Write(writer, value.Source) + FfiConverterOptionalStringINSTANCE.Write(writer, value.RegionId) + FfiConverterStringINSTANCE.Write(writer, value.Url) + FfiConverterBoolINSTANCE.Write(writer, value.CredentialConfigured) + FfiConverterBoolINSTANCE.Write(writer, value.InEffect) +} + +type FfiDestroyerRelayOverviewEntry struct{} + +func (_ FfiDestroyerRelayOverviewEntry) Destroy(value RelayOverviewEntry) { + value.Destroy() +} + +type RelaySaveResult struct { + Configured bool +} + +func (r *RelaySaveResult) Destroy() { + FfiDestroyerBool{}.Destroy(r.Configured) +} + +type FfiConverterRelaySaveResult struct{} + +var FfiConverterRelaySaveResultINSTANCE = FfiConverterRelaySaveResult{} + +func (c FfiConverterRelaySaveResult) Lift(rb RustBufferI) RelaySaveResult { + return LiftFromRustBuffer[RelaySaveResult](c, rb) +} + +func (c FfiConverterRelaySaveResult) Read(reader io.Reader) RelaySaveResult { + return RelaySaveResult{ + FfiConverterBoolINSTANCE.Read(reader), + } +} + +func (c FfiConverterRelaySaveResult) Lower(value RelaySaveResult) C.RustBuffer { + return LowerIntoRustBuffer[RelaySaveResult](c, value) +} + +func (c FfiConverterRelaySaveResult) LowerExternal(value RelaySaveResult) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[RelaySaveResult](c, value)) +} + +func (c FfiConverterRelaySaveResult) Write(writer io.Writer, value RelaySaveResult) { + FfiConverterBoolINSTANCE.Write(writer, value.Configured) +} + +type FfiDestroyerRelaySaveResult struct{} + +func (_ FfiDestroyerRelaySaveResult) Destroy(value RelaySaveResult) { + value.Destroy() +} + +type SendReport struct { + EntryId string + AtMs int64 + TotalAccepted uint64 + TotalDuplicate uint64 + TotalOffline uint64 + TotalErrored uint64 + TotalPending uint64 +} + +func (r *SendReport) Destroy() { + FfiDestroyerString{}.Destroy(r.EntryId) + FfiDestroyerInt64{}.Destroy(r.AtMs) + FfiDestroyerUint64{}.Destroy(r.TotalAccepted) + FfiDestroyerUint64{}.Destroy(r.TotalDuplicate) + FfiDestroyerUint64{}.Destroy(r.TotalOffline) + FfiDestroyerUint64{}.Destroy(r.TotalErrored) + FfiDestroyerUint64{}.Destroy(r.TotalPending) +} + +type FfiConverterSendReport struct{} + +var FfiConverterSendReportINSTANCE = FfiConverterSendReport{} + +func (c FfiConverterSendReport) Lift(rb RustBufferI) SendReport { + return LiftFromRustBuffer[SendReport](c, rb) +} + +func (c FfiConverterSendReport) Read(reader io.Reader) SendReport { + return SendReport{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterInt64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } +} + +func (c FfiConverterSendReport) Lower(value SendReport) C.RustBuffer { + return LowerIntoRustBuffer[SendReport](c, value) +} + +func (c FfiConverterSendReport) LowerExternal(value SendReport) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[SendReport](c, value)) +} + +func (c FfiConverterSendReport) Write(writer io.Writer, value SendReport) { + FfiConverterStringINSTANCE.Write(writer, value.EntryId) + FfiConverterInt64INSTANCE.Write(writer, value.AtMs) + FfiConverterUint64INSTANCE.Write(writer, value.TotalAccepted) + FfiConverterUint64INSTANCE.Write(writer, value.TotalDuplicate) + FfiConverterUint64INSTANCE.Write(writer, value.TotalOffline) + FfiConverterUint64INSTANCE.Write(writer, value.TotalErrored) + FfiConverterUint64INSTANCE.Write(writer, value.TotalPending) +} + +type FfiDestroyerSendReport struct{} + +func (_ FfiDestroyerSendReport) Destroy(value SendReport) { + value.Destroy() +} + +type SessionRecovery struct { + Unlocked bool + Resumed bool +} + +func (r *SessionRecovery) Destroy() { + FfiDestroyerBool{}.Destroy(r.Unlocked) + FfiDestroyerBool{}.Destroy(r.Resumed) +} + +type FfiConverterSessionRecovery struct{} + +var FfiConverterSessionRecoveryINSTANCE = FfiConverterSessionRecovery{} + +func (c FfiConverterSessionRecovery) Lift(rb RustBufferI) SessionRecovery { + return LiftFromRustBuffer[SessionRecovery](c, rb) +} + +func (c FfiConverterSessionRecovery) Read(reader io.Reader) SessionRecovery { + return SessionRecovery{ + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } +} + +func (c FfiConverterSessionRecovery) Lower(value SessionRecovery) C.RustBuffer { + return LowerIntoRustBuffer[SessionRecovery](c, value) +} + +func (c FfiConverterSessionRecovery) LowerExternal(value SessionRecovery) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[SessionRecovery](c, value)) +} + +func (c FfiConverterSessionRecovery) Write(writer io.Writer, value SessionRecovery) { + FfiConverterBoolINSTANCE.Write(writer, value.Unlocked) + FfiConverterBoolINSTANCE.Write(writer, value.Resumed) +} + +type FfiDestroyerSessionRecovery struct{} + +func (_ FfiDestroyerSessionRecovery) Destroy(value SessionRecovery) { + value.Destroy() +} + +type SpaceCreated struct { + SpaceId string + SelfDeviceId string + IdentityFingerprint string +} + +func (r *SpaceCreated) Destroy() { + FfiDestroyerString{}.Destroy(r.SpaceId) + FfiDestroyerString{}.Destroy(r.SelfDeviceId) + FfiDestroyerString{}.Destroy(r.IdentityFingerprint) +} + +type FfiConverterSpaceCreated struct{} + +var FfiConverterSpaceCreatedINSTANCE = FfiConverterSpaceCreated{} + +func (c FfiConverterSpaceCreated) Lift(rb RustBufferI) SpaceCreated { + return LiftFromRustBuffer[SpaceCreated](c, rb) +} + +func (c FfiConverterSpaceCreated) Read(reader io.Reader) SpaceCreated { + return SpaceCreated{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterSpaceCreated) Lower(value SpaceCreated) C.RustBuffer { + return LowerIntoRustBuffer[SpaceCreated](c, value) +} + +func (c FfiConverterSpaceCreated) LowerExternal(value SpaceCreated) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[SpaceCreated](c, value)) +} + +func (c FfiConverterSpaceCreated) Write(writer io.Writer, value SpaceCreated) { + FfiConverterStringINSTANCE.Write(writer, value.SpaceId) + FfiConverterStringINSTANCE.Write(writer, value.SelfDeviceId) + FfiConverterStringINSTANCE.Write(writer, value.IdentityFingerprint) +} + +type FfiDestroyerSpaceCreated struct{} + +func (_ FfiDestroyerSpaceCreated) Destroy(value SpaceCreated) { + value.Destroy() +} + +type SpaceInvitation struct { + InvitationCode string + FullInvitation string + ExpiresAtMs int64 +} + +func (r *SpaceInvitation) Destroy() { + FfiDestroyerString{}.Destroy(r.InvitationCode) + FfiDestroyerString{}.Destroy(r.FullInvitation) + FfiDestroyerInt64{}.Destroy(r.ExpiresAtMs) +} + +type FfiConverterSpaceInvitation struct{} + +var FfiConverterSpaceInvitationINSTANCE = FfiConverterSpaceInvitation{} + +func (c FfiConverterSpaceInvitation) Lift(rb RustBufferI) SpaceInvitation { + return LiftFromRustBuffer[SpaceInvitation](c, rb) +} + +func (c FfiConverterSpaceInvitation) Read(reader io.Reader) SpaceInvitation { + return SpaceInvitation{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterInt64INSTANCE.Read(reader), + } +} + +func (c FfiConverterSpaceInvitation) Lower(value SpaceInvitation) C.RustBuffer { + return LowerIntoRustBuffer[SpaceInvitation](c, value) +} + +func (c FfiConverterSpaceInvitation) LowerExternal(value SpaceInvitation) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[SpaceInvitation](c, value)) +} + +func (c FfiConverterSpaceInvitation) Write(writer io.Writer, value SpaceInvitation) { + FfiConverterStringINSTANCE.Write(writer, value.InvitationCode) + FfiConverterStringINSTANCE.Write(writer, value.FullInvitation) + FfiConverterInt64INSTANCE.Write(writer, value.ExpiresAtMs) +} + +type FfiDestroyerSpaceInvitation struct{} + +func (_ FfiDestroyerSpaceInvitation) Destroy(value SpaceInvitation) { + value.Destroy() +} + +type SpaceState struct { + HasCompleted bool + RePairingRequired bool + SpaceId *string + CurrentInvitation *SpaceInvitation + DeviceName *string +} + +func (r *SpaceState) Destroy() { + FfiDestroyerBool{}.Destroy(r.HasCompleted) + FfiDestroyerBool{}.Destroy(r.RePairingRequired) + FfiDestroyerOptionalString{}.Destroy(r.SpaceId) + FfiDestroyerOptionalSpaceInvitation{}.Destroy(r.CurrentInvitation) + FfiDestroyerOptionalString{}.Destroy(r.DeviceName) +} + +type FfiConverterSpaceState struct{} + +var FfiConverterSpaceStateINSTANCE = FfiConverterSpaceState{} + +func (c FfiConverterSpaceState) Lift(rb RustBufferI) SpaceState { + return LiftFromRustBuffer[SpaceState](c, rb) +} + +func (c FfiConverterSpaceState) Read(reader io.Reader) SpaceState { + return SpaceState{ + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalSpaceInvitationINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + } +} + +func (c FfiConverterSpaceState) Lower(value SpaceState) C.RustBuffer { + return LowerIntoRustBuffer[SpaceState](c, value) +} + +func (c FfiConverterSpaceState) LowerExternal(value SpaceState) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[SpaceState](c, value)) +} + +func (c FfiConverterSpaceState) Write(writer io.Writer, value SpaceState) { + FfiConverterBoolINSTANCE.Write(writer, value.HasCompleted) + FfiConverterBoolINSTANCE.Write(writer, value.RePairingRequired) + FfiConverterOptionalStringINSTANCE.Write(writer, value.SpaceId) + FfiConverterOptionalSpaceInvitationINSTANCE.Write(writer, value.CurrentInvitation) + FfiConverterOptionalStringINSTANCE.Write(writer, value.DeviceName) +} + +type FfiDestroyerSpaceState struct{} + +func (_ FfiDestroyerSpaceState) Destroy(value SpaceState) { + value.Destroy() +} + +type WorkspaceConvergence struct { + Phase WorkspaceConvergencePhase + Revision uint64 + HistoryEventCount uint64 + EffectiveMemberCount uint64 + PendingRemovalDecisionDeviceIds []string + PendingRemovalDecisionEventId *string + DivergedPeerDeviceIds []string + UpgradeRequiredPeerDeviceIds []string + ConvergenceDigest *string + Removed bool + UpdatedAtMs int64 + FailureCategory *WorkspaceConvergenceFailureCategory +} + +func (r *WorkspaceConvergence) Destroy() { + FfiDestroyerWorkspaceConvergencePhase{}.Destroy(r.Phase) + FfiDestroyerUint64{}.Destroy(r.Revision) + FfiDestroyerUint64{}.Destroy(r.HistoryEventCount) + FfiDestroyerUint64{}.Destroy(r.EffectiveMemberCount) + FfiDestroyerSequenceString{}.Destroy(r.PendingRemovalDecisionDeviceIds) + FfiDestroyerOptionalString{}.Destroy(r.PendingRemovalDecisionEventId) + FfiDestroyerSequenceString{}.Destroy(r.DivergedPeerDeviceIds) + FfiDestroyerSequenceString{}.Destroy(r.UpgradeRequiredPeerDeviceIds) + FfiDestroyerOptionalString{}.Destroy(r.ConvergenceDigest) + FfiDestroyerBool{}.Destroy(r.Removed) + FfiDestroyerInt64{}.Destroy(r.UpdatedAtMs) + FfiDestroyerOptionalWorkspaceConvergenceFailureCategory{}.Destroy(r.FailureCategory) +} + +type FfiConverterWorkspaceConvergence struct{} + +var FfiConverterWorkspaceConvergenceINSTANCE = FfiConverterWorkspaceConvergence{} + +func (c FfiConverterWorkspaceConvergence) Lift(rb RustBufferI) WorkspaceConvergence { + return LiftFromRustBuffer[WorkspaceConvergence](c, rb) +} + +func (c FfiConverterWorkspaceConvergence) Read(reader io.Reader) WorkspaceConvergence { + return WorkspaceConvergence{ + FfiConverterWorkspaceConvergencePhaseINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterSequenceStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterSequenceStringINSTANCE.Read(reader), + FfiConverterSequenceStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterInt64INSTANCE.Read(reader), + FfiConverterOptionalWorkspaceConvergenceFailureCategoryINSTANCE.Read(reader), + } +} + +func (c FfiConverterWorkspaceConvergence) Lower(value WorkspaceConvergence) C.RustBuffer { + return LowerIntoRustBuffer[WorkspaceConvergence](c, value) +} + +func (c FfiConverterWorkspaceConvergence) LowerExternal(value WorkspaceConvergence) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[WorkspaceConvergence](c, value)) +} + +func (c FfiConverterWorkspaceConvergence) Write(writer io.Writer, value WorkspaceConvergence) { + FfiConverterWorkspaceConvergencePhaseINSTANCE.Write(writer, value.Phase) + FfiConverterUint64INSTANCE.Write(writer, value.Revision) + FfiConverterUint64INSTANCE.Write(writer, value.HistoryEventCount) + FfiConverterUint64INSTANCE.Write(writer, value.EffectiveMemberCount) + FfiConverterSequenceStringINSTANCE.Write(writer, value.PendingRemovalDecisionDeviceIds) + FfiConverterOptionalStringINSTANCE.Write(writer, value.PendingRemovalDecisionEventId) + FfiConverterSequenceStringINSTANCE.Write(writer, value.DivergedPeerDeviceIds) + FfiConverterSequenceStringINSTANCE.Write(writer, value.UpgradeRequiredPeerDeviceIds) + FfiConverterOptionalStringINSTANCE.Write(writer, value.ConvergenceDigest) + FfiConverterBoolINSTANCE.Write(writer, value.Removed) + FfiConverterInt64INSTANCE.Write(writer, value.UpdatedAtMs) + FfiConverterOptionalWorkspaceConvergenceFailureCategoryINSTANCE.Write(writer, value.FailureCategory) +} + +type FfiDestroyerWorkspaceConvergence struct{} + +func (_ FfiDestroyerWorkspaceConvergence) Destroy(value WorkspaceConvergence) { + value.Destroy() +} + +type BindingAnalyticsDeviceType uint + +const ( + BindingAnalyticsDeviceTypeMobile BindingAnalyticsDeviceType = 1 + BindingAnalyticsDeviceTypeDesktop BindingAnalyticsDeviceType = 2 +) + +type FfiConverterBindingAnalyticsDeviceType struct{} + +var FfiConverterBindingAnalyticsDeviceTypeINSTANCE = FfiConverterBindingAnalyticsDeviceType{} + +func (c FfiConverterBindingAnalyticsDeviceType) Lift(rb RustBufferI) BindingAnalyticsDeviceType { + return LiftFromRustBuffer[BindingAnalyticsDeviceType](c, rb) +} + +func (c FfiConverterBindingAnalyticsDeviceType) Lower(value BindingAnalyticsDeviceType) C.RustBuffer { + return LowerIntoRustBuffer[BindingAnalyticsDeviceType](c, value) +} + +func (c FfiConverterBindingAnalyticsDeviceType) LowerExternal(value BindingAnalyticsDeviceType) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingAnalyticsDeviceType](c, value)) +} +func (FfiConverterBindingAnalyticsDeviceType) Read(reader io.Reader) BindingAnalyticsDeviceType { + id := readInt32(reader) + return BindingAnalyticsDeviceType(id) +} + +func (FfiConverterBindingAnalyticsDeviceType) Write(writer io.Writer, value BindingAnalyticsDeviceType) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingAnalyticsDeviceType struct{} + +func (_ FfiDestroyerBindingAnalyticsDeviceType) Destroy(value BindingAnalyticsDeviceType) { +} + +type BindingAnalyticsHostError struct { + err error +} + +// Convenience method to turn *BindingAnalyticsHostError into error +// Avoiding treating nil pointer as non nil error interface +func (err *BindingAnalyticsHostError) AsError() error { + if err == nil { + return nil + } else { + return err + } +} + +func (err BindingAnalyticsHostError) Error() string { + return fmt.Sprintf("BindingAnalyticsHostError: %s", err.err.Error()) +} + +func (err BindingAnalyticsHostError) Unwrap() error { + return err.err +} + +// Err* are used for checking error type with `errors.Is` +var ErrBindingAnalyticsHostErrorContextUnavailable = fmt.Errorf("BindingAnalyticsHostErrorContextUnavailable") +var ErrBindingAnalyticsHostErrorDeliveryFailed = fmt.Errorf("BindingAnalyticsHostErrorDeliveryFailed") +var ErrBindingAnalyticsHostErrorPersistenceFailed = fmt.Errorf("BindingAnalyticsHostErrorPersistenceFailed") +var ErrBindingAnalyticsHostErrorInvalidIdentity = fmt.Errorf("BindingAnalyticsHostErrorInvalidIdentity") + +// Variant structs +type BindingAnalyticsHostErrorContextUnavailable struct { +} + +func NewBindingAnalyticsHostErrorContextUnavailable() *BindingAnalyticsHostError { + return &BindingAnalyticsHostError{err: &BindingAnalyticsHostErrorContextUnavailable{}} +} + +func (e BindingAnalyticsHostErrorContextUnavailable) destroy() { +} + +func (err BindingAnalyticsHostErrorContextUnavailable) Error() string { + return fmt.Sprint("ContextUnavailable") +} + +func (self BindingAnalyticsHostErrorContextUnavailable) Is(target error) bool { + return target == ErrBindingAnalyticsHostErrorContextUnavailable +} + +type BindingAnalyticsHostErrorDeliveryFailed struct { +} + +func NewBindingAnalyticsHostErrorDeliveryFailed() *BindingAnalyticsHostError { + return &BindingAnalyticsHostError{err: &BindingAnalyticsHostErrorDeliveryFailed{}} +} + +func (e BindingAnalyticsHostErrorDeliveryFailed) destroy() { +} + +func (err BindingAnalyticsHostErrorDeliveryFailed) Error() string { + return fmt.Sprint("DeliveryFailed") +} + +func (self BindingAnalyticsHostErrorDeliveryFailed) Is(target error) bool { + return target == ErrBindingAnalyticsHostErrorDeliveryFailed +} + +type BindingAnalyticsHostErrorPersistenceFailed struct { +} + +func NewBindingAnalyticsHostErrorPersistenceFailed() *BindingAnalyticsHostError { + return &BindingAnalyticsHostError{err: &BindingAnalyticsHostErrorPersistenceFailed{}} +} + +func (e BindingAnalyticsHostErrorPersistenceFailed) destroy() { +} + +func (err BindingAnalyticsHostErrorPersistenceFailed) Error() string { + return fmt.Sprint("PersistenceFailed") +} + +func (self BindingAnalyticsHostErrorPersistenceFailed) Is(target error) bool { + return target == ErrBindingAnalyticsHostErrorPersistenceFailed +} + +type BindingAnalyticsHostErrorInvalidIdentity struct { +} + +func NewBindingAnalyticsHostErrorInvalidIdentity() *BindingAnalyticsHostError { + return &BindingAnalyticsHostError{err: &BindingAnalyticsHostErrorInvalidIdentity{}} +} + +func (e BindingAnalyticsHostErrorInvalidIdentity) destroy() { +} + +func (err BindingAnalyticsHostErrorInvalidIdentity) Error() string { + return fmt.Sprint("InvalidIdentity") +} + +func (self BindingAnalyticsHostErrorInvalidIdentity) Is(target error) bool { + return target == ErrBindingAnalyticsHostErrorInvalidIdentity +} + +type FfiConverterBindingAnalyticsHostError struct{} + +var FfiConverterBindingAnalyticsHostErrorINSTANCE = FfiConverterBindingAnalyticsHostError{} + +func (c FfiConverterBindingAnalyticsHostError) Lift(eb RustBufferI) *BindingAnalyticsHostError { + return LiftFromRustBuffer[*BindingAnalyticsHostError](c, eb) +} + +func (c FfiConverterBindingAnalyticsHostError) Lower(value *BindingAnalyticsHostError) C.RustBuffer { + return LowerIntoRustBuffer[*BindingAnalyticsHostError](c, value) +} + +func (c FfiConverterBindingAnalyticsHostError) LowerExternal(value *BindingAnalyticsHostError) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingAnalyticsHostError](c, value)) +} + +func (c FfiConverterBindingAnalyticsHostError) Read(reader io.Reader) *BindingAnalyticsHostError { + errorID := readUint32(reader) + + switch errorID { + case 1: + return &BindingAnalyticsHostError{&BindingAnalyticsHostErrorContextUnavailable{}} + case 2: + return &BindingAnalyticsHostError{&BindingAnalyticsHostErrorDeliveryFailed{}} + case 3: + return &BindingAnalyticsHostError{&BindingAnalyticsHostErrorPersistenceFailed{}} + case 4: + return &BindingAnalyticsHostError{&BindingAnalyticsHostErrorInvalidIdentity{}} + default: + panic(fmt.Sprintf("Unknown error code %d in FfiConverterBindingAnalyticsHostError.Read()", errorID)) + } +} + +func (c FfiConverterBindingAnalyticsHostError) Write(writer io.Writer, value *BindingAnalyticsHostError) { + switch variantValue := value.err.(type) { + case *BindingAnalyticsHostErrorContextUnavailable: + writeInt32(writer, 1) + case *BindingAnalyticsHostErrorDeliveryFailed: + writeInt32(writer, 2) + case *BindingAnalyticsHostErrorPersistenceFailed: + writeInt32(writer, 3) + case *BindingAnalyticsHostErrorInvalidIdentity: + writeInt32(writer, 4) + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiConverterBindingAnalyticsHostError.Write", value)) + } +} + +type FfiDestroyerBindingAnalyticsHostError struct{} + +func (_ FfiDestroyerBindingAnalyticsHostError) Destroy(value *BindingAnalyticsHostError) { + switch variantValue := value.err.(type) { + case BindingAnalyticsHostErrorContextUnavailable: + variantValue.destroy() + case BindingAnalyticsHostErrorDeliveryFailed: + variantValue.destroy() + case BindingAnalyticsHostErrorPersistenceFailed: + variantValue.destroy() + case BindingAnalyticsHostErrorInvalidIdentity: + variantValue.destroy() + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerBindingAnalyticsHostError.Destroy", value)) + } +} + +type BindingAnalyticsOs uint + +const ( + BindingAnalyticsOsMacos BindingAnalyticsOs = 1 + BindingAnalyticsOsWindows BindingAnalyticsOs = 2 + BindingAnalyticsOsLinux BindingAnalyticsOs = 3 + BindingAnalyticsOsIos BindingAnalyticsOs = 4 + BindingAnalyticsOsAndroid BindingAnalyticsOs = 5 + BindingAnalyticsOsOther BindingAnalyticsOs = 6 +) + +type FfiConverterBindingAnalyticsOs struct{} + +var FfiConverterBindingAnalyticsOsINSTANCE = FfiConverterBindingAnalyticsOs{} + +func (c FfiConverterBindingAnalyticsOs) Lift(rb RustBufferI) BindingAnalyticsOs { + return LiftFromRustBuffer[BindingAnalyticsOs](c, rb) +} + +func (c FfiConverterBindingAnalyticsOs) Lower(value BindingAnalyticsOs) C.RustBuffer { + return LowerIntoRustBuffer[BindingAnalyticsOs](c, value) +} + +func (c FfiConverterBindingAnalyticsOs) LowerExternal(value BindingAnalyticsOs) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingAnalyticsOs](c, value)) +} +func (FfiConverterBindingAnalyticsOs) Read(reader io.Reader) BindingAnalyticsOs { + id := readInt32(reader) + return BindingAnalyticsOs(id) +} + +func (FfiConverterBindingAnalyticsOs) Write(writer io.Writer, value BindingAnalyticsOs) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingAnalyticsOs struct{} + +func (_ FfiDestroyerBindingAnalyticsOs) Destroy(value BindingAnalyticsOs) { +} + +type BindingCaptureEndReason uint + +const ( + BindingCaptureEndReasonExpired BindingCaptureEndReason = 1 + BindingCaptureEndReasonRequested BindingCaptureEndReason = 2 + BindingCaptureEndReasonSuspensionExpiryUnknown BindingCaptureEndReason = 3 + BindingCaptureEndReasonRuntimeShutdown BindingCaptureEndReason = 4 +) + +type FfiConverterBindingCaptureEndReason struct{} + +var FfiConverterBindingCaptureEndReasonINSTANCE = FfiConverterBindingCaptureEndReason{} + +func (c FfiConverterBindingCaptureEndReason) Lift(rb RustBufferI) BindingCaptureEndReason { + return LiftFromRustBuffer[BindingCaptureEndReason](c, rb) +} + +func (c FfiConverterBindingCaptureEndReason) Lower(value BindingCaptureEndReason) C.RustBuffer { + return LowerIntoRustBuffer[BindingCaptureEndReason](c, value) +} + +func (c FfiConverterBindingCaptureEndReason) LowerExternal(value BindingCaptureEndReason) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingCaptureEndReason](c, value)) +} +func (FfiConverterBindingCaptureEndReason) Read(reader io.Reader) BindingCaptureEndReason { + id := readInt32(reader) + return BindingCaptureEndReason(id) +} + +func (FfiConverterBindingCaptureEndReason) Write(writer io.Writer, value BindingCaptureEndReason) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingCaptureEndReason struct{} + +func (_ FfiDestroyerBindingCaptureEndReason) Destroy(value BindingCaptureEndReason) { +} + +type BindingClipboardOrigin uint + +const ( + BindingClipboardOriginLocal BindingClipboardOrigin = 1 + BindingClipboardOriginRemote BindingClipboardOrigin = 2 +) + +type FfiConverterBindingClipboardOrigin struct{} + +var FfiConverterBindingClipboardOriginINSTANCE = FfiConverterBindingClipboardOrigin{} + +func (c FfiConverterBindingClipboardOrigin) Lift(rb RustBufferI) BindingClipboardOrigin { + return LiftFromRustBuffer[BindingClipboardOrigin](c, rb) +} + +func (c FfiConverterBindingClipboardOrigin) Lower(value BindingClipboardOrigin) C.RustBuffer { + return LowerIntoRustBuffer[BindingClipboardOrigin](c, value) +} + +func (c FfiConverterBindingClipboardOrigin) LowerExternal(value BindingClipboardOrigin) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingClipboardOrigin](c, value)) +} +func (FfiConverterBindingClipboardOrigin) Read(reader io.Reader) BindingClipboardOrigin { + id := readInt32(reader) + return BindingClipboardOrigin(id) +} + +func (FfiConverterBindingClipboardOrigin) Write(writer io.Writer, value BindingClipboardOrigin) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingClipboardOrigin struct{} + +func (_ FfiDestroyerBindingClipboardOrigin) Destroy(value BindingClipboardOrigin) { +} + +type BindingClipboardRepresentation interface { + Destroy() +} +type BindingClipboardRepresentationInline struct { + Format string + MimeType *string + Bytes []byte +} + +func (e BindingClipboardRepresentationInline) Destroy() { + FfiDestroyerString{}.Destroy(e.Format) + FfiDestroyerOptionalString{}.Destroy(e.MimeType) + FfiDestroyerBytes{}.Destroy(e.Bytes) +} + +type BindingClipboardRepresentationFile struct { + Format string + Handle string + DisplayName string + MimeType *string + SizeBytes uint64 +} + +func (e BindingClipboardRepresentationFile) Destroy() { + FfiDestroyerString{}.Destroy(e.Format) + FfiDestroyerString{}.Destroy(e.Handle) + FfiDestroyerString{}.Destroy(e.DisplayName) + FfiDestroyerOptionalString{}.Destroy(e.MimeType) + FfiDestroyerUint64{}.Destroy(e.SizeBytes) +} + +type FfiConverterBindingClipboardRepresentation struct{} + +var FfiConverterBindingClipboardRepresentationINSTANCE = FfiConverterBindingClipboardRepresentation{} + +func (c FfiConverterBindingClipboardRepresentation) Lift(rb RustBufferI) BindingClipboardRepresentation { + return LiftFromRustBuffer[BindingClipboardRepresentation](c, rb) +} + +func (c FfiConverterBindingClipboardRepresentation) Lower(value BindingClipboardRepresentation) C.RustBuffer { + return LowerIntoRustBuffer[BindingClipboardRepresentation](c, value) +} + +func (c FfiConverterBindingClipboardRepresentation) LowerExternal(value BindingClipboardRepresentation) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingClipboardRepresentation](c, value)) +} +func (FfiConverterBindingClipboardRepresentation) Read(reader io.Reader) BindingClipboardRepresentation { + id := readInt32(reader) + switch id { + case 1: + return BindingClipboardRepresentationInline{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterBytesINSTANCE.Read(reader), + } + case 2: + return BindingClipboardRepresentationFile{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } + default: + panic(fmt.Sprintf("invalid enum value %v in FfiConverterBindingClipboardRepresentation.Read()", id)) + } +} + +func (FfiConverterBindingClipboardRepresentation) Write(writer io.Writer, value BindingClipboardRepresentation) { + switch variant_value := value.(type) { + case BindingClipboardRepresentationInline: + writeInt32(writer, 1) + FfiConverterStringINSTANCE.Write(writer, variant_value.Format) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.MimeType) + FfiConverterBytesINSTANCE.Write(writer, variant_value.Bytes) + case BindingClipboardRepresentationFile: + writeInt32(writer, 2) + FfiConverterStringINSTANCE.Write(writer, variant_value.Format) + FfiConverterStringINSTANCE.Write(writer, variant_value.Handle) + FfiConverterStringINSTANCE.Write(writer, variant_value.DisplayName) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.MimeType) + FfiConverterUint64INSTANCE.Write(writer, variant_value.SizeBytes) + default: + _ = variant_value + panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterBindingClipboardRepresentation.Write", value)) + } +} + +type FfiDestroyerBindingClipboardRepresentation struct{} + +func (_ FfiDestroyerBindingClipboardRepresentation) Destroy(value BindingClipboardRepresentation) { + value.Destroy() +} + +type BindingClipboardRestoreMode uint + +const ( + BindingClipboardRestoreModeStandard BindingClipboardRestoreMode = 1 + BindingClipboardRestoreModePlainText BindingClipboardRestoreMode = 2 + BindingClipboardRestoreModeFilePaths BindingClipboardRestoreMode = 3 +) + +type FfiConverterBindingClipboardRestoreMode struct{} + +var FfiConverterBindingClipboardRestoreModeINSTANCE = FfiConverterBindingClipboardRestoreMode{} + +func (c FfiConverterBindingClipboardRestoreMode) Lift(rb RustBufferI) BindingClipboardRestoreMode { + return LiftFromRustBuffer[BindingClipboardRestoreMode](c, rb) +} + +func (c FfiConverterBindingClipboardRestoreMode) Lower(value BindingClipboardRestoreMode) C.RustBuffer { + return LowerIntoRustBuffer[BindingClipboardRestoreMode](c, value) +} + +func (c FfiConverterBindingClipboardRestoreMode) LowerExternal(value BindingClipboardRestoreMode) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingClipboardRestoreMode](c, value)) +} +func (FfiConverterBindingClipboardRestoreMode) Read(reader io.Reader) BindingClipboardRestoreMode { + id := readInt32(reader) + return BindingClipboardRestoreMode(id) +} + +func (FfiConverterBindingClipboardRestoreMode) Write(writer io.Writer, value BindingClipboardRestoreMode) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingClipboardRestoreMode struct{} + +func (_ FfiDestroyerBindingClipboardRestoreMode) Destroy(value BindingClipboardRestoreMode) { +} + +type BindingClipboardRestoreOutcome uint + +const ( + BindingClipboardRestoreOutcomeRestored BindingClipboardRestoreOutcome = 1 + BindingClipboardRestoreOutcomePayloadUnavailable BindingClipboardRestoreOutcome = 2 + BindingClipboardRestoreOutcomeNotApplicable BindingClipboardRestoreOutcome = 3 +) + +type FfiConverterBindingClipboardRestoreOutcome struct{} + +var FfiConverterBindingClipboardRestoreOutcomeINSTANCE = FfiConverterBindingClipboardRestoreOutcome{} + +func (c FfiConverterBindingClipboardRestoreOutcome) Lift(rb RustBufferI) BindingClipboardRestoreOutcome { + return LiftFromRustBuffer[BindingClipboardRestoreOutcome](c, rb) +} + +func (c FfiConverterBindingClipboardRestoreOutcome) Lower(value BindingClipboardRestoreOutcome) C.RustBuffer { + return LowerIntoRustBuffer[BindingClipboardRestoreOutcome](c, value) +} + +func (c FfiConverterBindingClipboardRestoreOutcome) LowerExternal(value BindingClipboardRestoreOutcome) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingClipboardRestoreOutcome](c, value)) +} +func (FfiConverterBindingClipboardRestoreOutcome) Read(reader io.Reader) BindingClipboardRestoreOutcome { + id := readInt32(reader) + return BindingClipboardRestoreOutcome(id) +} + +func (FfiConverterBindingClipboardRestoreOutcome) Write(writer io.Writer, value BindingClipboardRestoreOutcome) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingClipboardRestoreOutcome struct{} + +func (_ FfiDestroyerBindingClipboardRestoreOutcome) Destroy(value BindingClipboardRestoreOutcome) { +} + +type BindingDeploymentEnvironment uint + +const ( + BindingDeploymentEnvironmentDevelopment BindingDeploymentEnvironment = 1 + BindingDeploymentEnvironmentTest BindingDeploymentEnvironment = 2 + BindingDeploymentEnvironmentStaging BindingDeploymentEnvironment = 3 + BindingDeploymentEnvironmentProduction BindingDeploymentEnvironment = 4 +) + +type FfiConverterBindingDeploymentEnvironment struct{} + +var FfiConverterBindingDeploymentEnvironmentINSTANCE = FfiConverterBindingDeploymentEnvironment{} + +func (c FfiConverterBindingDeploymentEnvironment) Lift(rb RustBufferI) BindingDeploymentEnvironment { + return LiftFromRustBuffer[BindingDeploymentEnvironment](c, rb) +} + +func (c FfiConverterBindingDeploymentEnvironment) Lower(value BindingDeploymentEnvironment) C.RustBuffer { + return LowerIntoRustBuffer[BindingDeploymentEnvironment](c, value) +} + +func (c FfiConverterBindingDeploymentEnvironment) LowerExternal(value BindingDeploymentEnvironment) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingDeploymentEnvironment](c, value)) +} +func (FfiConverterBindingDeploymentEnvironment) Read(reader io.Reader) BindingDeploymentEnvironment { + id := readInt32(reader) + return BindingDeploymentEnvironment(id) +} + +func (FfiConverterBindingDeploymentEnvironment) Write(writer io.Writer, value BindingDeploymentEnvironment) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingDeploymentEnvironment struct{} + +func (_ FfiDestroyerBindingDeploymentEnvironment) Destroy(value BindingDeploymentEnvironment) { +} + +type BindingEngineState uint + +const ( + BindingEngineStateRunning BindingEngineState = 1 + BindingEngineStateQuiescing BindingEngineState = 2 + BindingEngineStateQuiesced BindingEngineState = 3 + BindingEngineStateSuspended BindingEngineState = 4 + BindingEngineStateShuttingDown BindingEngineState = 5 + BindingEngineStateStopped BindingEngineState = 6 +) + +type FfiConverterBindingEngineState struct{} + +var FfiConverterBindingEngineStateINSTANCE = FfiConverterBindingEngineState{} + +func (c FfiConverterBindingEngineState) Lift(rb RustBufferI) BindingEngineState { + return LiftFromRustBuffer[BindingEngineState](c, rb) +} + +func (c FfiConverterBindingEngineState) Lower(value BindingEngineState) C.RustBuffer { + return LowerIntoRustBuffer[BindingEngineState](c, value) +} + +func (c FfiConverterBindingEngineState) LowerExternal(value BindingEngineState) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingEngineState](c, value)) +} +func (FfiConverterBindingEngineState) Read(reader io.Reader) BindingEngineState { + id := readInt32(reader) + return BindingEngineState(id) +} + +func (FfiConverterBindingEngineState) Write(writer io.Writer, value BindingEngineState) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingEngineState struct{} + +func (_ FfiDestroyerBindingEngineState) Destroy(value BindingEngineState) { +} + +type BindingError struct { + err error +} + +// Convenience method to turn *BindingError into error +// Avoiding treating nil pointer as non nil error interface +func (err *BindingError) AsError() error { + if err == nil { + return nil + } else { + return err + } +} + +func (err BindingError) Error() string { + return fmt.Sprintf("BindingError: %s", err.err.Error()) +} + +func (err BindingError) Unwrap() error { + return err.err +} + +// Err* are used for checking error type with `errors.Is` +var ErrBindingErrorEngine = fmt.Errorf("BindingErrorEngine") +var ErrBindingErrorHostUnavailable = fmt.Errorf("BindingErrorHostUnavailable") +var ErrBindingErrorHostPermissionDenied = fmt.Errorf("BindingErrorHostPermissionDenied") +var ErrBindingErrorHostInvalidHandle = fmt.Errorf("BindingErrorHostInvalidHandle") +var ErrBindingErrorHostIo = fmt.Errorf("BindingErrorHostIo") +var ErrBindingErrorRuntimeUnavailable = fmt.Errorf("BindingErrorRuntimeUnavailable") +var ErrBindingErrorAlreadyStopped = fmt.Errorf("BindingErrorAlreadyStopped") +var ErrBindingErrorObservabilityConfigInvalid = fmt.Errorf("BindingErrorObservabilityConfigInvalid") +var ErrBindingErrorObservabilityConfigConflict = fmt.Errorf("BindingErrorObservabilityConfigConflict") +var ErrBindingErrorObservabilityRuntimeUnavailable = fmt.Errorf("BindingErrorObservabilityRuntimeUnavailable") +var ErrBindingErrorObservabilityNotInstalled = fmt.Errorf("BindingErrorObservabilityNotInstalled") +var ErrBindingErrorUnexpectedResult = fmt.Errorf("BindingErrorUnexpectedResult") + +// Variant structs +type BindingErrorEngine struct { + Code uint32 + Category BindingErrorCategory + Retryable bool +} + +func NewBindingErrorEngine( + code uint32, + category BindingErrorCategory, + retryable bool, +) *BindingError { + return &BindingError{err: &BindingErrorEngine{ + Code: code, + Category: category, + Retryable: retryable}} +} + +func (e BindingErrorEngine) destroy() { + FfiDestroyerUint32{}.Destroy(e.Code) + FfiDestroyerBindingErrorCategory{}.Destroy(e.Category) + FfiDestroyerBool{}.Destroy(e.Retryable) +} + +func (err BindingErrorEngine) Error() string { + return fmt.Sprint("Engine", + ": ", + + "Code=", + err.Code, + ", ", + "Category=", + err.Category, + ", ", + "Retryable=", + err.Retryable, + ) +} + +func (self BindingErrorEngine) Is(target error) bool { + return target == ErrBindingErrorEngine +} + +type BindingErrorHostUnavailable struct { +} + +func NewBindingErrorHostUnavailable() *BindingError { + return &BindingError{err: &BindingErrorHostUnavailable{}} +} + +func (e BindingErrorHostUnavailable) destroy() { +} + +func (err BindingErrorHostUnavailable) Error() string { + return fmt.Sprint("HostUnavailable") +} + +func (self BindingErrorHostUnavailable) Is(target error) bool { + return target == ErrBindingErrorHostUnavailable +} + +type BindingErrorHostPermissionDenied struct { +} + +func NewBindingErrorHostPermissionDenied() *BindingError { + return &BindingError{err: &BindingErrorHostPermissionDenied{}} +} + +func (e BindingErrorHostPermissionDenied) destroy() { +} + +func (err BindingErrorHostPermissionDenied) Error() string { + return fmt.Sprint("HostPermissionDenied") +} + +func (self BindingErrorHostPermissionDenied) Is(target error) bool { + return target == ErrBindingErrorHostPermissionDenied +} + +type BindingErrorHostInvalidHandle struct { +} + +func NewBindingErrorHostInvalidHandle() *BindingError { + return &BindingError{err: &BindingErrorHostInvalidHandle{}} +} + +func (e BindingErrorHostInvalidHandle) destroy() { +} + +func (err BindingErrorHostInvalidHandle) Error() string { + return fmt.Sprint("HostInvalidHandle") +} + +func (self BindingErrorHostInvalidHandle) Is(target error) bool { + return target == ErrBindingErrorHostInvalidHandle +} + +type BindingErrorHostIo struct { +} + +func NewBindingErrorHostIo() *BindingError { + return &BindingError{err: &BindingErrorHostIo{}} +} + +func (e BindingErrorHostIo) destroy() { +} + +func (err BindingErrorHostIo) Error() string { + return fmt.Sprint("HostIo") +} + +func (self BindingErrorHostIo) Is(target error) bool { + return target == ErrBindingErrorHostIo +} + +type BindingErrorRuntimeUnavailable struct { +} + +func NewBindingErrorRuntimeUnavailable() *BindingError { + return &BindingError{err: &BindingErrorRuntimeUnavailable{}} +} + +func (e BindingErrorRuntimeUnavailable) destroy() { +} + +func (err BindingErrorRuntimeUnavailable) Error() string { + return fmt.Sprint("RuntimeUnavailable") +} + +func (self BindingErrorRuntimeUnavailable) Is(target error) bool { + return target == ErrBindingErrorRuntimeUnavailable +} + +type BindingErrorAlreadyStopped struct { +} + +func NewBindingErrorAlreadyStopped() *BindingError { + return &BindingError{err: &BindingErrorAlreadyStopped{}} +} + +func (e BindingErrorAlreadyStopped) destroy() { +} + +func (err BindingErrorAlreadyStopped) Error() string { + return fmt.Sprint("AlreadyStopped") +} + +func (self BindingErrorAlreadyStopped) Is(target error) bool { + return target == ErrBindingErrorAlreadyStopped +} + +type BindingErrorObservabilityConfigInvalid struct { +} + +func NewBindingErrorObservabilityConfigInvalid() *BindingError { + return &BindingError{err: &BindingErrorObservabilityConfigInvalid{}} +} + +func (e BindingErrorObservabilityConfigInvalid) destroy() { +} + +func (err BindingErrorObservabilityConfigInvalid) Error() string { + return fmt.Sprint("ObservabilityConfigInvalid") +} + +func (self BindingErrorObservabilityConfigInvalid) Is(target error) bool { + return target == ErrBindingErrorObservabilityConfigInvalid +} + +type BindingErrorObservabilityConfigConflict struct { +} + +func NewBindingErrorObservabilityConfigConflict() *BindingError { + return &BindingError{err: &BindingErrorObservabilityConfigConflict{}} +} + +func (e BindingErrorObservabilityConfigConflict) destroy() { +} + +func (err BindingErrorObservabilityConfigConflict) Error() string { + return fmt.Sprint("ObservabilityConfigConflict") +} + +func (self BindingErrorObservabilityConfigConflict) Is(target error) bool { + return target == ErrBindingErrorObservabilityConfigConflict +} + +type BindingErrorObservabilityRuntimeUnavailable struct { +} + +func NewBindingErrorObservabilityRuntimeUnavailable() *BindingError { + return &BindingError{err: &BindingErrorObservabilityRuntimeUnavailable{}} +} + +func (e BindingErrorObservabilityRuntimeUnavailable) destroy() { +} + +func (err BindingErrorObservabilityRuntimeUnavailable) Error() string { + return fmt.Sprint("ObservabilityRuntimeUnavailable") +} + +func (self BindingErrorObservabilityRuntimeUnavailable) Is(target error) bool { + return target == ErrBindingErrorObservabilityRuntimeUnavailable +} + +type BindingErrorObservabilityNotInstalled struct { +} + +func NewBindingErrorObservabilityNotInstalled() *BindingError { + return &BindingError{err: &BindingErrorObservabilityNotInstalled{}} +} + +func (e BindingErrorObservabilityNotInstalled) destroy() { +} + +func (err BindingErrorObservabilityNotInstalled) Error() string { + return fmt.Sprint("ObservabilityNotInstalled") +} + +func (self BindingErrorObservabilityNotInstalled) Is(target error) bool { + return target == ErrBindingErrorObservabilityNotInstalled +} + +type BindingErrorUnexpectedResult struct { +} + +func NewBindingErrorUnexpectedResult() *BindingError { + return &BindingError{err: &BindingErrorUnexpectedResult{}} +} + +func (e BindingErrorUnexpectedResult) destroy() { +} + +func (err BindingErrorUnexpectedResult) Error() string { + return fmt.Sprint("UnexpectedResult") +} + +func (self BindingErrorUnexpectedResult) Is(target error) bool { + return target == ErrBindingErrorUnexpectedResult +} + +type FfiConverterBindingError struct{} + +var FfiConverterBindingErrorINSTANCE = FfiConverterBindingError{} + +func (c FfiConverterBindingError) Lift(eb RustBufferI) *BindingError { + return LiftFromRustBuffer[*BindingError](c, eb) +} + +func (c FfiConverterBindingError) Lower(value *BindingError) C.RustBuffer { + return LowerIntoRustBuffer[*BindingError](c, value) +} + +func (c FfiConverterBindingError) LowerExternal(value *BindingError) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingError](c, value)) +} + +func (c FfiConverterBindingError) Read(reader io.Reader) *BindingError { + errorID := readUint32(reader) + + switch errorID { + case 1: + return &BindingError{&BindingErrorEngine{ + Code: FfiConverterUint32INSTANCE.Read(reader), + Category: FfiConverterBindingErrorCategoryINSTANCE.Read(reader), + Retryable: FfiConverterBoolINSTANCE.Read(reader), + }} + case 2: + return &BindingError{&BindingErrorHostUnavailable{}} + case 3: + return &BindingError{&BindingErrorHostPermissionDenied{}} + case 4: + return &BindingError{&BindingErrorHostInvalidHandle{}} + case 5: + return &BindingError{&BindingErrorHostIo{}} + case 6: + return &BindingError{&BindingErrorRuntimeUnavailable{}} + case 7: + return &BindingError{&BindingErrorAlreadyStopped{}} + case 8: + return &BindingError{&BindingErrorObservabilityConfigInvalid{}} + case 9: + return &BindingError{&BindingErrorObservabilityConfigConflict{}} + case 10: + return &BindingError{&BindingErrorObservabilityRuntimeUnavailable{}} + case 11: + return &BindingError{&BindingErrorObservabilityNotInstalled{}} + case 12: + return &BindingError{&BindingErrorUnexpectedResult{}} + default: + panic(fmt.Sprintf("Unknown error code %d in FfiConverterBindingError.Read()", errorID)) + } +} + +func (c FfiConverterBindingError) Write(writer io.Writer, value *BindingError) { + switch variantValue := value.err.(type) { + case *BindingErrorEngine: + writeInt32(writer, 1) + FfiConverterUint32INSTANCE.Write(writer, variantValue.Code) + FfiConverterBindingErrorCategoryINSTANCE.Write(writer, variantValue.Category) + FfiConverterBoolINSTANCE.Write(writer, variantValue.Retryable) + case *BindingErrorHostUnavailable: + writeInt32(writer, 2) + case *BindingErrorHostPermissionDenied: + writeInt32(writer, 3) + case *BindingErrorHostInvalidHandle: + writeInt32(writer, 4) + case *BindingErrorHostIo: + writeInt32(writer, 5) + case *BindingErrorRuntimeUnavailable: + writeInt32(writer, 6) + case *BindingErrorAlreadyStopped: + writeInt32(writer, 7) + case *BindingErrorObservabilityConfigInvalid: + writeInt32(writer, 8) + case *BindingErrorObservabilityConfigConflict: + writeInt32(writer, 9) + case *BindingErrorObservabilityRuntimeUnavailable: + writeInt32(writer, 10) + case *BindingErrorObservabilityNotInstalled: + writeInt32(writer, 11) + case *BindingErrorUnexpectedResult: + writeInt32(writer, 12) + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiConverterBindingError.Write", value)) + } +} + +type FfiDestroyerBindingError struct{} + +func (_ FfiDestroyerBindingError) Destroy(value *BindingError) { + switch variantValue := value.err.(type) { + case BindingErrorEngine: + variantValue.destroy() + case BindingErrorHostUnavailable: + variantValue.destroy() + case BindingErrorHostPermissionDenied: + variantValue.destroy() + case BindingErrorHostInvalidHandle: + variantValue.destroy() + case BindingErrorHostIo: + variantValue.destroy() + case BindingErrorRuntimeUnavailable: + variantValue.destroy() + case BindingErrorAlreadyStopped: + variantValue.destroy() + case BindingErrorObservabilityConfigInvalid: + variantValue.destroy() + case BindingErrorObservabilityConfigConflict: + variantValue.destroy() + case BindingErrorObservabilityRuntimeUnavailable: + variantValue.destroy() + case BindingErrorObservabilityNotInstalled: + variantValue.destroy() + case BindingErrorUnexpectedResult: + variantValue.destroy() + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerBindingError.Destroy", value)) + } +} + +type BindingErrorCategory uint + +const ( + BindingErrorCategoryInvalidInput BindingErrorCategory = 1 + BindingErrorCategoryInvalidState BindingErrorCategory = 2 + BindingErrorCategoryUnauthorized BindingErrorCategory = 3 + BindingErrorCategoryNotFound BindingErrorCategory = 4 + BindingErrorCategoryConflict BindingErrorCategory = 5 + BindingErrorCategoryUnavailable BindingErrorCategory = 6 + BindingErrorCategoryDeadlineExceeded BindingErrorCategory = 7 + BindingErrorCategoryInternal BindingErrorCategory = 8 +) + +type FfiConverterBindingErrorCategory struct{} + +var FfiConverterBindingErrorCategoryINSTANCE = FfiConverterBindingErrorCategory{} + +func (c FfiConverterBindingErrorCategory) Lift(rb RustBufferI) BindingErrorCategory { + return LiftFromRustBuffer[BindingErrorCategory](c, rb) +} + +func (c FfiConverterBindingErrorCategory) Lower(value BindingErrorCategory) C.RustBuffer { + return LowerIntoRustBuffer[BindingErrorCategory](c, value) +} + +func (c FfiConverterBindingErrorCategory) LowerExternal(value BindingErrorCategory) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingErrorCategory](c, value)) +} +func (FfiConverterBindingErrorCategory) Read(reader io.Reader) BindingErrorCategory { + id := readInt32(reader) + return BindingErrorCategory(id) +} + +func (FfiConverterBindingErrorCategory) Write(writer io.Writer, value BindingErrorCategory) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingErrorCategory struct{} + +func (_ FfiDestroyerBindingErrorCategory) Destroy(value BindingErrorCategory) { +} + +type BindingEvent interface { + Destroy() +} +type BindingEventStateChanged struct { + State BindingEngineState +} + +func (e BindingEventStateChanged) Destroy() { + FfiDestroyerBindingEngineState{}.Destroy(e.State) +} + +type BindingEventOperationFinished struct { + OperationId string + Terminal BindingOperationTerminal + Failure *BindingFailure +} + +func (e BindingEventOperationFinished) Destroy() { + FfiDestroyerString{}.Destroy(e.OperationId) + FfiDestroyerBindingOperationTerminal{}.Destroy(e.Terminal) + FfiDestroyerOptionalBindingFailure{}.Destroy(e.Failure) +} + +type BindingEventLifecycleFailed struct { + Action BindingLifecycleAction + Failure BindingFailure +} + +func (e BindingEventLifecycleFailed) Destroy() { + FfiDestroyerBindingLifecycleAction{}.Destroy(e.Action) + FfiDestroyerBindingFailure{}.Destroy(e.Failure) +} + +type BindingEventRefreshRequired struct { + Reason BindingRefreshReason +} + +func (e BindingEventRefreshRequired) Destroy() { + FfiDestroyerBindingRefreshReason{}.Destroy(e.Reason) +} + +type BindingEventFatal struct { + Failure BindingFailure +} + +func (e BindingEventFatal) Destroy() { + FfiDestroyerBindingFailure{}.Destroy(e.Failure) +} + +type BindingEventIncomingEntry struct { + EntryId string + AttemptId *string + Preview string + Origin BindingClipboardOrigin +} + +func (e BindingEventIncomingEntry) Destroy() { + FfiDestroyerString{}.Destroy(e.EntryId) + FfiDestroyerOptionalString{}.Destroy(e.AttemptId) + FfiDestroyerString{}.Destroy(e.Preview) + FfiDestroyerBindingClipboardOrigin{}.Destroy(e.Origin) +} + +type BindingEventIncomingPending struct { + EntryId string + AttemptId *string + FromDevice string + TotalBytes *uint64 + Filenames []string +} + +func (e BindingEventIncomingPending) Destroy() { + FfiDestroyerString{}.Destroy(e.EntryId) + FfiDestroyerOptionalString{}.Destroy(e.AttemptId) + FfiDestroyerString{}.Destroy(e.FromDevice) + FfiDestroyerOptionalUint64{}.Destroy(e.TotalBytes) + FfiDestroyerSequenceString{}.Destroy(e.Filenames) +} + +type BindingEventReceiveAttemptStateChanged struct { + EntryId string + AttemptId string + State string +} + +func (e BindingEventReceiveAttemptStateChanged) Destroy() { + FfiDestroyerString{}.Destroy(e.EntryId) + FfiDestroyerString{}.Destroy(e.AttemptId) + FfiDestroyerString{}.Destroy(e.State) +} + +type BindingEventDeliveryStatusChanged struct { + EntryId string + TargetDeviceId string +} + +func (e BindingEventDeliveryStatusChanged) Destroy() { + FfiDestroyerString{}.Destroy(e.EntryId) + FfiDestroyerString{}.Destroy(e.TargetDeviceId) +} + +type BindingEventPeerPresenceChanged struct { + DeviceId string + State string + AtMs int64 +} + +func (e BindingEventPeerPresenceChanged) Destroy() { + FfiDestroyerString{}.Destroy(e.DeviceId) + FfiDestroyerString{}.Destroy(e.State) + FfiDestroyerInt64{}.Destroy(e.AtMs) +} + +type BindingEventDeviceTrustChanged struct { + Revision uint64 +} + +func (e BindingEventDeviceTrustChanged) Destroy() { + FfiDestroyerUint64{}.Destroy(e.Revision) +} + +type BindingEventTransferProgress struct { + TransferId string + EntryId *string + AttemptId *string + PeerId string + Direction BindingTransferDirection + CompletedBytes uint64 + TotalBytes *uint64 +} + +func (e BindingEventTransferProgress) Destroy() { + FfiDestroyerString{}.Destroy(e.TransferId) + FfiDestroyerOptionalString{}.Destroy(e.EntryId) + FfiDestroyerOptionalString{}.Destroy(e.AttemptId) + FfiDestroyerString{}.Destroy(e.PeerId) + FfiDestroyerBindingTransferDirection{}.Destroy(e.Direction) + FfiDestroyerUint64{}.Destroy(e.CompletedBytes) + FfiDestroyerOptionalUint64{}.Destroy(e.TotalBytes) +} + +type BindingEventTransferStatusChanged struct { + TransferId string + EntryId *string + AttemptId *string + Status string + Reason *string +} + +func (e BindingEventTransferStatusChanged) Destroy() { + FfiDestroyerString{}.Destroy(e.TransferId) + FfiDestroyerOptionalString{}.Destroy(e.EntryId) + FfiDestroyerOptionalString{}.Destroy(e.AttemptId) + FfiDestroyerString{}.Destroy(e.Status) + FfiDestroyerOptionalString{}.Destroy(e.Reason) +} + +type BindingEventActiveClipboardChanged struct { + SnapshotHash string + EntryId string + ActivatedAtMs int64 + ActivatedBy string +} + +func (e BindingEventActiveClipboardChanged) Destroy() { + FfiDestroyerString{}.Destroy(e.SnapshotHash) + FfiDestroyerString{}.Destroy(e.EntryId) + FfiDestroyerInt64{}.Destroy(e.ActivatedAtMs) + FfiDestroyerString{}.Destroy(e.ActivatedBy) +} + +type BindingEventNetworkRecoveryChanged struct { + Phase string + Retryable bool + NextRetryInMs *uint64 +} + +func (e BindingEventNetworkRecoveryChanged) Destroy() { + FfiDestroyerString{}.Destroy(e.Phase) + FfiDestroyerBool{}.Destroy(e.Retryable) + FfiDestroyerOptionalUint64{}.Destroy(e.NextRetryInMs) +} + +type BindingEventRePairingRequired struct { + Scope BindingRePairingScope +} + +func (e BindingEventRePairingRequired) Destroy() { + FfiDestroyerBindingRePairingScope{}.Destroy(e.Scope) +} + +type BindingEventChanged struct { + Kind string +} + +func (e BindingEventChanged) Destroy() { + FfiDestroyerString{}.Destroy(e.Kind) +} + +type FfiConverterBindingEvent struct{} + +var FfiConverterBindingEventINSTANCE = FfiConverterBindingEvent{} + +func (c FfiConverterBindingEvent) Lift(rb RustBufferI) BindingEvent { + return LiftFromRustBuffer[BindingEvent](c, rb) +} + +func (c FfiConverterBindingEvent) Lower(value BindingEvent) C.RustBuffer { + return LowerIntoRustBuffer[BindingEvent](c, value) +} + +func (c FfiConverterBindingEvent) LowerExternal(value BindingEvent) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingEvent](c, value)) +} +func (FfiConverterBindingEvent) Read(reader io.Reader) BindingEvent { + id := readInt32(reader) + switch id { + case 1: + return BindingEventStateChanged{ + FfiConverterBindingEngineStateINSTANCE.Read(reader), + } + case 2: + return BindingEventOperationFinished{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBindingOperationTerminalINSTANCE.Read(reader), + FfiConverterOptionalBindingFailureINSTANCE.Read(reader), + } + case 3: + return BindingEventLifecycleFailed{ + FfiConverterBindingLifecycleActionINSTANCE.Read(reader), + FfiConverterBindingFailureINSTANCE.Read(reader), + } + case 4: + return BindingEventRefreshRequired{ + FfiConverterBindingRefreshReasonINSTANCE.Read(reader), + } + case 5: + return BindingEventFatal{ + FfiConverterBindingFailureINSTANCE.Read(reader), + } + case 6: + return BindingEventIncomingEntry{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBindingClipboardOriginINSTANCE.Read(reader), + } + case 7: + return BindingEventIncomingPending{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalUint64INSTANCE.Read(reader), + FfiConverterSequenceStringINSTANCE.Read(reader), + } + case 8: + return BindingEventReceiveAttemptStateChanged{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } + case 9: + return BindingEventDeliveryStatusChanged{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } + case 10: + return BindingEventPeerPresenceChanged{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterInt64INSTANCE.Read(reader), + } + case 11: + return BindingEventDeviceTrustChanged{ + FfiConverterUint64INSTANCE.Read(reader), + } + case 12: + return BindingEventTransferProgress{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBindingTransferDirectionINSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterOptionalUint64INSTANCE.Read(reader), + } + case 13: + return BindingEventTransferStatusChanged{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + } + case 14: + return BindingEventActiveClipboardChanged{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterInt64INSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + } + case 15: + return BindingEventNetworkRecoveryChanged{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterOptionalUint64INSTANCE.Read(reader), + } + case 16: + return BindingEventRePairingRequired{ + FfiConverterBindingRePairingScopeINSTANCE.Read(reader), + } + case 17: + return BindingEventChanged{ + FfiConverterStringINSTANCE.Read(reader), + } + default: + panic(fmt.Sprintf("invalid enum value %v in FfiConverterBindingEvent.Read()", id)) + } +} + +func (FfiConverterBindingEvent) Write(writer io.Writer, value BindingEvent) { + switch variant_value := value.(type) { + case BindingEventStateChanged: + writeInt32(writer, 1) + FfiConverterBindingEngineStateINSTANCE.Write(writer, variant_value.State) + case BindingEventOperationFinished: + writeInt32(writer, 2) + FfiConverterStringINSTANCE.Write(writer, variant_value.OperationId) + FfiConverterBindingOperationTerminalINSTANCE.Write(writer, variant_value.Terminal) + FfiConverterOptionalBindingFailureINSTANCE.Write(writer, variant_value.Failure) + case BindingEventLifecycleFailed: + writeInt32(writer, 3) + FfiConverterBindingLifecycleActionINSTANCE.Write(writer, variant_value.Action) + FfiConverterBindingFailureINSTANCE.Write(writer, variant_value.Failure) + case BindingEventRefreshRequired: + writeInt32(writer, 4) + FfiConverterBindingRefreshReasonINSTANCE.Write(writer, variant_value.Reason) + case BindingEventFatal: + writeInt32(writer, 5) + FfiConverterBindingFailureINSTANCE.Write(writer, variant_value.Failure) + case BindingEventIncomingEntry: + writeInt32(writer, 6) + FfiConverterStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.AttemptId) + FfiConverterStringINSTANCE.Write(writer, variant_value.Preview) + FfiConverterBindingClipboardOriginINSTANCE.Write(writer, variant_value.Origin) + case BindingEventIncomingPending: + writeInt32(writer, 7) + FfiConverterStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.AttemptId) + FfiConverterStringINSTANCE.Write(writer, variant_value.FromDevice) + FfiConverterOptionalUint64INSTANCE.Write(writer, variant_value.TotalBytes) + FfiConverterSequenceStringINSTANCE.Write(writer, variant_value.Filenames) + case BindingEventReceiveAttemptStateChanged: + writeInt32(writer, 8) + FfiConverterStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterStringINSTANCE.Write(writer, variant_value.AttemptId) + FfiConverterStringINSTANCE.Write(writer, variant_value.State) + case BindingEventDeliveryStatusChanged: + writeInt32(writer, 9) + FfiConverterStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterStringINSTANCE.Write(writer, variant_value.TargetDeviceId) + case BindingEventPeerPresenceChanged: + writeInt32(writer, 10) + FfiConverterStringINSTANCE.Write(writer, variant_value.DeviceId) + FfiConverterStringINSTANCE.Write(writer, variant_value.State) + FfiConverterInt64INSTANCE.Write(writer, variant_value.AtMs) + case BindingEventDeviceTrustChanged: + writeInt32(writer, 11) + FfiConverterUint64INSTANCE.Write(writer, variant_value.Revision) + case BindingEventTransferProgress: + writeInt32(writer, 12) + FfiConverterStringINSTANCE.Write(writer, variant_value.TransferId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.AttemptId) + FfiConverterStringINSTANCE.Write(writer, variant_value.PeerId) + FfiConverterBindingTransferDirectionINSTANCE.Write(writer, variant_value.Direction) + FfiConverterUint64INSTANCE.Write(writer, variant_value.CompletedBytes) + FfiConverterOptionalUint64INSTANCE.Write(writer, variant_value.TotalBytes) + case BindingEventTransferStatusChanged: + writeInt32(writer, 13) + FfiConverterStringINSTANCE.Write(writer, variant_value.TransferId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.AttemptId) + FfiConverterStringINSTANCE.Write(writer, variant_value.Status) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.Reason) + case BindingEventActiveClipboardChanged: + writeInt32(writer, 14) + FfiConverterStringINSTANCE.Write(writer, variant_value.SnapshotHash) + FfiConverterStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterInt64INSTANCE.Write(writer, variant_value.ActivatedAtMs) + FfiConverterStringINSTANCE.Write(writer, variant_value.ActivatedBy) + case BindingEventNetworkRecoveryChanged: + writeInt32(writer, 15) + FfiConverterStringINSTANCE.Write(writer, variant_value.Phase) + FfiConverterBoolINSTANCE.Write(writer, variant_value.Retryable) + FfiConverterOptionalUint64INSTANCE.Write(writer, variant_value.NextRetryInMs) + case BindingEventRePairingRequired: + writeInt32(writer, 16) + FfiConverterBindingRePairingScopeINSTANCE.Write(writer, variant_value.Scope) + case BindingEventChanged: + writeInt32(writer, 17) + FfiConverterStringINSTANCE.Write(writer, variant_value.Kind) + default: + _ = variant_value + panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterBindingEvent.Write", value)) + } +} + +type FfiDestroyerBindingEvent struct{} + +func (_ FfiDestroyerBindingEvent) Destroy(value BindingEvent) { + value.Destroy() +} + +type BindingHostDiagnosticAction uint + +const ( + BindingHostDiagnosticActionRuntimeStart BindingHostDiagnosticAction = 1 + BindingHostDiagnosticActionRuntimeStop BindingHostDiagnosticAction = 2 + BindingHostDiagnosticActionOwnershipAcquire BindingHostDiagnosticAction = 3 + BindingHostDiagnosticActionSecurityPrepare BindingHostDiagnosticAction = 4 +) + +type FfiConverterBindingHostDiagnosticAction struct{} + +var FfiConverterBindingHostDiagnosticActionINSTANCE = FfiConverterBindingHostDiagnosticAction{} + +func (c FfiConverterBindingHostDiagnosticAction) Lift(rb RustBufferI) BindingHostDiagnosticAction { + return LiftFromRustBuffer[BindingHostDiagnosticAction](c, rb) +} + +func (c FfiConverterBindingHostDiagnosticAction) Lower(value BindingHostDiagnosticAction) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostDiagnosticAction](c, value) +} + +func (c FfiConverterBindingHostDiagnosticAction) LowerExternal(value BindingHostDiagnosticAction) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostDiagnosticAction](c, value)) +} +func (FfiConverterBindingHostDiagnosticAction) Read(reader io.Reader) BindingHostDiagnosticAction { + id := readInt32(reader) + return BindingHostDiagnosticAction(id) +} + +func (FfiConverterBindingHostDiagnosticAction) Write(writer io.Writer, value BindingHostDiagnosticAction) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingHostDiagnosticAction struct{} + +func (_ FfiDestroyerBindingHostDiagnosticAction) Destroy(value BindingHostDiagnosticAction) { +} + +type BindingHostDiagnosticEvent interface { + Destroy() +} +type BindingHostDiagnosticEventBegin struct { + Action BindingHostDiagnosticAction +} + +func (e BindingHostDiagnosticEventBegin) Destroy() { + FfiDestroyerBindingHostDiagnosticAction{}.Destroy(e.Action) +} + +type BindingHostDiagnosticEventFinish struct { + Token string + Outcome BindingHostDiagnosticOutcome +} + +func (e BindingHostDiagnosticEventFinish) Destroy() { + FfiDestroyerString{}.Destroy(e.Token) + FfiDestroyerBindingHostDiagnosticOutcome{}.Destroy(e.Outcome) +} + +type BindingHostDiagnosticEventLifecycle struct { + State BindingHostLifecycleState +} + +func (e BindingHostDiagnosticEventLifecycle) Destroy() { + FfiDestroyerBindingHostLifecycleState{}.Destroy(e.State) +} + +type BindingHostDiagnosticEventNetworkChanged struct { + Kind BindingHostNetworkKind + Available bool +} + +func (e BindingHostDiagnosticEventNetworkChanged) Destroy() { + FfiDestroyerBindingHostNetworkKind{}.Destroy(e.Kind) + FfiDestroyerBool{}.Destroy(e.Available) +} + +type BindingHostDiagnosticEventOwnershipReleased struct { +} + +func (e BindingHostDiagnosticEventOwnershipReleased) Destroy() { +} + +type FfiConverterBindingHostDiagnosticEvent struct{} + +var FfiConverterBindingHostDiagnosticEventINSTANCE = FfiConverterBindingHostDiagnosticEvent{} + +func (c FfiConverterBindingHostDiagnosticEvent) Lift(rb RustBufferI) BindingHostDiagnosticEvent { + return LiftFromRustBuffer[BindingHostDiagnosticEvent](c, rb) +} + +func (c FfiConverterBindingHostDiagnosticEvent) Lower(value BindingHostDiagnosticEvent) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostDiagnosticEvent](c, value) +} + +func (c FfiConverterBindingHostDiagnosticEvent) LowerExternal(value BindingHostDiagnosticEvent) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostDiagnosticEvent](c, value)) +} +func (FfiConverterBindingHostDiagnosticEvent) Read(reader io.Reader) BindingHostDiagnosticEvent { + id := readInt32(reader) + switch id { + case 1: + return BindingHostDiagnosticEventBegin{ + FfiConverterBindingHostDiagnosticActionINSTANCE.Read(reader), + } + case 2: + return BindingHostDiagnosticEventFinish{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBindingHostDiagnosticOutcomeINSTANCE.Read(reader), + } + case 3: + return BindingHostDiagnosticEventLifecycle{ + FfiConverterBindingHostLifecycleStateINSTANCE.Read(reader), + } + case 4: + return BindingHostDiagnosticEventNetworkChanged{ + FfiConverterBindingHostNetworkKindINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } + case 5: + return BindingHostDiagnosticEventOwnershipReleased{} + default: + panic(fmt.Sprintf("invalid enum value %v in FfiConverterBindingHostDiagnosticEvent.Read()", id)) + } +} + +func (FfiConverterBindingHostDiagnosticEvent) Write(writer io.Writer, value BindingHostDiagnosticEvent) { + switch variant_value := value.(type) { + case BindingHostDiagnosticEventBegin: + writeInt32(writer, 1) + FfiConverterBindingHostDiagnosticActionINSTANCE.Write(writer, variant_value.Action) + case BindingHostDiagnosticEventFinish: + writeInt32(writer, 2) + FfiConverterStringINSTANCE.Write(writer, variant_value.Token) + FfiConverterBindingHostDiagnosticOutcomeINSTANCE.Write(writer, variant_value.Outcome) + case BindingHostDiagnosticEventLifecycle: + writeInt32(writer, 3) + FfiConverterBindingHostLifecycleStateINSTANCE.Write(writer, variant_value.State) + case BindingHostDiagnosticEventNetworkChanged: + writeInt32(writer, 4) + FfiConverterBindingHostNetworkKindINSTANCE.Write(writer, variant_value.Kind) + FfiConverterBoolINSTANCE.Write(writer, variant_value.Available) + case BindingHostDiagnosticEventOwnershipReleased: + writeInt32(writer, 5) + default: + _ = variant_value + panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterBindingHostDiagnosticEvent.Write", value)) + } +} + +type FfiDestroyerBindingHostDiagnosticEvent struct{} + +func (_ FfiDestroyerBindingHostDiagnosticEvent) Destroy(value BindingHostDiagnosticEvent) { + value.Destroy() +} + +type BindingHostDiagnosticFailure uint + +const ( + BindingHostDiagnosticFailureUnavailable BindingHostDiagnosticFailure = 1 + BindingHostDiagnosticFailurePermissionDenied BindingHostDiagnosticFailure = 2 + BindingHostDiagnosticFailureLocked BindingHostDiagnosticFailure = 3 + BindingHostDiagnosticFailureBusy BindingHostDiagnosticFailure = 4 + BindingHostDiagnosticFailureUnknown BindingHostDiagnosticFailure = 5 +) + +type FfiConverterBindingHostDiagnosticFailure struct{} + +var FfiConverterBindingHostDiagnosticFailureINSTANCE = FfiConverterBindingHostDiagnosticFailure{} + +func (c FfiConverterBindingHostDiagnosticFailure) Lift(rb RustBufferI) BindingHostDiagnosticFailure { + return LiftFromRustBuffer[BindingHostDiagnosticFailure](c, rb) +} + +func (c FfiConverterBindingHostDiagnosticFailure) Lower(value BindingHostDiagnosticFailure) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostDiagnosticFailure](c, value) +} + +func (c FfiConverterBindingHostDiagnosticFailure) LowerExternal(value BindingHostDiagnosticFailure) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostDiagnosticFailure](c, value)) +} +func (FfiConverterBindingHostDiagnosticFailure) Read(reader io.Reader) BindingHostDiagnosticFailure { + id := readInt32(reader) + return BindingHostDiagnosticFailure(id) +} + +func (FfiConverterBindingHostDiagnosticFailure) Write(writer io.Writer, value BindingHostDiagnosticFailure) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingHostDiagnosticFailure struct{} + +func (_ FfiDestroyerBindingHostDiagnosticFailure) Destroy(value BindingHostDiagnosticFailure) { +} + +type BindingHostDiagnosticOutcome interface { + Destroy() +} +type BindingHostDiagnosticOutcomeCompleted struct { +} + +func (e BindingHostDiagnosticOutcomeCompleted) Destroy() { +} + +type BindingHostDiagnosticOutcomeFailed struct { + Reason BindingHostDiagnosticFailure +} + +func (e BindingHostDiagnosticOutcomeFailed) Destroy() { + FfiDestroyerBindingHostDiagnosticFailure{}.Destroy(e.Reason) +} + +type BindingHostDiagnosticOutcomeInterrupted struct { +} + +func (e BindingHostDiagnosticOutcomeInterrupted) Destroy() { +} + +type FfiConverterBindingHostDiagnosticOutcome struct{} + +var FfiConverterBindingHostDiagnosticOutcomeINSTANCE = FfiConverterBindingHostDiagnosticOutcome{} + +func (c FfiConverterBindingHostDiagnosticOutcome) Lift(rb RustBufferI) BindingHostDiagnosticOutcome { + return LiftFromRustBuffer[BindingHostDiagnosticOutcome](c, rb) +} + +func (c FfiConverterBindingHostDiagnosticOutcome) Lower(value BindingHostDiagnosticOutcome) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostDiagnosticOutcome](c, value) +} + +func (c FfiConverterBindingHostDiagnosticOutcome) LowerExternal(value BindingHostDiagnosticOutcome) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostDiagnosticOutcome](c, value)) +} +func (FfiConverterBindingHostDiagnosticOutcome) Read(reader io.Reader) BindingHostDiagnosticOutcome { + id := readInt32(reader) + switch id { + case 1: + return BindingHostDiagnosticOutcomeCompleted{} + case 2: + return BindingHostDiagnosticOutcomeFailed{ + FfiConverterBindingHostDiagnosticFailureINSTANCE.Read(reader), + } + case 3: + return BindingHostDiagnosticOutcomeInterrupted{} + default: + panic(fmt.Sprintf("invalid enum value %v in FfiConverterBindingHostDiagnosticOutcome.Read()", id)) + } +} + +func (FfiConverterBindingHostDiagnosticOutcome) Write(writer io.Writer, value BindingHostDiagnosticOutcome) { + switch variant_value := value.(type) { + case BindingHostDiagnosticOutcomeCompleted: + writeInt32(writer, 1) + case BindingHostDiagnosticOutcomeFailed: + writeInt32(writer, 2) + FfiConverterBindingHostDiagnosticFailureINSTANCE.Write(writer, variant_value.Reason) + case BindingHostDiagnosticOutcomeInterrupted: + writeInt32(writer, 3) + default: + _ = variant_value + panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterBindingHostDiagnosticOutcome.Write", value)) + } +} + +type FfiDestroyerBindingHostDiagnosticOutcome struct{} + +func (_ FfiDestroyerBindingHostDiagnosticOutcome) Destroy(value BindingHostDiagnosticOutcome) { + value.Destroy() +} + +type BindingHostDiagnosticRecordStatus uint + +const ( + BindingHostDiagnosticRecordStatusAccepted BindingHostDiagnosticRecordStatus = 1 + BindingHostDiagnosticRecordStatusPolicyFiltered BindingHostDiagnosticRecordStatus = 2 + BindingHostDiagnosticRecordStatusCapacityExceeded BindingHostDiagnosticRecordStatus = 3 + BindingHostDiagnosticRecordStatusInvalidToken BindingHostDiagnosticRecordStatus = 4 + BindingHostDiagnosticRecordStatusInvalidSource BindingHostDiagnosticRecordStatus = 5 + BindingHostDiagnosticRecordStatusNotRegistered BindingHostDiagnosticRecordStatus = 6 + BindingHostDiagnosticRecordStatusUnavailable BindingHostDiagnosticRecordStatus = 7 + BindingHostDiagnosticRecordStatusAlreadyShutdown BindingHostDiagnosticRecordStatus = 8 +) + +type FfiConverterBindingHostDiagnosticRecordStatus struct{} + +var FfiConverterBindingHostDiagnosticRecordStatusINSTANCE = FfiConverterBindingHostDiagnosticRecordStatus{} + +func (c FfiConverterBindingHostDiagnosticRecordStatus) Lift(rb RustBufferI) BindingHostDiagnosticRecordStatus { + return LiftFromRustBuffer[BindingHostDiagnosticRecordStatus](c, rb) +} + +func (c FfiConverterBindingHostDiagnosticRecordStatus) Lower(value BindingHostDiagnosticRecordStatus) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostDiagnosticRecordStatus](c, value) +} + +func (c FfiConverterBindingHostDiagnosticRecordStatus) LowerExternal(value BindingHostDiagnosticRecordStatus) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostDiagnosticRecordStatus](c, value)) +} +func (FfiConverterBindingHostDiagnosticRecordStatus) Read(reader io.Reader) BindingHostDiagnosticRecordStatus { + id := readInt32(reader) + return BindingHostDiagnosticRecordStatus(id) +} + +func (FfiConverterBindingHostDiagnosticRecordStatus) Write(writer io.Writer, value BindingHostDiagnosticRecordStatus) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingHostDiagnosticRecordStatus struct{} + +func (_ FfiDestroyerBindingHostDiagnosticRecordStatus) Destroy(value BindingHostDiagnosticRecordStatus) { +} + +type BindingHostDiagnosticSource uint + +const ( + BindingHostDiagnosticSourceApplication BindingHostDiagnosticSource = 1 + BindingHostDiagnosticSourceShareExtension BindingHostDiagnosticSource = 2 + BindingHostDiagnosticSourceKeyboardExtension BindingHostDiagnosticSource = 3 + BindingHostDiagnosticSourceBackgroundService BindingHostDiagnosticSource = 4 +) + +type FfiConverterBindingHostDiagnosticSource struct{} + +var FfiConverterBindingHostDiagnosticSourceINSTANCE = FfiConverterBindingHostDiagnosticSource{} + +func (c FfiConverterBindingHostDiagnosticSource) Lift(rb RustBufferI) BindingHostDiagnosticSource { + return LiftFromRustBuffer[BindingHostDiagnosticSource](c, rb) +} + +func (c FfiConverterBindingHostDiagnosticSource) Lower(value BindingHostDiagnosticSource) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostDiagnosticSource](c, value) +} + +func (c FfiConverterBindingHostDiagnosticSource) LowerExternal(value BindingHostDiagnosticSource) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostDiagnosticSource](c, value)) +} +func (FfiConverterBindingHostDiagnosticSource) Read(reader io.Reader) BindingHostDiagnosticSource { + id := readInt32(reader) + return BindingHostDiagnosticSource(id) +} + +func (FfiConverterBindingHostDiagnosticSource) Write(writer io.Writer, value BindingHostDiagnosticSource) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingHostDiagnosticSource struct{} + +func (_ FfiDestroyerBindingHostDiagnosticSource) Destroy(value BindingHostDiagnosticSource) { +} + +type BindingHostLifecycleState uint + +const ( + BindingHostLifecycleStateForeground BindingHostLifecycleState = 1 + BindingHostLifecycleStateBackground BindingHostLifecycleState = 2 +) + +type FfiConverterBindingHostLifecycleState struct{} + +var FfiConverterBindingHostLifecycleStateINSTANCE = FfiConverterBindingHostLifecycleState{} + +func (c FfiConverterBindingHostLifecycleState) Lift(rb RustBufferI) BindingHostLifecycleState { + return LiftFromRustBuffer[BindingHostLifecycleState](c, rb) +} + +func (c FfiConverterBindingHostLifecycleState) Lower(value BindingHostLifecycleState) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostLifecycleState](c, value) +} + +func (c FfiConverterBindingHostLifecycleState) LowerExternal(value BindingHostLifecycleState) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostLifecycleState](c, value)) +} +func (FfiConverterBindingHostLifecycleState) Read(reader io.Reader) BindingHostLifecycleState { + id := readInt32(reader) + return BindingHostLifecycleState(id) +} + +func (FfiConverterBindingHostLifecycleState) Write(writer io.Writer, value BindingHostLifecycleState) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingHostLifecycleState struct{} + +func (_ FfiDestroyerBindingHostLifecycleState) Destroy(value BindingHostLifecycleState) { +} + +type BindingHostNetworkKind uint + +const ( + BindingHostNetworkKindWifi BindingHostNetworkKind = 1 + BindingHostNetworkKindCellular BindingHostNetworkKind = 2 + BindingHostNetworkKindEthernet BindingHostNetworkKind = 3 + BindingHostNetworkKindOther BindingHostNetworkKind = 4 + BindingHostNetworkKindUnknown BindingHostNetworkKind = 5 +) + +type FfiConverterBindingHostNetworkKind struct{} + +var FfiConverterBindingHostNetworkKindINSTANCE = FfiConverterBindingHostNetworkKind{} + +func (c FfiConverterBindingHostNetworkKind) Lift(rb RustBufferI) BindingHostNetworkKind { + return LiftFromRustBuffer[BindingHostNetworkKind](c, rb) +} + +func (c FfiConverterBindingHostNetworkKind) Lower(value BindingHostNetworkKind) C.RustBuffer { + return LowerIntoRustBuffer[BindingHostNetworkKind](c, value) +} + +func (c FfiConverterBindingHostNetworkKind) LowerExternal(value BindingHostNetworkKind) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingHostNetworkKind](c, value)) +} +func (FfiConverterBindingHostNetworkKind) Read(reader io.Reader) BindingHostNetworkKind { + id := readInt32(reader) + return BindingHostNetworkKind(id) +} + +func (FfiConverterBindingHostNetworkKind) Write(writer io.Writer, value BindingHostNetworkKind) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingHostNetworkKind struct{} + +func (_ FfiDestroyerBindingHostNetworkKind) Destroy(value BindingHostNetworkKind) { +} + +type BindingLifecycleAction uint + +const ( + BindingLifecycleActionSuspend BindingLifecycleAction = 1 + BindingLifecycleActionResume BindingLifecycleAction = 2 +) + +type FfiConverterBindingLifecycleAction struct{} + +var FfiConverterBindingLifecycleActionINSTANCE = FfiConverterBindingLifecycleAction{} + +func (c FfiConverterBindingLifecycleAction) Lift(rb RustBufferI) BindingLifecycleAction { + return LiftFromRustBuffer[BindingLifecycleAction](c, rb) +} + +func (c FfiConverterBindingLifecycleAction) Lower(value BindingLifecycleAction) C.RustBuffer { + return LowerIntoRustBuffer[BindingLifecycleAction](c, value) +} + +func (c FfiConverterBindingLifecycleAction) LowerExternal(value BindingLifecycleAction) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingLifecycleAction](c, value)) +} +func (FfiConverterBindingLifecycleAction) Read(reader io.Reader) BindingLifecycleAction { + id := readInt32(reader) + return BindingLifecycleAction(id) +} + +func (FfiConverterBindingLifecycleAction) Write(writer io.Writer, value BindingLifecycleAction) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingLifecycleAction struct{} + +func (_ FfiDestroyerBindingLifecycleAction) Destroy(value BindingLifecycleAction) { +} + +type BindingLocalCaptureMode uint + +const ( + BindingLocalCaptureModeStandard BindingLocalCaptureMode = 1 + BindingLocalCaptureModeDetailed BindingLocalCaptureMode = 2 +) + +type FfiConverterBindingLocalCaptureMode struct{} + +var FfiConverterBindingLocalCaptureModeINSTANCE = FfiConverterBindingLocalCaptureMode{} + +func (c FfiConverterBindingLocalCaptureMode) Lift(rb RustBufferI) BindingLocalCaptureMode { + return LiftFromRustBuffer[BindingLocalCaptureMode](c, rb) +} + +func (c FfiConverterBindingLocalCaptureMode) Lower(value BindingLocalCaptureMode) C.RustBuffer { + return LowerIntoRustBuffer[BindingLocalCaptureMode](c, value) +} + +func (c FfiConverterBindingLocalCaptureMode) LowerExternal(value BindingLocalCaptureMode) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingLocalCaptureMode](c, value)) +} +func (FfiConverterBindingLocalCaptureMode) Read(reader io.Reader) BindingLocalCaptureMode { + id := readInt32(reader) + return BindingLocalCaptureMode(id) +} + +func (FfiConverterBindingLocalCaptureMode) Write(writer io.Writer, value BindingLocalCaptureMode) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingLocalCaptureMode struct{} + +func (_ FfiDestroyerBindingLocalCaptureMode) Destroy(value BindingLocalCaptureMode) { +} + +type BindingLocalDiagnosticError struct { + err error +} + +// Convenience method to turn *BindingLocalDiagnosticError into error +// Avoiding treating nil pointer as non nil error interface +func (err *BindingLocalDiagnosticError) AsError() error { + if err == nil { + return nil + } else { + return err + } +} + +func (err BindingLocalDiagnosticError) Error() string { + return fmt.Sprintf("BindingLocalDiagnosticError: %s", err.err.Error()) +} + +func (err BindingLocalDiagnosticError) Unwrap() error { + return err.err +} + +// Err* are used for checking error type with `errors.Is` +var ErrBindingLocalDiagnosticErrorNotInstalled = fmt.Errorf("BindingLocalDiagnosticErrorNotInstalled") +var ErrBindingLocalDiagnosticErrorLocalSinkUnavailable = fmt.Errorf("BindingLocalDiagnosticErrorLocalSinkUnavailable") +var ErrBindingLocalDiagnosticErrorAlreadyShutdown = fmt.Errorf("BindingLocalDiagnosticErrorAlreadyShutdown") +var ErrBindingLocalDiagnosticErrorInvalidDuration = fmt.Errorf("BindingLocalDiagnosticErrorInvalidDuration") +var ErrBindingLocalDiagnosticErrorInvalidCaptureId = fmt.Errorf("BindingLocalDiagnosticErrorInvalidCaptureId") +var ErrBindingLocalDiagnosticErrorInvalidDeadline = fmt.Errorf("BindingLocalDiagnosticErrorInvalidDeadline") +var ErrBindingLocalDiagnosticErrorInvalidHostSource = fmt.Errorf("BindingLocalDiagnosticErrorInvalidHostSource") + +// Variant structs +type BindingLocalDiagnosticErrorNotInstalled struct { +} + +func NewBindingLocalDiagnosticErrorNotInstalled() *BindingLocalDiagnosticError { + return &BindingLocalDiagnosticError{err: &BindingLocalDiagnosticErrorNotInstalled{}} +} + +func (e BindingLocalDiagnosticErrorNotInstalled) destroy() { +} + +func (err BindingLocalDiagnosticErrorNotInstalled) Error() string { + return fmt.Sprint("NotInstalled") +} + +func (self BindingLocalDiagnosticErrorNotInstalled) Is(target error) bool { + return target == ErrBindingLocalDiagnosticErrorNotInstalled +} + +type BindingLocalDiagnosticErrorLocalSinkUnavailable struct { +} + +func NewBindingLocalDiagnosticErrorLocalSinkUnavailable() *BindingLocalDiagnosticError { + return &BindingLocalDiagnosticError{err: &BindingLocalDiagnosticErrorLocalSinkUnavailable{}} +} + +func (e BindingLocalDiagnosticErrorLocalSinkUnavailable) destroy() { +} + +func (err BindingLocalDiagnosticErrorLocalSinkUnavailable) Error() string { + return fmt.Sprint("LocalSinkUnavailable") +} + +func (self BindingLocalDiagnosticErrorLocalSinkUnavailable) Is(target error) bool { + return target == ErrBindingLocalDiagnosticErrorLocalSinkUnavailable +} + +type BindingLocalDiagnosticErrorAlreadyShutdown struct { +} + +func NewBindingLocalDiagnosticErrorAlreadyShutdown() *BindingLocalDiagnosticError { + return &BindingLocalDiagnosticError{err: &BindingLocalDiagnosticErrorAlreadyShutdown{}} +} + +func (e BindingLocalDiagnosticErrorAlreadyShutdown) destroy() { +} + +func (err BindingLocalDiagnosticErrorAlreadyShutdown) Error() string { + return fmt.Sprint("AlreadyShutdown") +} + +func (self BindingLocalDiagnosticErrorAlreadyShutdown) Is(target error) bool { + return target == ErrBindingLocalDiagnosticErrorAlreadyShutdown +} + +type BindingLocalDiagnosticErrorInvalidDuration struct { +} + +func NewBindingLocalDiagnosticErrorInvalidDuration() *BindingLocalDiagnosticError { + return &BindingLocalDiagnosticError{err: &BindingLocalDiagnosticErrorInvalidDuration{}} +} + +func (e BindingLocalDiagnosticErrorInvalidDuration) destroy() { +} + +func (err BindingLocalDiagnosticErrorInvalidDuration) Error() string { + return fmt.Sprint("InvalidDuration") +} + +func (self BindingLocalDiagnosticErrorInvalidDuration) Is(target error) bool { + return target == ErrBindingLocalDiagnosticErrorInvalidDuration +} + +type BindingLocalDiagnosticErrorInvalidCaptureId struct { +} + +func NewBindingLocalDiagnosticErrorInvalidCaptureId() *BindingLocalDiagnosticError { + return &BindingLocalDiagnosticError{err: &BindingLocalDiagnosticErrorInvalidCaptureId{}} +} + +func (e BindingLocalDiagnosticErrorInvalidCaptureId) destroy() { +} + +func (err BindingLocalDiagnosticErrorInvalidCaptureId) Error() string { + return fmt.Sprint("InvalidCaptureId") +} + +func (self BindingLocalDiagnosticErrorInvalidCaptureId) Is(target error) bool { + return target == ErrBindingLocalDiagnosticErrorInvalidCaptureId +} + +type BindingLocalDiagnosticErrorInvalidDeadline struct { +} + +func NewBindingLocalDiagnosticErrorInvalidDeadline() *BindingLocalDiagnosticError { + return &BindingLocalDiagnosticError{err: &BindingLocalDiagnosticErrorInvalidDeadline{}} +} + +func (e BindingLocalDiagnosticErrorInvalidDeadline) destroy() { +} + +func (err BindingLocalDiagnosticErrorInvalidDeadline) Error() string { + return fmt.Sprint("InvalidDeadline") +} + +func (self BindingLocalDiagnosticErrorInvalidDeadline) Is(target error) bool { + return target == ErrBindingLocalDiagnosticErrorInvalidDeadline +} + +type BindingLocalDiagnosticErrorInvalidHostSource struct { +} + +func NewBindingLocalDiagnosticErrorInvalidHostSource() *BindingLocalDiagnosticError { + return &BindingLocalDiagnosticError{err: &BindingLocalDiagnosticErrorInvalidHostSource{}} +} + +func (e BindingLocalDiagnosticErrorInvalidHostSource) destroy() { +} + +func (err BindingLocalDiagnosticErrorInvalidHostSource) Error() string { + return fmt.Sprint("InvalidHostSource") +} + +func (self BindingLocalDiagnosticErrorInvalidHostSource) Is(target error) bool { + return target == ErrBindingLocalDiagnosticErrorInvalidHostSource +} + +type FfiConverterBindingLocalDiagnosticError struct{} + +var FfiConverterBindingLocalDiagnosticErrorINSTANCE = FfiConverterBindingLocalDiagnosticError{} + +func (c FfiConverterBindingLocalDiagnosticError) Lift(eb RustBufferI) *BindingLocalDiagnosticError { + return LiftFromRustBuffer[*BindingLocalDiagnosticError](c, eb) +} + +func (c FfiConverterBindingLocalDiagnosticError) Lower(value *BindingLocalDiagnosticError) C.RustBuffer { + return LowerIntoRustBuffer[*BindingLocalDiagnosticError](c, value) +} + +func (c FfiConverterBindingLocalDiagnosticError) LowerExternal(value *BindingLocalDiagnosticError) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingLocalDiagnosticError](c, value)) +} + +func (c FfiConverterBindingLocalDiagnosticError) Read(reader io.Reader) *BindingLocalDiagnosticError { + errorID := readUint32(reader) + + switch errorID { + case 1: + return &BindingLocalDiagnosticError{&BindingLocalDiagnosticErrorNotInstalled{}} + case 2: + return &BindingLocalDiagnosticError{&BindingLocalDiagnosticErrorLocalSinkUnavailable{}} + case 3: + return &BindingLocalDiagnosticError{&BindingLocalDiagnosticErrorAlreadyShutdown{}} + case 4: + return &BindingLocalDiagnosticError{&BindingLocalDiagnosticErrorInvalidDuration{}} + case 5: + return &BindingLocalDiagnosticError{&BindingLocalDiagnosticErrorInvalidCaptureId{}} + case 6: + return &BindingLocalDiagnosticError{&BindingLocalDiagnosticErrorInvalidDeadline{}} + case 7: + return &BindingLocalDiagnosticError{&BindingLocalDiagnosticErrorInvalidHostSource{}} + default: + panic(fmt.Sprintf("Unknown error code %d in FfiConverterBindingLocalDiagnosticError.Read()", errorID)) + } +} + +func (c FfiConverterBindingLocalDiagnosticError) Write(writer io.Writer, value *BindingLocalDiagnosticError) { + switch variantValue := value.err.(type) { + case *BindingLocalDiagnosticErrorNotInstalled: + writeInt32(writer, 1) + case *BindingLocalDiagnosticErrorLocalSinkUnavailable: + writeInt32(writer, 2) + case *BindingLocalDiagnosticErrorAlreadyShutdown: + writeInt32(writer, 3) + case *BindingLocalDiagnosticErrorInvalidDuration: + writeInt32(writer, 4) + case *BindingLocalDiagnosticErrorInvalidCaptureId: + writeInt32(writer, 5) + case *BindingLocalDiagnosticErrorInvalidDeadline: + writeInt32(writer, 6) + case *BindingLocalDiagnosticErrorInvalidHostSource: + writeInt32(writer, 7) + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiConverterBindingLocalDiagnosticError.Write", value)) + } +} + +type FfiDestroyerBindingLocalDiagnosticError struct{} + +func (_ FfiDestroyerBindingLocalDiagnosticError) Destroy(value *BindingLocalDiagnosticError) { + switch variantValue := value.err.(type) { + case BindingLocalDiagnosticErrorNotInstalled: + variantValue.destroy() + case BindingLocalDiagnosticErrorLocalSinkUnavailable: + variantValue.destroy() + case BindingLocalDiagnosticErrorAlreadyShutdown: + variantValue.destroy() + case BindingLocalDiagnosticErrorInvalidDuration: + variantValue.destroy() + case BindingLocalDiagnosticErrorInvalidCaptureId: + variantValue.destroy() + case BindingLocalDiagnosticErrorInvalidDeadline: + variantValue.destroy() + case BindingLocalDiagnosticErrorInvalidHostSource: + variantValue.destroy() + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerBindingLocalDiagnosticError.Destroy", value)) + } +} + +type BindingLocalDiagnosticSource uint + +const ( + BindingLocalDiagnosticSourceRuntime BindingLocalDiagnosticSource = 1 + BindingLocalDiagnosticSourceConnections BindingLocalDiagnosticSource = 2 + BindingLocalDiagnosticSourceAddressStorage BindingLocalDiagnosticSource = 3 + BindingLocalDiagnosticSourceDnsDiscovery BindingLocalDiagnosticSource = 4 + BindingLocalDiagnosticSourceMdnsDiscovery BindingLocalDiagnosticSource = 5 + BindingLocalDiagnosticSourcePkarrDiscovery BindingLocalDiagnosticSource = 6 + BindingLocalDiagnosticSourceConnectionPaths BindingLocalDiagnosticSource = 7 + BindingLocalDiagnosticSourceRelayRecovery BindingLocalDiagnosticSource = 8 + BindingLocalDiagnosticSourceMembershipUpdates BindingLocalDiagnosticSource = 9 + BindingLocalDiagnosticSourceSessions BindingLocalDiagnosticSource = 10 + BindingLocalDiagnosticSourceHostApplication BindingLocalDiagnosticSource = 11 + BindingLocalDiagnosticSourceHostShareExtension BindingLocalDiagnosticSource = 12 + BindingLocalDiagnosticSourceHostKeyboardExtension BindingLocalDiagnosticSource = 13 + BindingLocalDiagnosticSourceHostBackgroundService BindingLocalDiagnosticSource = 14 +) + +type FfiConverterBindingLocalDiagnosticSource struct{} + +var FfiConverterBindingLocalDiagnosticSourceINSTANCE = FfiConverterBindingLocalDiagnosticSource{} + +func (c FfiConverterBindingLocalDiagnosticSource) Lift(rb RustBufferI) BindingLocalDiagnosticSource { + return LiftFromRustBuffer[BindingLocalDiagnosticSource](c, rb) +} + +func (c FfiConverterBindingLocalDiagnosticSource) Lower(value BindingLocalDiagnosticSource) C.RustBuffer { + return LowerIntoRustBuffer[BindingLocalDiagnosticSource](c, value) +} + +func (c FfiConverterBindingLocalDiagnosticSource) LowerExternal(value BindingLocalDiagnosticSource) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingLocalDiagnosticSource](c, value)) +} +func (FfiConverterBindingLocalDiagnosticSource) Read(reader io.Reader) BindingLocalDiagnosticSource { + id := readInt32(reader) + return BindingLocalDiagnosticSource(id) +} + +func (FfiConverterBindingLocalDiagnosticSource) Write(writer io.Writer, value BindingLocalDiagnosticSource) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingLocalDiagnosticSource struct{} + +func (_ FfiDestroyerBindingLocalDiagnosticSource) Destroy(value BindingLocalDiagnosticSource) { +} + +// 远端导出器构建失败的阶段;只有固定分类,不含 endpoint 或错误正文。 +type BindingObservabilityRemoteSetupFailure uint + +const ( + BindingObservabilityRemoteSetupFailureHttpClient BindingObservabilityRemoteSetupFailure = 1 + BindingObservabilityRemoteSetupFailureTraceExporter BindingObservabilityRemoteSetupFailure = 2 + BindingObservabilityRemoteSetupFailureLogExporter BindingObservabilityRemoteSetupFailure = 3 +) + +type FfiConverterBindingObservabilityRemoteSetupFailure struct{} + +var FfiConverterBindingObservabilityRemoteSetupFailureINSTANCE = FfiConverterBindingObservabilityRemoteSetupFailure{} + +func (c FfiConverterBindingObservabilityRemoteSetupFailure) Lift(rb RustBufferI) BindingObservabilityRemoteSetupFailure { + return LiftFromRustBuffer[BindingObservabilityRemoteSetupFailure](c, rb) +} + +func (c FfiConverterBindingObservabilityRemoteSetupFailure) Lower(value BindingObservabilityRemoteSetupFailure) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilityRemoteSetupFailure](c, value) +} + +func (c FfiConverterBindingObservabilityRemoteSetupFailure) LowerExternal(value BindingObservabilityRemoteSetupFailure) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilityRemoteSetupFailure](c, value)) +} +func (FfiConverterBindingObservabilityRemoteSetupFailure) Read(reader io.Reader) BindingObservabilityRemoteSetupFailure { + id := readInt32(reader) + return BindingObservabilityRemoteSetupFailure(id) +} + +func (FfiConverterBindingObservabilityRemoteSetupFailure) Write(writer io.Writer, value BindingObservabilityRemoteSetupFailure) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingObservabilityRemoteSetupFailure struct{} + +func (_ FfiDestroyerBindingObservabilityRemoteSetupFailure) Destroy(value BindingObservabilityRemoteSetupFailure) { +} + +type BindingObservabilitySetupStatus uint + +const ( + BindingObservabilitySetupStatusDisabled BindingObservabilitySetupStatus = 1 + BindingObservabilitySetupStatusReady BindingObservabilitySetupStatus = 2 + BindingObservabilitySetupStatusUnavailable BindingObservabilitySetupStatus = 3 +) + +type FfiConverterBindingObservabilitySetupStatus struct{} + +var FfiConverterBindingObservabilitySetupStatusINSTANCE = FfiConverterBindingObservabilitySetupStatus{} + +func (c FfiConverterBindingObservabilitySetupStatus) Lift(rb RustBufferI) BindingObservabilitySetupStatus { + return LiftFromRustBuffer[BindingObservabilitySetupStatus](c, rb) +} + +func (c FfiConverterBindingObservabilitySetupStatus) Lower(value BindingObservabilitySetupStatus) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilitySetupStatus](c, value) +} + +func (c FfiConverterBindingObservabilitySetupStatus) LowerExternal(value BindingObservabilitySetupStatus) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilitySetupStatus](c, value)) +} +func (FfiConverterBindingObservabilitySetupStatus) Read(reader io.Reader) BindingObservabilitySetupStatus { + id := readInt32(reader) + return BindingObservabilitySetupStatus(id) +} + +func (FfiConverterBindingObservabilitySetupStatus) Write(writer io.Writer, value BindingObservabilitySetupStatus) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingObservabilitySetupStatus struct{} + +func (_ FfiDestroyerBindingObservabilitySetupStatus) Destroy(value BindingObservabilitySetupStatus) { +} + +type BindingObservabilitySignalResult uint + +const ( + BindingObservabilitySignalResultCompleted BindingObservabilitySignalResult = 1 + BindingObservabilitySignalResultFailed BindingObservabilitySignalResult = 2 + BindingObservabilitySignalResultTimedOut BindingObservabilitySignalResult = 3 + BindingObservabilitySignalResultAlreadyShutdown BindingObservabilitySignalResult = 4 +) + +type FfiConverterBindingObservabilitySignalResult struct{} + +var FfiConverterBindingObservabilitySignalResultINSTANCE = FfiConverterBindingObservabilitySignalResult{} + +func (c FfiConverterBindingObservabilitySignalResult) Lift(rb RustBufferI) BindingObservabilitySignalResult { + return LiftFromRustBuffer[BindingObservabilitySignalResult](c, rb) +} + +func (c FfiConverterBindingObservabilitySignalResult) Lower(value BindingObservabilitySignalResult) C.RustBuffer { + return LowerIntoRustBuffer[BindingObservabilitySignalResult](c, value) +} + +func (c FfiConverterBindingObservabilitySignalResult) LowerExternal(value BindingObservabilitySignalResult) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingObservabilitySignalResult](c, value)) +} +func (FfiConverterBindingObservabilitySignalResult) Read(reader io.Reader) BindingObservabilitySignalResult { + id := readInt32(reader) + return BindingObservabilitySignalResult(id) +} + +func (FfiConverterBindingObservabilitySignalResult) Write(writer io.Writer, value BindingObservabilitySignalResult) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingObservabilitySignalResult struct{} + +func (_ FfiDestroyerBindingObservabilitySignalResult) Destroy(value BindingObservabilitySignalResult) { +} + +type BindingOperationTerminal uint + +const ( + BindingOperationTerminalSucceeded BindingOperationTerminal = 1 + BindingOperationTerminalFailed BindingOperationTerminal = 2 + BindingOperationTerminalCancelled BindingOperationTerminal = 3 +) + +type FfiConverterBindingOperationTerminal struct{} + +var FfiConverterBindingOperationTerminalINSTANCE = FfiConverterBindingOperationTerminal{} + +func (c FfiConverterBindingOperationTerminal) Lift(rb RustBufferI) BindingOperationTerminal { + return LiftFromRustBuffer[BindingOperationTerminal](c, rb) +} + +func (c FfiConverterBindingOperationTerminal) Lower(value BindingOperationTerminal) C.RustBuffer { + return LowerIntoRustBuffer[BindingOperationTerminal](c, value) +} + +func (c FfiConverterBindingOperationTerminal) LowerExternal(value BindingOperationTerminal) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingOperationTerminal](c, value)) +} +func (FfiConverterBindingOperationTerminal) Read(reader io.Reader) BindingOperationTerminal { + id := readInt32(reader) + return BindingOperationTerminal(id) +} + +func (FfiConverterBindingOperationTerminal) Write(writer io.Writer, value BindingOperationTerminal) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingOperationTerminal struct{} + +func (_ FfiDestroyerBindingOperationTerminal) Destroy(value BindingOperationTerminal) { +} + +type BindingRePairingScope uint + +const ( + BindingRePairingScopeAllDevices BindingRePairingScope = 1 +) + +type FfiConverterBindingRePairingScope struct{} + +var FfiConverterBindingRePairingScopeINSTANCE = FfiConverterBindingRePairingScope{} + +func (c FfiConverterBindingRePairingScope) Lift(rb RustBufferI) BindingRePairingScope { + return LiftFromRustBuffer[BindingRePairingScope](c, rb) +} + +func (c FfiConverterBindingRePairingScope) Lower(value BindingRePairingScope) C.RustBuffer { + return LowerIntoRustBuffer[BindingRePairingScope](c, value) +} + +func (c FfiConverterBindingRePairingScope) LowerExternal(value BindingRePairingScope) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingRePairingScope](c, value)) +} +func (FfiConverterBindingRePairingScope) Read(reader io.Reader) BindingRePairingScope { + id := readInt32(reader) + return BindingRePairingScope(id) +} + +func (FfiConverterBindingRePairingScope) Write(writer io.Writer, value BindingRePairingScope) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingRePairingScope struct{} + +func (_ FfiDestroyerBindingRePairingScope) Destroy(value BindingRePairingScope) { +} + +type BindingRefreshReason uint + +const ( + BindingRefreshReasonConsumerLagged BindingRefreshReason = 1 + BindingRefreshReasonStateInvalidated BindingRefreshReason = 2 +) + +type FfiConverterBindingRefreshReason struct{} + +var FfiConverterBindingRefreshReasonINSTANCE = FfiConverterBindingRefreshReason{} + +func (c FfiConverterBindingRefreshReason) Lift(rb RustBufferI) BindingRefreshReason { + return LiftFromRustBuffer[BindingRefreshReason](c, rb) +} + +func (c FfiConverterBindingRefreshReason) Lower(value BindingRefreshReason) C.RustBuffer { + return LowerIntoRustBuffer[BindingRefreshReason](c, value) +} + +func (c FfiConverterBindingRefreshReason) LowerExternal(value BindingRefreshReason) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingRefreshReason](c, value)) +} +func (FfiConverterBindingRefreshReason) Read(reader io.Reader) BindingRefreshReason { + id := readInt32(reader) + return BindingRefreshReason(id) +} + +func (FfiConverterBindingRefreshReason) Write(writer io.Writer, value BindingRefreshReason) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingRefreshReason struct{} + +func (_ FfiDestroyerBindingRefreshReason) Destroy(value BindingRefreshReason) { +} + +type BindingSourceCapability uint + +const ( + BindingSourceCapabilitySupported BindingSourceCapability = 1 + BindingSourceCapabilityPartial BindingSourceCapability = 2 + BindingSourceCapabilityUnsupported BindingSourceCapability = 3 + BindingSourceCapabilityUnknown BindingSourceCapability = 4 +) + +type FfiConverterBindingSourceCapability struct{} + +var FfiConverterBindingSourceCapabilityINSTANCE = FfiConverterBindingSourceCapability{} + +func (c FfiConverterBindingSourceCapability) Lift(rb RustBufferI) BindingSourceCapability { + return LiftFromRustBuffer[BindingSourceCapability](c, rb) +} + +func (c FfiConverterBindingSourceCapability) Lower(value BindingSourceCapability) C.RustBuffer { + return LowerIntoRustBuffer[BindingSourceCapability](c, value) +} + +func (c FfiConverterBindingSourceCapability) LowerExternal(value BindingSourceCapability) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingSourceCapability](c, value)) +} +func (FfiConverterBindingSourceCapability) Read(reader io.Reader) BindingSourceCapability { + id := readInt32(reader) + return BindingSourceCapability(id) +} + +func (FfiConverterBindingSourceCapability) Write(writer io.Writer, value BindingSourceCapability) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingSourceCapability struct{} + +func (_ FfiDestroyerBindingSourceCapability) Destroy(value BindingSourceCapability) { +} + +type BindingSourceCollection uint + +const ( + BindingSourceCollectionEnabled BindingSourceCollection = 1 + BindingSourceCollectionDisabled BindingSourceCollection = 2 + BindingSourceCollectionUnavailable BindingSourceCollection = 3 + BindingSourceCollectionNotRegistered BindingSourceCollection = 4 +) + +type FfiConverterBindingSourceCollection struct{} + +var FfiConverterBindingSourceCollectionINSTANCE = FfiConverterBindingSourceCollection{} + +func (c FfiConverterBindingSourceCollection) Lift(rb RustBufferI) BindingSourceCollection { + return LiftFromRustBuffer[BindingSourceCollection](c, rb) +} + +func (c FfiConverterBindingSourceCollection) Lower(value BindingSourceCollection) C.RustBuffer { + return LowerIntoRustBuffer[BindingSourceCollection](c, value) +} + +func (c FfiConverterBindingSourceCollection) LowerExternal(value BindingSourceCollection) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingSourceCollection](c, value)) +} +func (FfiConverterBindingSourceCollection) Read(reader io.Reader) BindingSourceCollection { + id := readInt32(reader) + return BindingSourceCollection(id) +} + +func (FfiConverterBindingSourceCollection) Write(writer io.Writer, value BindingSourceCollection) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingSourceCollection struct{} + +func (_ FfiDestroyerBindingSourceCollection) Destroy(value BindingSourceCollection) { +} + +type BindingStopCaptureResult uint + +const ( + BindingStopCaptureResultStopped BindingStopCaptureResult = 1 + BindingStopCaptureResultAlreadyStopped BindingStopCaptureResult = 2 + BindingStopCaptureResultDifferentCapture BindingStopCaptureResult = 3 +) + +type FfiConverterBindingStopCaptureResult struct{} + +var FfiConverterBindingStopCaptureResultINSTANCE = FfiConverterBindingStopCaptureResult{} + +func (c FfiConverterBindingStopCaptureResult) Lift(rb RustBufferI) BindingStopCaptureResult { + return LiftFromRustBuffer[BindingStopCaptureResult](c, rb) +} + +func (c FfiConverterBindingStopCaptureResult) Lower(value BindingStopCaptureResult) C.RustBuffer { + return LowerIntoRustBuffer[BindingStopCaptureResult](c, value) +} + +func (c FfiConverterBindingStopCaptureResult) LowerExternal(value BindingStopCaptureResult) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingStopCaptureResult](c, value)) +} +func (FfiConverterBindingStopCaptureResult) Read(reader io.Reader) BindingStopCaptureResult { + id := readInt32(reader) + return BindingStopCaptureResult(id) +} + +func (FfiConverterBindingStopCaptureResult) Write(writer io.Writer, value BindingStopCaptureResult) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingStopCaptureResult struct{} + +func (_ FfiDestroyerBindingStopCaptureResult) Destroy(value BindingStopCaptureResult) { +} + +type BindingTransferDirection uint + +const ( + BindingTransferDirectionSending BindingTransferDirection = 1 + BindingTransferDirectionReceiving BindingTransferDirection = 2 +) + +type FfiConverterBindingTransferDirection struct{} + +var FfiConverterBindingTransferDirectionINSTANCE = FfiConverterBindingTransferDirection{} + +func (c FfiConverterBindingTransferDirection) Lift(rb RustBufferI) BindingTransferDirection { + return LiftFromRustBuffer[BindingTransferDirection](c, rb) +} + +func (c FfiConverterBindingTransferDirection) Lower(value BindingTransferDirection) C.RustBuffer { + return LowerIntoRustBuffer[BindingTransferDirection](c, value) +} + +func (c FfiConverterBindingTransferDirection) LowerExternal(value BindingTransferDirection) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[BindingTransferDirection](c, value)) +} +func (FfiConverterBindingTransferDirection) Read(reader io.Reader) BindingTransferDirection { + id := readInt32(reader) + return BindingTransferDirection(id) +} + +func (FfiConverterBindingTransferDirection) Write(writer io.Writer, value BindingTransferDirection) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerBindingTransferDirection struct{} + +func (_ FfiDestroyerBindingTransferDirection) Destroy(value BindingTransferDirection) { +} + +type ConnectivityOpportunity uint + +const ( + ConnectivityOpportunityForeground ConnectivityOpportunity = 1 + ConnectivityOpportunitySystemWake ConnectivityOpportunity = 2 + ConnectivityOpportunityNetworkChanged ConnectivityOpportunity = 3 +) + +type FfiConverterConnectivityOpportunity struct{} + +var FfiConverterConnectivityOpportunityINSTANCE = FfiConverterConnectivityOpportunity{} + +func (c FfiConverterConnectivityOpportunity) Lift(rb RustBufferI) ConnectivityOpportunity { + return LiftFromRustBuffer[ConnectivityOpportunity](c, rb) +} + +func (c FfiConverterConnectivityOpportunity) Lower(value ConnectivityOpportunity) C.RustBuffer { + return LowerIntoRustBuffer[ConnectivityOpportunity](c, value) +} + +func (c FfiConverterConnectivityOpportunity) LowerExternal(value ConnectivityOpportunity) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[ConnectivityOpportunity](c, value)) +} +func (FfiConverterConnectivityOpportunity) Read(reader io.Reader) ConnectivityOpportunity { + id := readInt32(reader) + return ConnectivityOpportunity(id) +} + +func (FfiConverterConnectivityOpportunity) Write(writer io.Writer, value ConnectivityOpportunity) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerConnectivityOpportunity struct{} + +func (_ FfiDestroyerConnectivityOpportunity) Destroy(value ConnectivityOpportunity) { +} + +type CustomRelayMutationRejection uint + +const ( + CustomRelayMutationRejectionInvalidUrl CustomRelayMutationRejection = 1 + CustomRelayMutationRejectionDuplicate CustomRelayMutationRejection = 2 + CustomRelayMutationRejectionNotFound CustomRelayMutationRejection = 3 +) + +type FfiConverterCustomRelayMutationRejection struct{} + +var FfiConverterCustomRelayMutationRejectionINSTANCE = FfiConverterCustomRelayMutationRejection{} + +func (c FfiConverterCustomRelayMutationRejection) Lift(rb RustBufferI) CustomRelayMutationRejection { + return LiftFromRustBuffer[CustomRelayMutationRejection](c, rb) +} + +func (c FfiConverterCustomRelayMutationRejection) Lower(value CustomRelayMutationRejection) C.RustBuffer { + return LowerIntoRustBuffer[CustomRelayMutationRejection](c, value) +} + +func (c FfiConverterCustomRelayMutationRejection) LowerExternal(value CustomRelayMutationRejection) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[CustomRelayMutationRejection](c, value)) +} +func (FfiConverterCustomRelayMutationRejection) Read(reader io.Reader) CustomRelayMutationRejection { + id := readInt32(reader) + return CustomRelayMutationRejection(id) +} + +func (FfiConverterCustomRelayMutationRejection) Write(writer io.Writer, value CustomRelayMutationRejection) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerCustomRelayMutationRejection struct{} + +func (_ FfiDestroyerCustomRelayMutationRejection) Destroy(value CustomRelayMutationRejection) { +} + +type DeviceTrustChoice uint + +const ( + DeviceTrustChoiceApplyChange DeviceTrustChoice = 1 + DeviceTrustChoiceKeepCurrentDeviceGroup DeviceTrustChoice = 2 +) + +type FfiConverterDeviceTrustChoice struct{} + +var FfiConverterDeviceTrustChoiceINSTANCE = FfiConverterDeviceTrustChoice{} + +func (c FfiConverterDeviceTrustChoice) Lift(rb RustBufferI) DeviceTrustChoice { + return LiftFromRustBuffer[DeviceTrustChoice](c, rb) +} + +func (c FfiConverterDeviceTrustChoice) Lower(value DeviceTrustChoice) C.RustBuffer { + return LowerIntoRustBuffer[DeviceTrustChoice](c, value) +} + +func (c FfiConverterDeviceTrustChoice) LowerExternal(value DeviceTrustChoice) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[DeviceTrustChoice](c, value)) +} +func (FfiConverterDeviceTrustChoice) Read(reader io.Reader) DeviceTrustChoice { + id := readInt32(reader) + return DeviceTrustChoice(id) +} + +func (FfiConverterDeviceTrustChoice) Write(writer io.Writer, value DeviceTrustChoice) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerDeviceTrustChoice struct{} + +func (_ FfiDestroyerDeviceTrustChoice) Destroy(value DeviceTrustChoice) { +} + +type EntryNotResendableReason uint + +const ( + EntryNotResendableReasonRemoteOrigin EntryNotResendableReason = 1 + EntryNotResendableReasonPayloadLost EntryNotResendableReason = 2 +) + +type FfiConverterEntryNotResendableReason struct{} + +var FfiConverterEntryNotResendableReasonINSTANCE = FfiConverterEntryNotResendableReason{} + +func (c FfiConverterEntryNotResendableReason) Lift(rb RustBufferI) EntryNotResendableReason { + return LiftFromRustBuffer[EntryNotResendableReason](c, rb) +} + +func (c FfiConverterEntryNotResendableReason) Lower(value EntryNotResendableReason) C.RustBuffer { + return LowerIntoRustBuffer[EntryNotResendableReason](c, value) +} + +func (c FfiConverterEntryNotResendableReason) LowerExternal(value EntryNotResendableReason) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[EntryNotResendableReason](c, value)) +} +func (FfiConverterEntryNotResendableReason) Read(reader io.Reader) EntryNotResendableReason { + id := readInt32(reader) + return EntryNotResendableReason(id) +} + +func (FfiConverterEntryNotResendableReason) Write(writer io.Writer, value EntryNotResendableReason) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerEntryNotResendableReason struct{} + +func (_ FfiDestroyerEntryNotResendableReason) Destroy(value EntryNotResendableReason) { +} + +type HostBindingError struct { + err error +} + +// Convenience method to turn *HostBindingError into error +// Avoiding treating nil pointer as non nil error interface +func (err *HostBindingError) AsError() error { + if err == nil { + return nil + } else { + return err + } +} + +func (err HostBindingError) Error() string { + return fmt.Sprintf("HostBindingError: %s", err.err.Error()) +} + +func (err HostBindingError) Unwrap() error { + return err.err +} + +// Err* are used for checking error type with `errors.Is` +var ErrHostBindingErrorUnavailable = fmt.Errorf("HostBindingErrorUnavailable") +var ErrHostBindingErrorPermissionDenied = fmt.Errorf("HostBindingErrorPermissionDenied") +var ErrHostBindingErrorInvalidHandle = fmt.Errorf("HostBindingErrorInvalidHandle") +var ErrHostBindingErrorIo = fmt.Errorf("HostBindingErrorIo") + +// Variant structs +type HostBindingErrorUnavailable struct { +} + +func NewHostBindingErrorUnavailable() *HostBindingError { + return &HostBindingError{err: &HostBindingErrorUnavailable{}} +} + +func (e HostBindingErrorUnavailable) destroy() { +} + +func (err HostBindingErrorUnavailable) Error() string { + return fmt.Sprint("Unavailable") +} + +func (self HostBindingErrorUnavailable) Is(target error) bool { + return target == ErrHostBindingErrorUnavailable +} + +type HostBindingErrorPermissionDenied struct { +} + +func NewHostBindingErrorPermissionDenied() *HostBindingError { + return &HostBindingError{err: &HostBindingErrorPermissionDenied{}} +} + +func (e HostBindingErrorPermissionDenied) destroy() { +} + +func (err HostBindingErrorPermissionDenied) Error() string { + return fmt.Sprint("PermissionDenied") +} + +func (self HostBindingErrorPermissionDenied) Is(target error) bool { + return target == ErrHostBindingErrorPermissionDenied +} + +type HostBindingErrorInvalidHandle struct { +} + +func NewHostBindingErrorInvalidHandle() *HostBindingError { + return &HostBindingError{err: &HostBindingErrorInvalidHandle{}} +} + +func (e HostBindingErrorInvalidHandle) destroy() { +} + +func (err HostBindingErrorInvalidHandle) Error() string { + return fmt.Sprint("InvalidHandle") +} + +func (self HostBindingErrorInvalidHandle) Is(target error) bool { + return target == ErrHostBindingErrorInvalidHandle +} + +type HostBindingErrorIo struct { +} + +func NewHostBindingErrorIo() *HostBindingError { + return &HostBindingError{err: &HostBindingErrorIo{}} +} + +func (e HostBindingErrorIo) destroy() { +} + +func (err HostBindingErrorIo) Error() string { + return fmt.Sprint("Io") +} + +func (self HostBindingErrorIo) Is(target error) bool { + return target == ErrHostBindingErrorIo +} + +type FfiConverterHostBindingError struct{} + +var FfiConverterHostBindingErrorINSTANCE = FfiConverterHostBindingError{} + +func (c FfiConverterHostBindingError) Lift(eb RustBufferI) *HostBindingError { + return LiftFromRustBuffer[*HostBindingError](c, eb) +} + +func (c FfiConverterHostBindingError) Lower(value *HostBindingError) C.RustBuffer { + return LowerIntoRustBuffer[*HostBindingError](c, value) +} + +func (c FfiConverterHostBindingError) LowerExternal(value *HostBindingError) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*HostBindingError](c, value)) +} + +func (c FfiConverterHostBindingError) Read(reader io.Reader) *HostBindingError { + errorID := readUint32(reader) + + switch errorID { + case 1: + return &HostBindingError{&HostBindingErrorUnavailable{}} + case 2: + return &HostBindingError{&HostBindingErrorPermissionDenied{}} + case 3: + return &HostBindingError{&HostBindingErrorInvalidHandle{}} + case 4: + return &HostBindingError{&HostBindingErrorIo{}} + default: + panic(fmt.Sprintf("Unknown error code %d in FfiConverterHostBindingError.Read()", errorID)) + } +} + +func (c FfiConverterHostBindingError) Write(writer io.Writer, value *HostBindingError) { + switch variantValue := value.err.(type) { + case *HostBindingErrorUnavailable: + writeInt32(writer, 1) + case *HostBindingErrorPermissionDenied: + writeInt32(writer, 2) + case *HostBindingErrorInvalidHandle: + writeInt32(writer, 3) + case *HostBindingErrorIo: + writeInt32(writer, 4) + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiConverterHostBindingError.Write", value)) + } +} + +type FfiDestroyerHostBindingError struct{} + +func (_ FfiDestroyerHostBindingError) Destroy(value *HostBindingError) { + switch variantValue := value.err.(type) { + case HostBindingErrorUnavailable: + variantValue.destroy() + case HostBindingErrorPermissionDenied: + variantValue.destroy() + case HostBindingErrorInvalidHandle: + variantValue.destroy() + case HostBindingErrorIo: + variantValue.destroy() + default: + _ = variantValue + panic(fmt.Sprintf("invalid error value `%v` in FfiDestroyerHostBindingError.Destroy", value)) + } +} + +type InvitationAvailability uint + +const ( + InvitationAvailabilityCrossNetwork InvitationAvailability = 1 + InvitationAvailabilitySameLocalNetwork InvitationAvailability = 2 +) + +type FfiConverterInvitationAvailability struct{} + +var FfiConverterInvitationAvailabilityINSTANCE = FfiConverterInvitationAvailability{} + +func (c FfiConverterInvitationAvailability) Lift(rb RustBufferI) InvitationAvailability { + return LiftFromRustBuffer[InvitationAvailability](c, rb) +} + +func (c FfiConverterInvitationAvailability) Lower(value InvitationAvailability) C.RustBuffer { + return LowerIntoRustBuffer[InvitationAvailability](c, value) +} + +func (c FfiConverterInvitationAvailability) LowerExternal(value InvitationAvailability) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[InvitationAvailability](c, value)) +} +func (FfiConverterInvitationAvailability) Read(reader io.Reader) InvitationAvailability { + id := readInt32(reader) + return InvitationAvailability(id) +} + +func (FfiConverterInvitationAvailability) Write(writer io.Writer, value InvitationAvailability) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerInvitationAvailability struct{} + +func (_ FfiDestroyerInvitationAvailability) Destroy(value InvitationAvailability) { +} + +type JoinSpaceAttentionReason uint + +const ( + JoinSpaceAttentionReasonOutcomeCannotBeProven JoinSpaceAttentionReason = 1 + JoinSpaceAttentionReasonContinuationUnavailable JoinSpaceAttentionReason = 2 +) + +type FfiConverterJoinSpaceAttentionReason struct{} + +var FfiConverterJoinSpaceAttentionReasonINSTANCE = FfiConverterJoinSpaceAttentionReason{} + +func (c FfiConverterJoinSpaceAttentionReason) Lift(rb RustBufferI) JoinSpaceAttentionReason { + return LiftFromRustBuffer[JoinSpaceAttentionReason](c, rb) +} + +func (c FfiConverterJoinSpaceAttentionReason) Lower(value JoinSpaceAttentionReason) C.RustBuffer { + return LowerIntoRustBuffer[JoinSpaceAttentionReason](c, value) +} + +func (c FfiConverterJoinSpaceAttentionReason) LowerExternal(value JoinSpaceAttentionReason) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[JoinSpaceAttentionReason](c, value)) +} +func (FfiConverterJoinSpaceAttentionReason) Read(reader io.Reader) JoinSpaceAttentionReason { + id := readInt32(reader) + return JoinSpaceAttentionReason(id) +} + +func (FfiConverterJoinSpaceAttentionReason) Write(writer io.Writer, value JoinSpaceAttentionReason) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerJoinSpaceAttentionReason struct{} + +func (_ FfiDestroyerJoinSpaceAttentionReason) Destroy(value JoinSpaceAttentionReason) { +} + +type JoinSpaceAttentionRecovery uint + +const ( + JoinSpaceAttentionRecoveryPreserveDataAndContactSupport JoinSpaceAttentionRecovery = 1 + JoinSpaceAttentionRecoveryRestartWithNewInvitation JoinSpaceAttentionRecovery = 2 +) + +type FfiConverterJoinSpaceAttentionRecovery struct{} + +var FfiConverterJoinSpaceAttentionRecoveryINSTANCE = FfiConverterJoinSpaceAttentionRecovery{} + +func (c FfiConverterJoinSpaceAttentionRecovery) Lift(rb RustBufferI) JoinSpaceAttentionRecovery { + return LiftFromRustBuffer[JoinSpaceAttentionRecovery](c, rb) +} + +func (c FfiConverterJoinSpaceAttentionRecovery) Lower(value JoinSpaceAttentionRecovery) C.RustBuffer { + return LowerIntoRustBuffer[JoinSpaceAttentionRecovery](c, value) +} + +func (c FfiConverterJoinSpaceAttentionRecovery) LowerExternal(value JoinSpaceAttentionRecovery) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[JoinSpaceAttentionRecovery](c, value)) +} +func (FfiConverterJoinSpaceAttentionRecovery) Read(reader io.Reader) JoinSpaceAttentionRecovery { + id := readInt32(reader) + return JoinSpaceAttentionRecovery(id) +} + +func (FfiConverterJoinSpaceAttentionRecovery) Write(writer io.Writer, value JoinSpaceAttentionRecovery) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerJoinSpaceAttentionRecovery struct{} + +func (_ FfiDestroyerJoinSpaceAttentionRecovery) Destroy(value JoinSpaceAttentionRecovery) { +} + +type JoinSpaceRejectionReason uint + +const ( + JoinSpaceRejectionReasonInvitationUnavailable JoinSpaceRejectionReason = 1 + JoinSpaceRejectionReasonAuthenticationRejected JoinSpaceRejectionReason = 2 + JoinSpaceRejectionReasonIdentityConflict JoinSpaceRejectionReason = 3 + JoinSpaceRejectionReasonBaseHistoryChanged JoinSpaceRejectionReason = 4 + JoinSpaceRejectionReasonJoinerHistoryAhead JoinSpaceRejectionReason = 5 + JoinSpaceRejectionReasonHistoryConflict JoinSpaceRejectionReason = 6 + JoinSpaceRejectionReasonCompletionInvalid JoinSpaceRejectionReason = 7 + JoinSpaceRejectionReasonMembershipHistoryInvalid JoinSpaceRejectionReason = 8 + JoinSpaceRejectionReasonSecurityMaterialInvalid JoinSpaceRejectionReason = 9 + JoinSpaceRejectionReasonRelationshipConflict JoinSpaceRejectionReason = 10 + JoinSpaceRejectionReasonActivationStateInvalid JoinSpaceRejectionReason = 11 + JoinSpaceRejectionReasonPeerUpgradeRequired JoinSpaceRejectionReason = 12 + JoinSpaceRejectionReasonCancelled JoinSpaceRejectionReason = 13 + JoinSpaceRejectionReasonRemovedBeforeActivation JoinSpaceRejectionReason = 14 +) + +type FfiConverterJoinSpaceRejectionReason struct{} + +var FfiConverterJoinSpaceRejectionReasonINSTANCE = FfiConverterJoinSpaceRejectionReason{} + +func (c FfiConverterJoinSpaceRejectionReason) Lift(rb RustBufferI) JoinSpaceRejectionReason { + return LiftFromRustBuffer[JoinSpaceRejectionReason](c, rb) +} + +func (c FfiConverterJoinSpaceRejectionReason) Lower(value JoinSpaceRejectionReason) C.RustBuffer { + return LowerIntoRustBuffer[JoinSpaceRejectionReason](c, value) +} + +func (c FfiConverterJoinSpaceRejectionReason) LowerExternal(value JoinSpaceRejectionReason) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[JoinSpaceRejectionReason](c, value)) +} +func (FfiConverterJoinSpaceRejectionReason) Read(reader io.Reader) JoinSpaceRejectionReason { + id := readInt32(reader) + return JoinSpaceRejectionReason(id) +} + +func (FfiConverterJoinSpaceRejectionReason) Write(writer io.Writer, value JoinSpaceRejectionReason) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerJoinSpaceRejectionReason struct{} + +func (_ FfiDestroyerJoinSpaceRejectionReason) Destroy(value JoinSpaceRejectionReason) { +} + +type JoinSpaceStatus interface { + Destroy() +} +type JoinSpaceStatusActive struct { + JoinId string + JoinedSpace JoinedSpace + PeerUpgradeRequired bool +} + +func (e JoinSpaceStatusActive) Destroy() { + FfiDestroyerString{}.Destroy(e.JoinId) + FfiDestroyerJoinedSpace{}.Destroy(e.JoinedSpace) + FfiDestroyerBool{}.Destroy(e.PeerUpgradeRequired) +} + +type JoinSpaceStatusPending struct { + JoinId string + TargetSpaceId *string + SponsorDeviceId *string + SponsorIdentityFingerprint *string + CancelRequested bool + PeerUpgradeRequired bool +} + +func (e JoinSpaceStatusPending) Destroy() { + FfiDestroyerString{}.Destroy(e.JoinId) + FfiDestroyerOptionalString{}.Destroy(e.TargetSpaceId) + FfiDestroyerOptionalString{}.Destroy(e.SponsorDeviceId) + FfiDestroyerOptionalString{}.Destroy(e.SponsorIdentityFingerprint) + FfiDestroyerBool{}.Destroy(e.CancelRequested) + FfiDestroyerBool{}.Destroy(e.PeerUpgradeRequired) +} + +type JoinSpaceStatusProcessing struct { + JoinId string + TargetSpaceId string + SponsorDeviceId string + SponsorIdentityFingerprint string + PeerUpgradeRequired bool +} + +func (e JoinSpaceStatusProcessing) Destroy() { + FfiDestroyerString{}.Destroy(e.JoinId) + FfiDestroyerString{}.Destroy(e.TargetSpaceId) + FfiDestroyerString{}.Destroy(e.SponsorDeviceId) + FfiDestroyerString{}.Destroy(e.SponsorIdentityFingerprint) + FfiDestroyerBool{}.Destroy(e.PeerUpgradeRequired) +} + +type JoinSpaceStatusNeedsAttention struct { + JoinId string + Reason JoinSpaceAttentionReason + Recovery JoinSpaceAttentionRecovery + NextRetryAtMs *int64 +} + +func (e JoinSpaceStatusNeedsAttention) Destroy() { + FfiDestroyerString{}.Destroy(e.JoinId) + FfiDestroyerJoinSpaceAttentionReason{}.Destroy(e.Reason) + FfiDestroyerJoinSpaceAttentionRecovery{}.Destroy(e.Recovery) + FfiDestroyerOptionalInt64{}.Destroy(e.NextRetryAtMs) +} + +type JoinSpaceStatusRejected struct { + JoinId string + Reason JoinSpaceRejectionReason +} + +func (e JoinSpaceStatusRejected) Destroy() { + FfiDestroyerString{}.Destroy(e.JoinId) + FfiDestroyerJoinSpaceRejectionReason{}.Destroy(e.Reason) +} + +type JoinSpaceStatusTerminated struct { + JoinId string + Reason JoinSpaceTerminationReason +} + +func (e JoinSpaceStatusTerminated) Destroy() { + FfiDestroyerString{}.Destroy(e.JoinId) + FfiDestroyerJoinSpaceTerminationReason{}.Destroy(e.Reason) +} + +type FfiConverterJoinSpaceStatus struct{} + +var FfiConverterJoinSpaceStatusINSTANCE = FfiConverterJoinSpaceStatus{} + +func (c FfiConverterJoinSpaceStatus) Lift(rb RustBufferI) JoinSpaceStatus { + return LiftFromRustBuffer[JoinSpaceStatus](c, rb) +} + +func (c FfiConverterJoinSpaceStatus) Lower(value JoinSpaceStatus) C.RustBuffer { + return LowerIntoRustBuffer[JoinSpaceStatus](c, value) +} + +func (c FfiConverterJoinSpaceStatus) LowerExternal(value JoinSpaceStatus) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[JoinSpaceStatus](c, value)) +} +func (FfiConverterJoinSpaceStatus) Read(reader io.Reader) JoinSpaceStatus { + id := readInt32(reader) + switch id { + case 1: + return JoinSpaceStatusActive{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterJoinedSpaceINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } + case 2: + return JoinSpaceStatusPending{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterOptionalStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } + case 3: + return JoinSpaceStatusProcessing{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterStringINSTANCE.Read(reader), + FfiConverterBoolINSTANCE.Read(reader), + } + case 4: + return JoinSpaceStatusNeedsAttention{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterJoinSpaceAttentionReasonINSTANCE.Read(reader), + FfiConverterJoinSpaceAttentionRecoveryINSTANCE.Read(reader), + FfiConverterOptionalInt64INSTANCE.Read(reader), + } + case 5: + return JoinSpaceStatusRejected{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterJoinSpaceRejectionReasonINSTANCE.Read(reader), + } + case 6: + return JoinSpaceStatusTerminated{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterJoinSpaceTerminationReasonINSTANCE.Read(reader), + } + default: + panic(fmt.Sprintf("invalid enum value %v in FfiConverterJoinSpaceStatus.Read()", id)) + } +} + +func (FfiConverterJoinSpaceStatus) Write(writer io.Writer, value JoinSpaceStatus) { + switch variant_value := value.(type) { + case JoinSpaceStatusActive: + writeInt32(writer, 1) + FfiConverterStringINSTANCE.Write(writer, variant_value.JoinId) + FfiConverterJoinedSpaceINSTANCE.Write(writer, variant_value.JoinedSpace) + FfiConverterBoolINSTANCE.Write(writer, variant_value.PeerUpgradeRequired) + case JoinSpaceStatusPending: + writeInt32(writer, 2) + FfiConverterStringINSTANCE.Write(writer, variant_value.JoinId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.TargetSpaceId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.SponsorDeviceId) + FfiConverterOptionalStringINSTANCE.Write(writer, variant_value.SponsorIdentityFingerprint) + FfiConverterBoolINSTANCE.Write(writer, variant_value.CancelRequested) + FfiConverterBoolINSTANCE.Write(writer, variant_value.PeerUpgradeRequired) + case JoinSpaceStatusProcessing: + writeInt32(writer, 3) + FfiConverterStringINSTANCE.Write(writer, variant_value.JoinId) + FfiConverterStringINSTANCE.Write(writer, variant_value.TargetSpaceId) + FfiConverterStringINSTANCE.Write(writer, variant_value.SponsorDeviceId) + FfiConverterStringINSTANCE.Write(writer, variant_value.SponsorIdentityFingerprint) + FfiConverterBoolINSTANCE.Write(writer, variant_value.PeerUpgradeRequired) + case JoinSpaceStatusNeedsAttention: + writeInt32(writer, 4) + FfiConverterStringINSTANCE.Write(writer, variant_value.JoinId) + FfiConverterJoinSpaceAttentionReasonINSTANCE.Write(writer, variant_value.Reason) + FfiConverterJoinSpaceAttentionRecoveryINSTANCE.Write(writer, variant_value.Recovery) + FfiConverterOptionalInt64INSTANCE.Write(writer, variant_value.NextRetryAtMs) + case JoinSpaceStatusRejected: + writeInt32(writer, 5) + FfiConverterStringINSTANCE.Write(writer, variant_value.JoinId) + FfiConverterJoinSpaceRejectionReasonINSTANCE.Write(writer, variant_value.Reason) + case JoinSpaceStatusTerminated: + writeInt32(writer, 6) + FfiConverterStringINSTANCE.Write(writer, variant_value.JoinId) + FfiConverterJoinSpaceTerminationReasonINSTANCE.Write(writer, variant_value.Reason) + default: + _ = variant_value + panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterJoinSpaceStatus.Write", value)) + } +} + +type FfiDestroyerJoinSpaceStatus struct{} + +func (_ FfiDestroyerJoinSpaceStatus) Destroy(value JoinSpaceStatus) { + value.Destroy() +} + +type JoinSpaceTerminationReason uint + +const ( + JoinSpaceTerminationReasonCancelled JoinSpaceTerminationReason = 1 + JoinSpaceTerminationReasonExpired JoinSpaceTerminationReason = 2 + JoinSpaceTerminationReasonSuperseded JoinSpaceTerminationReason = 3 +) + +type FfiConverterJoinSpaceTerminationReason struct{} + +var FfiConverterJoinSpaceTerminationReasonINSTANCE = FfiConverterJoinSpaceTerminationReason{} + +func (c FfiConverterJoinSpaceTerminationReason) Lift(rb RustBufferI) JoinSpaceTerminationReason { + return LiftFromRustBuffer[JoinSpaceTerminationReason](c, rb) +} + +func (c FfiConverterJoinSpaceTerminationReason) Lower(value JoinSpaceTerminationReason) C.RustBuffer { + return LowerIntoRustBuffer[JoinSpaceTerminationReason](c, value) +} + +func (c FfiConverterJoinSpaceTerminationReason) LowerExternal(value JoinSpaceTerminationReason) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[JoinSpaceTerminationReason](c, value)) +} +func (FfiConverterJoinSpaceTerminationReason) Read(reader io.Reader) JoinSpaceTerminationReason { + id := readInt32(reader) + return JoinSpaceTerminationReason(id) +} + +func (FfiConverterJoinSpaceTerminationReason) Write(writer io.Writer, value JoinSpaceTerminationReason) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerJoinSpaceTerminationReason struct{} + +func (_ FfiDestroyerJoinSpaceTerminationReason) Destroy(value JoinSpaceTerminationReason) { +} + +type MembershipRemovalDecision uint + +const ( + MembershipRemovalDecisionAccept MembershipRemovalDecision = 1 + MembershipRemovalDecisionReject MembershipRemovalDecision = 2 +) + +type FfiConverterMembershipRemovalDecision struct{} + +var FfiConverterMembershipRemovalDecisionINSTANCE = FfiConverterMembershipRemovalDecision{} + +func (c FfiConverterMembershipRemovalDecision) Lift(rb RustBufferI) MembershipRemovalDecision { + return LiftFromRustBuffer[MembershipRemovalDecision](c, rb) +} + +func (c FfiConverterMembershipRemovalDecision) Lower(value MembershipRemovalDecision) C.RustBuffer { + return LowerIntoRustBuffer[MembershipRemovalDecision](c, value) +} + +func (c FfiConverterMembershipRemovalDecision) LowerExternal(value MembershipRemovalDecision) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[MembershipRemovalDecision](c, value)) +} +func (FfiConverterMembershipRemovalDecision) Read(reader io.Reader) MembershipRemovalDecision { + id := readInt32(reader) + return MembershipRemovalDecision(id) +} + +func (FfiConverterMembershipRemovalDecision) Write(writer io.Writer, value MembershipRemovalDecision) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerMembershipRemovalDecision struct{} + +func (_ FfiDestroyerMembershipRemovalDecision) Destroy(value MembershipRemovalDecision) { +} + +type RelayEntrySource uint + +const ( + RelayEntrySourceBuiltIn RelayEntrySource = 1 + RelayEntrySourceCustom RelayEntrySource = 2 +) + +type FfiConverterRelayEntrySource struct{} + +var FfiConverterRelayEntrySourceINSTANCE = FfiConverterRelayEntrySource{} + +func (c FfiConverterRelayEntrySource) Lift(rb RustBufferI) RelayEntrySource { + return LiftFromRustBuffer[RelayEntrySource](c, rb) +} + +func (c FfiConverterRelayEntrySource) Lower(value RelayEntrySource) C.RustBuffer { + return LowerIntoRustBuffer[RelayEntrySource](c, value) +} + +func (c FfiConverterRelayEntrySource) LowerExternal(value RelayEntrySource) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[RelayEntrySource](c, value)) +} +func (FfiConverterRelayEntrySource) Read(reader io.Reader) RelayEntrySource { + id := readInt32(reader) + return RelayEntrySource(id) +} + +func (FfiConverterRelayEntrySource) Write(writer io.Writer, value RelayEntrySource) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerRelayEntrySource struct{} + +func (_ FfiDestroyerRelayEntrySource) Destroy(value RelayEntrySource) { +} + +// Relay 路由方式。优先级:`Disabled`(仅局域网)> `Custom`(替换内置列表)> `BuiltIn`。 +type RelayRoutingMode uint + +const ( + RelayRoutingModeBuiltIn RelayRoutingMode = 1 + RelayRoutingModeCustom RelayRoutingMode = 2 + RelayRoutingModeDisabled RelayRoutingMode = 3 +) + +type FfiConverterRelayRoutingMode struct{} + +var FfiConverterRelayRoutingModeINSTANCE = FfiConverterRelayRoutingMode{} + +func (c FfiConverterRelayRoutingMode) Lift(rb RustBufferI) RelayRoutingMode { + return LiftFromRustBuffer[RelayRoutingMode](c, rb) +} + +func (c FfiConverterRelayRoutingMode) Lower(value RelayRoutingMode) C.RustBuffer { + return LowerIntoRustBuffer[RelayRoutingMode](c, value) +} + +func (c FfiConverterRelayRoutingMode) LowerExternal(value RelayRoutingMode) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[RelayRoutingMode](c, value)) +} +func (FfiConverterRelayRoutingMode) Read(reader io.Reader) RelayRoutingMode { + id := readInt32(reader) + return RelayRoutingMode(id) +} + +func (FfiConverterRelayRoutingMode) Write(writer io.Writer, value RelayRoutingMode) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerRelayRoutingMode struct{} + +func (_ FfiDestroyerRelayRoutingMode) Destroy(value RelayRoutingMode) { +} + +type ResendEntryOutcome interface { + Destroy() +} +type ResendEntryOutcomeCompleted struct { + Accepted uint64 + Duplicate uint64 + Offline uint64 + Errored uint64 + Pending uint64 +} + +func (e ResendEntryOutcomeCompleted) Destroy() { + FfiDestroyerUint64{}.Destroy(e.Accepted) + FfiDestroyerUint64{}.Destroy(e.Duplicate) + FfiDestroyerUint64{}.Destroy(e.Offline) + FfiDestroyerUint64{}.Destroy(e.Errored) + FfiDestroyerUint64{}.Destroy(e.Pending) +} + +type ResendEntryOutcomeSynchronizationDisabled struct { +} + +func (e ResendEntryOutcomeSynchronizationDisabled) Destroy() { +} + +type ResendEntryOutcomeEntryNotFound struct { + EntryId string +} + +func (e ResendEntryOutcomeEntryNotFound) Destroy() { + FfiDestroyerString{}.Destroy(e.EntryId) +} + +type ResendEntryOutcomeEntryNotResendable struct { + EntryId string + Reason EntryNotResendableReason +} + +func (e ResendEntryOutcomeEntryNotResendable) Destroy() { + FfiDestroyerString{}.Destroy(e.EntryId) + FfiDestroyerEntryNotResendableReason{}.Destroy(e.Reason) +} + +type ResendEntryOutcomeTargetNotTrusted struct { + DeviceId string +} + +func (e ResendEntryOutcomeTargetNotTrusted) Destroy() { + FfiDestroyerString{}.Destroy(e.DeviceId) +} + +type ResendEntryOutcomeNoEligibleTargets struct { +} + +func (e ResendEntryOutcomeNoEligibleTargets) Destroy() { +} + +type FfiConverterResendEntryOutcome struct{} + +var FfiConverterResendEntryOutcomeINSTANCE = FfiConverterResendEntryOutcome{} + +func (c FfiConverterResendEntryOutcome) Lift(rb RustBufferI) ResendEntryOutcome { + return LiftFromRustBuffer[ResendEntryOutcome](c, rb) +} + +func (c FfiConverterResendEntryOutcome) Lower(value ResendEntryOutcome) C.RustBuffer { + return LowerIntoRustBuffer[ResendEntryOutcome](c, value) +} + +func (c FfiConverterResendEntryOutcome) LowerExternal(value ResendEntryOutcome) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[ResendEntryOutcome](c, value)) +} +func (FfiConverterResendEntryOutcome) Read(reader io.Reader) ResendEntryOutcome { + id := readInt32(reader) + switch id { + case 1: + return ResendEntryOutcomeCompleted{ + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + FfiConverterUint64INSTANCE.Read(reader), + } + case 2: + return ResendEntryOutcomeSynchronizationDisabled{} + case 3: + return ResendEntryOutcomeEntryNotFound{ + FfiConverterStringINSTANCE.Read(reader), + } + case 4: + return ResendEntryOutcomeEntryNotResendable{ + FfiConverterStringINSTANCE.Read(reader), + FfiConverterEntryNotResendableReasonINSTANCE.Read(reader), + } + case 5: + return ResendEntryOutcomeTargetNotTrusted{ + FfiConverterStringINSTANCE.Read(reader), + } + case 6: + return ResendEntryOutcomeNoEligibleTargets{} + default: + panic(fmt.Sprintf("invalid enum value %v in FfiConverterResendEntryOutcome.Read()", id)) + } +} + +func (FfiConverterResendEntryOutcome) Write(writer io.Writer, value ResendEntryOutcome) { + switch variant_value := value.(type) { + case ResendEntryOutcomeCompleted: + writeInt32(writer, 1) + FfiConverterUint64INSTANCE.Write(writer, variant_value.Accepted) + FfiConverterUint64INSTANCE.Write(writer, variant_value.Duplicate) + FfiConverterUint64INSTANCE.Write(writer, variant_value.Offline) + FfiConverterUint64INSTANCE.Write(writer, variant_value.Errored) + FfiConverterUint64INSTANCE.Write(writer, variant_value.Pending) + case ResendEntryOutcomeSynchronizationDisabled: + writeInt32(writer, 2) + case ResendEntryOutcomeEntryNotFound: + writeInt32(writer, 3) + FfiConverterStringINSTANCE.Write(writer, variant_value.EntryId) + case ResendEntryOutcomeEntryNotResendable: + writeInt32(writer, 4) + FfiConverterStringINSTANCE.Write(writer, variant_value.EntryId) + FfiConverterEntryNotResendableReasonINSTANCE.Write(writer, variant_value.Reason) + case ResendEntryOutcomeTargetNotTrusted: + writeInt32(writer, 5) + FfiConverterStringINSTANCE.Write(writer, variant_value.DeviceId) + case ResendEntryOutcomeNoEligibleTargets: + writeInt32(writer, 6) + default: + _ = variant_value + panic(fmt.Sprintf("invalid enum value `%v` in FfiConverterResendEntryOutcome.Write", value)) + } +} + +type FfiDestroyerResendEntryOutcome struct{} + +func (_ FfiDestroyerResendEntryOutcome) Destroy(value ResendEntryOutcome) { + value.Destroy() +} + +type WorkspaceConvergenceFailureCategory uint + +const ( + WorkspaceConvergenceFailureCategorySpaceMismatch WorkspaceConvergenceFailureCategory = 1 + WorkspaceConvergenceFailureCategoryContinuityGap WorkspaceConvergenceFailureCategory = 2 + WorkspaceConvergenceFailureCategoryIdentityMismatch WorkspaceConvergenceFailureCategory = 3 + WorkspaceConvergenceFailureCategoryDigestConflict WorkspaceConvergenceFailureCategory = 4 + WorkspaceConvergenceFailureCategoryUnauthorized WorkspaceConvergenceFailureCategory = 5 + WorkspaceConvergenceFailureCategoryVersionIncompatible WorkspaceConvergenceFailureCategory = 6 + WorkspaceConvergenceFailureCategoryNoEffectiveMembers WorkspaceConvergenceFailureCategory = 7 + WorkspaceConvergenceFailureCategoryStorage WorkspaceConvergenceFailureCategory = 8 +) + +type FfiConverterWorkspaceConvergenceFailureCategory struct{} + +var FfiConverterWorkspaceConvergenceFailureCategoryINSTANCE = FfiConverterWorkspaceConvergenceFailureCategory{} + +func (c FfiConverterWorkspaceConvergenceFailureCategory) Lift(rb RustBufferI) WorkspaceConvergenceFailureCategory { + return LiftFromRustBuffer[WorkspaceConvergenceFailureCategory](c, rb) +} + +func (c FfiConverterWorkspaceConvergenceFailureCategory) Lower(value WorkspaceConvergenceFailureCategory) C.RustBuffer { + return LowerIntoRustBuffer[WorkspaceConvergenceFailureCategory](c, value) +} + +func (c FfiConverterWorkspaceConvergenceFailureCategory) LowerExternal(value WorkspaceConvergenceFailureCategory) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[WorkspaceConvergenceFailureCategory](c, value)) +} +func (FfiConverterWorkspaceConvergenceFailureCategory) Read(reader io.Reader) WorkspaceConvergenceFailureCategory { + id := readInt32(reader) + return WorkspaceConvergenceFailureCategory(id) +} + +func (FfiConverterWorkspaceConvergenceFailureCategory) Write(writer io.Writer, value WorkspaceConvergenceFailureCategory) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerWorkspaceConvergenceFailureCategory struct{} + +func (_ FfiDestroyerWorkspaceConvergenceFailureCategory) Destroy(value WorkspaceConvergenceFailureCategory) { +} + +type WorkspaceConvergencePhase uint + +const ( + WorkspaceConvergencePhaseLocallyApplied WorkspaceConvergencePhase = 1 + WorkspaceConvergencePhaseConverging WorkspaceConvergencePhase = 2 + WorkspaceConvergencePhaseComplete WorkspaceConvergencePhase = 3 + WorkspaceConvergencePhaseRecoveryRequired WorkspaceConvergencePhase = 4 +) + +type FfiConverterWorkspaceConvergencePhase struct{} + +var FfiConverterWorkspaceConvergencePhaseINSTANCE = FfiConverterWorkspaceConvergencePhase{} + +func (c FfiConverterWorkspaceConvergencePhase) Lift(rb RustBufferI) WorkspaceConvergencePhase { + return LiftFromRustBuffer[WorkspaceConvergencePhase](c, rb) +} + +func (c FfiConverterWorkspaceConvergencePhase) Lower(value WorkspaceConvergencePhase) C.RustBuffer { + return LowerIntoRustBuffer[WorkspaceConvergencePhase](c, value) +} + +func (c FfiConverterWorkspaceConvergencePhase) LowerExternal(value WorkspaceConvergencePhase) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[WorkspaceConvergencePhase](c, value)) +} +func (FfiConverterWorkspaceConvergencePhase) Read(reader io.Reader) WorkspaceConvergencePhase { + id := readInt32(reader) + return WorkspaceConvergencePhase(id) +} + +func (FfiConverterWorkspaceConvergencePhase) Write(writer io.Writer, value WorkspaceConvergencePhase) { + writeInt32(writer, int32(value)) +} + +type FfiDestroyerWorkspaceConvergencePhase struct{} + +func (_ FfiDestroyerWorkspaceConvergencePhase) Destroy(value WorkspaceConvergencePhase) { +} + +type FfiConverterOptionalUint64 struct{} + +var FfiConverterOptionalUint64INSTANCE = FfiConverterOptionalUint64{} + +func (c FfiConverterOptionalUint64) Lift(rb RustBufferI) *uint64 { + return LiftFromRustBuffer[*uint64](c, rb) +} + +func (_ FfiConverterOptionalUint64) Read(reader io.Reader) *uint64 { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterUint64INSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalUint64) Lower(value *uint64) C.RustBuffer { + return LowerIntoRustBuffer[*uint64](c, value) +} + +func (c FfiConverterOptionalUint64) LowerExternal(value *uint64) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*uint64](c, value)) +} + +func (_ FfiConverterOptionalUint64) Write(writer io.Writer, value *uint64) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterUint64INSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalUint64 struct{} + +func (_ FfiDestroyerOptionalUint64) Destroy(value *uint64) { + if value != nil { + FfiDestroyerUint64{}.Destroy(*value) + } +} + +type FfiConverterOptionalInt64 struct{} + +var FfiConverterOptionalInt64INSTANCE = FfiConverterOptionalInt64{} + +func (c FfiConverterOptionalInt64) Lift(rb RustBufferI) *int64 { + return LiftFromRustBuffer[*int64](c, rb) +} + +func (_ FfiConverterOptionalInt64) Read(reader io.Reader) *int64 { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterInt64INSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalInt64) Lower(value *int64) C.RustBuffer { + return LowerIntoRustBuffer[*int64](c, value) +} + +func (c FfiConverterOptionalInt64) LowerExternal(value *int64) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*int64](c, value)) +} + +func (_ FfiConverterOptionalInt64) Write(writer io.Writer, value *int64) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterInt64INSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalInt64 struct{} + +func (_ FfiDestroyerOptionalInt64) Destroy(value *int64) { + if value != nil { + FfiDestroyerInt64{}.Destroy(*value) + } +} + +type FfiConverterOptionalString struct{} + +var FfiConverterOptionalStringINSTANCE = FfiConverterOptionalString{} + +func (c FfiConverterOptionalString) Lift(rb RustBufferI) *string { + return LiftFromRustBuffer[*string](c, rb) +} + +func (_ FfiConverterOptionalString) Read(reader io.Reader) *string { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterStringINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalString) Lower(value *string) C.RustBuffer { + return LowerIntoRustBuffer[*string](c, value) +} + +func (c FfiConverterOptionalString) LowerExternal(value *string) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*string](c, value)) +} + +func (_ FfiConverterOptionalString) Write(writer io.Writer, value *string) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterStringINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalString struct{} + +func (_ FfiDestroyerOptionalString) Destroy(value *string) { + if value != nil { + FfiDestroyerString{}.Destroy(*value) + } +} + +type FfiConverterOptionalBytes struct{} + +var FfiConverterOptionalBytesINSTANCE = FfiConverterOptionalBytes{} + +func (c FfiConverterOptionalBytes) Lift(rb RustBufferI) *[]byte { + return LiftFromRustBuffer[*[]byte](c, rb) +} + +func (_ FfiConverterOptionalBytes) Read(reader io.Reader) *[]byte { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterBytesINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalBytes) Lower(value *[]byte) C.RustBuffer { + return LowerIntoRustBuffer[*[]byte](c, value) +} + +func (c FfiConverterOptionalBytes) LowerExternal(value *[]byte) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*[]byte](c, value)) +} + +func (_ FfiConverterOptionalBytes) Write(writer io.Writer, value *[]byte) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterBytesINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalBytes struct{} + +func (_ FfiDestroyerOptionalBytes) Destroy(value *[]byte) { + if value != nil { + FfiDestroyerBytes{}.Destroy(*value) + } +} + +type FfiConverterOptionalActiveClipboard struct{} + +var FfiConverterOptionalActiveClipboardINSTANCE = FfiConverterOptionalActiveClipboard{} + +func (c FfiConverterOptionalActiveClipboard) Lift(rb RustBufferI) *ActiveClipboard { + return LiftFromRustBuffer[*ActiveClipboard](c, rb) +} + +func (_ FfiConverterOptionalActiveClipboard) Read(reader io.Reader) *ActiveClipboard { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterActiveClipboardINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalActiveClipboard) Lower(value *ActiveClipboard) C.RustBuffer { + return LowerIntoRustBuffer[*ActiveClipboard](c, value) +} + +func (c FfiConverterOptionalActiveClipboard) LowerExternal(value *ActiveClipboard) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*ActiveClipboard](c, value)) +} + +func (_ FfiConverterOptionalActiveClipboard) Write(writer io.Writer, value *ActiveClipboard) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterActiveClipboardINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalActiveClipboard struct{} + +func (_ FfiDestroyerOptionalActiveClipboard) Destroy(value *ActiveClipboard) { + if value != nil { + FfiDestroyerActiveClipboard{}.Destroy(*value) + } +} + +type FfiConverterOptionalBindingCollectorConfig struct{} + +var FfiConverterOptionalBindingCollectorConfigINSTANCE = FfiConverterOptionalBindingCollectorConfig{} + +func (c FfiConverterOptionalBindingCollectorConfig) Lift(rb RustBufferI) *BindingCollectorConfig { + return LiftFromRustBuffer[*BindingCollectorConfig](c, rb) +} + +func (_ FfiConverterOptionalBindingCollectorConfig) Read(reader io.Reader) *BindingCollectorConfig { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterBindingCollectorConfigINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalBindingCollectorConfig) Lower(value *BindingCollectorConfig) C.RustBuffer { + return LowerIntoRustBuffer[*BindingCollectorConfig](c, value) +} + +func (c FfiConverterOptionalBindingCollectorConfig) LowerExternal(value *BindingCollectorConfig) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingCollectorConfig](c, value)) +} + +func (_ FfiConverterOptionalBindingCollectorConfig) Write(writer io.Writer, value *BindingCollectorConfig) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterBindingCollectorConfigINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalBindingCollectorConfig struct{} + +func (_ FfiDestroyerOptionalBindingCollectorConfig) Destroy(value *BindingCollectorConfig) { + if value != nil { + FfiDestroyerBindingCollectorConfig{}.Destroy(*value) + } +} + +type FfiConverterOptionalBindingFailure struct{} + +var FfiConverterOptionalBindingFailureINSTANCE = FfiConverterOptionalBindingFailure{} + +func (c FfiConverterOptionalBindingFailure) Lift(rb RustBufferI) *BindingFailure { + return LiftFromRustBuffer[*BindingFailure](c, rb) +} + +func (_ FfiConverterOptionalBindingFailure) Read(reader io.Reader) *BindingFailure { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterBindingFailureINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalBindingFailure) Lower(value *BindingFailure) C.RustBuffer { + return LowerIntoRustBuffer[*BindingFailure](c, value) +} + +func (c FfiConverterOptionalBindingFailure) LowerExternal(value *BindingFailure) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingFailure](c, value)) +} + +func (_ FfiConverterOptionalBindingFailure) Write(writer io.Writer, value *BindingFailure) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterBindingFailureINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalBindingFailure struct{} + +func (_ FfiDestroyerOptionalBindingFailure) Destroy(value *BindingFailure) { + if value != nil { + FfiDestroyerBindingFailure{}.Destroy(*value) + } +} + +type FfiConverterOptionalSendReport struct{} + +var FfiConverterOptionalSendReportINSTANCE = FfiConverterOptionalSendReport{} + +func (c FfiConverterOptionalSendReport) Lift(rb RustBufferI) *SendReport { + return LiftFromRustBuffer[*SendReport](c, rb) +} + +func (_ FfiConverterOptionalSendReport) Read(reader io.Reader) *SendReport { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterSendReportINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalSendReport) Lower(value *SendReport) C.RustBuffer { + return LowerIntoRustBuffer[*SendReport](c, value) +} + +func (c FfiConverterOptionalSendReport) LowerExternal(value *SendReport) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*SendReport](c, value)) +} + +func (_ FfiConverterOptionalSendReport) Write(writer io.Writer, value *SendReport) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterSendReportINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalSendReport struct{} + +func (_ FfiDestroyerOptionalSendReport) Destroy(value *SendReport) { + if value != nil { + FfiDestroyerSendReport{}.Destroy(*value) + } +} + +type FfiConverterOptionalSpaceInvitation struct{} + +var FfiConverterOptionalSpaceInvitationINSTANCE = FfiConverterOptionalSpaceInvitation{} + +func (c FfiConverterOptionalSpaceInvitation) Lift(rb RustBufferI) *SpaceInvitation { + return LiftFromRustBuffer[*SpaceInvitation](c, rb) +} + +func (_ FfiConverterOptionalSpaceInvitation) Read(reader io.Reader) *SpaceInvitation { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterSpaceInvitationINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalSpaceInvitation) Lower(value *SpaceInvitation) C.RustBuffer { + return LowerIntoRustBuffer[*SpaceInvitation](c, value) +} + +func (c FfiConverterOptionalSpaceInvitation) LowerExternal(value *SpaceInvitation) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*SpaceInvitation](c, value)) +} + +func (_ FfiConverterOptionalSpaceInvitation) Write(writer io.Writer, value *SpaceInvitation) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterSpaceInvitationINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalSpaceInvitation struct{} + +func (_ FfiDestroyerOptionalSpaceInvitation) Destroy(value *SpaceInvitation) { + if value != nil { + FfiDestroyerSpaceInvitation{}.Destroy(*value) + } +} + +type FfiConverterOptionalBindingCaptureEndReason struct{} + +var FfiConverterOptionalBindingCaptureEndReasonINSTANCE = FfiConverterOptionalBindingCaptureEndReason{} + +func (c FfiConverterOptionalBindingCaptureEndReason) Lift(rb RustBufferI) *BindingCaptureEndReason { + return LiftFromRustBuffer[*BindingCaptureEndReason](c, rb) +} + +func (_ FfiConverterOptionalBindingCaptureEndReason) Read(reader io.Reader) *BindingCaptureEndReason { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterBindingCaptureEndReasonINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalBindingCaptureEndReason) Lower(value *BindingCaptureEndReason) C.RustBuffer { + return LowerIntoRustBuffer[*BindingCaptureEndReason](c, value) +} + +func (c FfiConverterOptionalBindingCaptureEndReason) LowerExternal(value *BindingCaptureEndReason) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingCaptureEndReason](c, value)) +} + +func (_ FfiConverterOptionalBindingCaptureEndReason) Write(writer io.Writer, value *BindingCaptureEndReason) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterBindingCaptureEndReasonINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalBindingCaptureEndReason struct{} + +func (_ FfiDestroyerOptionalBindingCaptureEndReason) Destroy(value *BindingCaptureEndReason) { + if value != nil { + FfiDestroyerBindingCaptureEndReason{}.Destroy(*value) + } +} + +type FfiConverterOptionalBindingEvent struct{} + +var FfiConverterOptionalBindingEventINSTANCE = FfiConverterOptionalBindingEvent{} + +func (c FfiConverterOptionalBindingEvent) Lift(rb RustBufferI) *BindingEvent { + return LiftFromRustBuffer[*BindingEvent](c, rb) +} + +func (_ FfiConverterOptionalBindingEvent) Read(reader io.Reader) *BindingEvent { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterBindingEventINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalBindingEvent) Lower(value *BindingEvent) C.RustBuffer { + return LowerIntoRustBuffer[*BindingEvent](c, value) +} + +func (c FfiConverterOptionalBindingEvent) LowerExternal(value *BindingEvent) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingEvent](c, value)) +} + +func (_ FfiConverterOptionalBindingEvent) Write(writer io.Writer, value *BindingEvent) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterBindingEventINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalBindingEvent struct{} + +func (_ FfiDestroyerOptionalBindingEvent) Destroy(value *BindingEvent) { + if value != nil { + FfiDestroyerBindingEvent{}.Destroy(*value) + } +} + +type FfiConverterOptionalBindingObservabilityRemoteSetupFailure struct{} + +var FfiConverterOptionalBindingObservabilityRemoteSetupFailureINSTANCE = FfiConverterOptionalBindingObservabilityRemoteSetupFailure{} + +func (c FfiConverterOptionalBindingObservabilityRemoteSetupFailure) Lift(rb RustBufferI) *BindingObservabilityRemoteSetupFailure { + return LiftFromRustBuffer[*BindingObservabilityRemoteSetupFailure](c, rb) +} + +func (_ FfiConverterOptionalBindingObservabilityRemoteSetupFailure) Read(reader io.Reader) *BindingObservabilityRemoteSetupFailure { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterBindingObservabilityRemoteSetupFailureINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalBindingObservabilityRemoteSetupFailure) Lower(value *BindingObservabilityRemoteSetupFailure) C.RustBuffer { + return LowerIntoRustBuffer[*BindingObservabilityRemoteSetupFailure](c, value) +} + +func (c FfiConverterOptionalBindingObservabilityRemoteSetupFailure) LowerExternal(value *BindingObservabilityRemoteSetupFailure) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*BindingObservabilityRemoteSetupFailure](c, value)) +} + +func (_ FfiConverterOptionalBindingObservabilityRemoteSetupFailure) Write(writer io.Writer, value *BindingObservabilityRemoteSetupFailure) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterBindingObservabilityRemoteSetupFailureINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalBindingObservabilityRemoteSetupFailure struct{} + +func (_ FfiDestroyerOptionalBindingObservabilityRemoteSetupFailure) Destroy(value *BindingObservabilityRemoteSetupFailure) { + if value != nil { + FfiDestroyerBindingObservabilityRemoteSetupFailure{}.Destroy(*value) + } +} + +type FfiConverterOptionalCustomRelayMutationRejection struct{} + +var FfiConverterOptionalCustomRelayMutationRejectionINSTANCE = FfiConverterOptionalCustomRelayMutationRejection{} + +func (c FfiConverterOptionalCustomRelayMutationRejection) Lift(rb RustBufferI) *CustomRelayMutationRejection { + return LiftFromRustBuffer[*CustomRelayMutationRejection](c, rb) +} + +func (_ FfiConverterOptionalCustomRelayMutationRejection) Read(reader io.Reader) *CustomRelayMutationRejection { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterCustomRelayMutationRejectionINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalCustomRelayMutationRejection) Lower(value *CustomRelayMutationRejection) C.RustBuffer { + return LowerIntoRustBuffer[*CustomRelayMutationRejection](c, value) +} + +func (c FfiConverterOptionalCustomRelayMutationRejection) LowerExternal(value *CustomRelayMutationRejection) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*CustomRelayMutationRejection](c, value)) +} + +func (_ FfiConverterOptionalCustomRelayMutationRejection) Write(writer io.Writer, value *CustomRelayMutationRejection) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterCustomRelayMutationRejectionINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalCustomRelayMutationRejection struct{} + +func (_ FfiDestroyerOptionalCustomRelayMutationRejection) Destroy(value *CustomRelayMutationRejection) { + if value != nil { + FfiDestroyerCustomRelayMutationRejection{}.Destroy(*value) + } +} + +type FfiConverterOptionalRelayRoutingMode struct{} + +var FfiConverterOptionalRelayRoutingModeINSTANCE = FfiConverterOptionalRelayRoutingMode{} + +func (c FfiConverterOptionalRelayRoutingMode) Lift(rb RustBufferI) *RelayRoutingMode { + return LiftFromRustBuffer[*RelayRoutingMode](c, rb) +} + +func (_ FfiConverterOptionalRelayRoutingMode) Read(reader io.Reader) *RelayRoutingMode { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterRelayRoutingModeINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalRelayRoutingMode) Lower(value *RelayRoutingMode) C.RustBuffer { + return LowerIntoRustBuffer[*RelayRoutingMode](c, value) +} + +func (c FfiConverterOptionalRelayRoutingMode) LowerExternal(value *RelayRoutingMode) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*RelayRoutingMode](c, value)) +} + +func (_ FfiConverterOptionalRelayRoutingMode) Write(writer io.Writer, value *RelayRoutingMode) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterRelayRoutingModeINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalRelayRoutingMode struct{} + +func (_ FfiDestroyerOptionalRelayRoutingMode) Destroy(value *RelayRoutingMode) { + if value != nil { + FfiDestroyerRelayRoutingMode{}.Destroy(*value) + } +} + +type FfiConverterOptionalWorkspaceConvergenceFailureCategory struct{} + +var FfiConverterOptionalWorkspaceConvergenceFailureCategoryINSTANCE = FfiConverterOptionalWorkspaceConvergenceFailureCategory{} + +func (c FfiConverterOptionalWorkspaceConvergenceFailureCategory) Lift(rb RustBufferI) *WorkspaceConvergenceFailureCategory { + return LiftFromRustBuffer[*WorkspaceConvergenceFailureCategory](c, rb) +} + +func (_ FfiConverterOptionalWorkspaceConvergenceFailureCategory) Read(reader io.Reader) *WorkspaceConvergenceFailureCategory { + if readInt8(reader) == 0 { + return nil + } + temp := FfiConverterWorkspaceConvergenceFailureCategoryINSTANCE.Read(reader) + return &temp +} + +func (c FfiConverterOptionalWorkspaceConvergenceFailureCategory) Lower(value *WorkspaceConvergenceFailureCategory) C.RustBuffer { + return LowerIntoRustBuffer[*WorkspaceConvergenceFailureCategory](c, value) +} + +func (c FfiConverterOptionalWorkspaceConvergenceFailureCategory) LowerExternal(value *WorkspaceConvergenceFailureCategory) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[*WorkspaceConvergenceFailureCategory](c, value)) +} + +func (_ FfiConverterOptionalWorkspaceConvergenceFailureCategory) Write(writer io.Writer, value *WorkspaceConvergenceFailureCategory) { + if value == nil { + writeInt8(writer, 0) + } else { + writeInt8(writer, 1) + FfiConverterWorkspaceConvergenceFailureCategoryINSTANCE.Write(writer, *value) + } +} + +type FfiDestroyerOptionalWorkspaceConvergenceFailureCategory struct{} + +func (_ FfiDestroyerOptionalWorkspaceConvergenceFailureCategory) Destroy(value *WorkspaceConvergenceFailureCategory) { + if value != nil { + FfiDestroyerWorkspaceConvergenceFailureCategory{}.Destroy(*value) + } +} + +type FfiConverterSequenceString struct{} + +var FfiConverterSequenceStringINSTANCE = FfiConverterSequenceString{} + +func (c FfiConverterSequenceString) Lift(rb RustBufferI) []string { + return LiftFromRustBuffer[[]string](c, rb) +} + +func (c FfiConverterSequenceString) Read(reader io.Reader) []string { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]string, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterStringINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceString) Lower(value []string) C.RustBuffer { + return LowerIntoRustBuffer[[]string](c, value) +} + +func (c FfiConverterSequenceString) LowerExternal(value []string) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[[]string](c, value)) +} + +func (c FfiConverterSequenceString) Write(writer io.Writer, value []string) { + if len(value) > math.MaxInt32 { + panic("[]string is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterStringINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceString struct{} + +func (FfiDestroyerSequenceString) Destroy(sequence []string) { + for _, value := range sequence { + FfiDestroyerString{}.Destroy(value) + } +} + +type FfiConverterSequenceBindingFileSourceCounts struct{} + +var FfiConverterSequenceBindingFileSourceCountsINSTANCE = FfiConverterSequenceBindingFileSourceCounts{} + +func (c FfiConverterSequenceBindingFileSourceCounts) Lift(rb RustBufferI) []BindingFileSourceCounts { + return LiftFromRustBuffer[[]BindingFileSourceCounts](c, rb) +} + +func (c FfiConverterSequenceBindingFileSourceCounts) Read(reader io.Reader) []BindingFileSourceCounts { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]BindingFileSourceCounts, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterBindingFileSourceCountsINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceBindingFileSourceCounts) Lower(value []BindingFileSourceCounts) C.RustBuffer { + return LowerIntoRustBuffer[[]BindingFileSourceCounts](c, value) +} + +func (c FfiConverterSequenceBindingFileSourceCounts) LowerExternal(value []BindingFileSourceCounts) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[[]BindingFileSourceCounts](c, value)) +} + +func (c FfiConverterSequenceBindingFileSourceCounts) Write(writer io.Writer, value []BindingFileSourceCounts) { + if len(value) > math.MaxInt32 { + panic("[]BindingFileSourceCounts is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterBindingFileSourceCountsINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceBindingFileSourceCounts struct{} + +func (FfiDestroyerSequenceBindingFileSourceCounts) Destroy(sequence []BindingFileSourceCounts) { + for _, value := range sequence { + FfiDestroyerBindingFileSourceCounts{}.Destroy(value) + } +} + +type FfiConverterSequenceBindingSourceCoverage struct{} + +var FfiConverterSequenceBindingSourceCoverageINSTANCE = FfiConverterSequenceBindingSourceCoverage{} + +func (c FfiConverterSequenceBindingSourceCoverage) Lift(rb RustBufferI) []BindingSourceCoverage { + return LiftFromRustBuffer[[]BindingSourceCoverage](c, rb) +} + +func (c FfiConverterSequenceBindingSourceCoverage) Read(reader io.Reader) []BindingSourceCoverage { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]BindingSourceCoverage, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterBindingSourceCoverageINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceBindingSourceCoverage) Lower(value []BindingSourceCoverage) C.RustBuffer { + return LowerIntoRustBuffer[[]BindingSourceCoverage](c, value) +} + +func (c FfiConverterSequenceBindingSourceCoverage) LowerExternal(value []BindingSourceCoverage) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[[]BindingSourceCoverage](c, value)) +} + +func (c FfiConverterSequenceBindingSourceCoverage) Write(writer io.Writer, value []BindingSourceCoverage) { + if len(value) > math.MaxInt32 { + panic("[]BindingSourceCoverage is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterBindingSourceCoverageINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceBindingSourceCoverage struct{} + +func (FfiDestroyerSequenceBindingSourceCoverage) Destroy(sequence []BindingSourceCoverage) { + for _, value := range sequence { + FfiDestroyerBindingSourceCoverage{}.Destroy(value) + } +} + +type FfiConverterSequenceCustomRelay struct{} + +var FfiConverterSequenceCustomRelayINSTANCE = FfiConverterSequenceCustomRelay{} + +func (c FfiConverterSequenceCustomRelay) Lift(rb RustBufferI) []CustomRelay { + return LiftFromRustBuffer[[]CustomRelay](c, rb) +} + +func (c FfiConverterSequenceCustomRelay) Read(reader io.Reader) []CustomRelay { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]CustomRelay, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterCustomRelayINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceCustomRelay) Lower(value []CustomRelay) C.RustBuffer { + return LowerIntoRustBuffer[[]CustomRelay](c, value) +} + +func (c FfiConverterSequenceCustomRelay) LowerExternal(value []CustomRelay) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[[]CustomRelay](c, value)) +} + +func (c FfiConverterSequenceCustomRelay) Write(writer io.Writer, value []CustomRelay) { + if len(value) > math.MaxInt32 { + panic("[]CustomRelay is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterCustomRelayINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceCustomRelay struct{} + +func (FfiDestroyerSequenceCustomRelay) Destroy(sequence []CustomRelay) { + for _, value := range sequence { + FfiDestroyerCustomRelay{}.Destroy(value) + } +} + +type FfiConverterSequenceDevice struct{} + +var FfiConverterSequenceDeviceINSTANCE = FfiConverterSequenceDevice{} + +func (c FfiConverterSequenceDevice) Lift(rb RustBufferI) []Device { + return LiftFromRustBuffer[[]Device](c, rb) +} + +func (c FfiConverterSequenceDevice) Read(reader io.Reader) []Device { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]Device, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterDeviceINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceDevice) Lower(value []Device) C.RustBuffer { + return LowerIntoRustBuffer[[]Device](c, value) +} + +func (c FfiConverterSequenceDevice) LowerExternal(value []Device) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[[]Device](c, value)) +} + +func (c FfiConverterSequenceDevice) Write(writer io.Writer, value []Device) { + if len(value) > math.MaxInt32 { + panic("[]Device is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterDeviceINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceDevice struct{} + +func (FfiDestroyerSequenceDevice) Destroy(sequence []Device) { + for _, value := range sequence { + FfiDestroyerDevice{}.Destroy(value) + } +} + +type FfiConverterSequenceRelayOverviewEntry struct{} + +var FfiConverterSequenceRelayOverviewEntryINSTANCE = FfiConverterSequenceRelayOverviewEntry{} + +func (c FfiConverterSequenceRelayOverviewEntry) Lift(rb RustBufferI) []RelayOverviewEntry { + return LiftFromRustBuffer[[]RelayOverviewEntry](c, rb) +} + +func (c FfiConverterSequenceRelayOverviewEntry) Read(reader io.Reader) []RelayOverviewEntry { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]RelayOverviewEntry, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterRelayOverviewEntryINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceRelayOverviewEntry) Lower(value []RelayOverviewEntry) C.RustBuffer { + return LowerIntoRustBuffer[[]RelayOverviewEntry](c, value) +} + +func (c FfiConverterSequenceRelayOverviewEntry) LowerExternal(value []RelayOverviewEntry) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[[]RelayOverviewEntry](c, value)) +} + +func (c FfiConverterSequenceRelayOverviewEntry) Write(writer io.Writer, value []RelayOverviewEntry) { + if len(value) > math.MaxInt32 { + panic("[]RelayOverviewEntry is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterRelayOverviewEntryINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceRelayOverviewEntry struct{} + +func (FfiDestroyerSequenceRelayOverviewEntry) Destroy(sequence []RelayOverviewEntry) { + for _, value := range sequence { + FfiDestroyerRelayOverviewEntry{}.Destroy(value) + } +} + +type FfiConverterSequenceBindingClipboardRepresentation struct{} + +var FfiConverterSequenceBindingClipboardRepresentationINSTANCE = FfiConverterSequenceBindingClipboardRepresentation{} + +func (c FfiConverterSequenceBindingClipboardRepresentation) Lift(rb RustBufferI) []BindingClipboardRepresentation { + return LiftFromRustBuffer[[]BindingClipboardRepresentation](c, rb) +} + +func (c FfiConverterSequenceBindingClipboardRepresentation) Read(reader io.Reader) []BindingClipboardRepresentation { + length := readInt32(reader) + if length == 0 { + return nil + } + result := make([]BindingClipboardRepresentation, 0, length) + for i := int32(0); i < length; i++ { + result = append(result, FfiConverterBindingClipboardRepresentationINSTANCE.Read(reader)) + } + return result +} + +func (c FfiConverterSequenceBindingClipboardRepresentation) Lower(value []BindingClipboardRepresentation) C.RustBuffer { + return LowerIntoRustBuffer[[]BindingClipboardRepresentation](c, value) +} + +func (c FfiConverterSequenceBindingClipboardRepresentation) LowerExternal(value []BindingClipboardRepresentation) ExternalCRustBuffer { + return RustBufferFromC(LowerIntoRustBuffer[[]BindingClipboardRepresentation](c, value)) +} + +func (c FfiConverterSequenceBindingClipboardRepresentation) Write(writer io.Writer, value []BindingClipboardRepresentation) { + if len(value) > math.MaxInt32 { + panic("[]BindingClipboardRepresentation is too large to fit into Int32") + } + + writeInt32(writer, int32(len(value))) + for _, item := range value { + FfiConverterBindingClipboardRepresentationINSTANCE.Write(writer, item) + } +} + +type FfiDestroyerSequenceBindingClipboardRepresentation struct{} + +func (FfiDestroyerSequenceBindingClipboardRepresentation) Destroy(sequence []BindingClipboardRepresentation) { + for _, value := range sequence { + FfiDestroyerBindingClipboardRepresentation{}.Destroy(value) + } +} + +func CoreVersion() string { + return FfiConverterStringINSTANCE.Lift(rustCall(func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_core_version(_uniffiStatus), + } + })) +} + +func FlushProcessObservability(deadlineMs uint64) (BindingObservabilityFlushSummary, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_flush_process_observability(FfiConverterUint64INSTANCE.Lower(deadlineMs), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingObservabilityFlushSummary + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingObservabilityFlushSummaryINSTANCE.Lift(_uniffiRV), nil + } +} + +func InstallProcessObservability(config BindingObservabilityConfig, host BindingHost) (BindingObservabilitySetup, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_install_process_observability(FfiConverterBindingObservabilityConfigINSTANCE.Lower(config), FfiConverterBindingHostINSTANCE.Lower(host), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingObservabilitySetup + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingObservabilitySetupINSTANCE.Lift(_uniffiRV), nil + } +} + +func QueryProcessObservabilityHealth() (BindingObservabilityHealth, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_query_process_observability_health(_uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingObservabilityHealth + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingObservabilityHealthINSTANCE.Lift(_uniffiRV), nil + } +} + +func ShutdownProcessObservability(deadlineMs uint64) (BindingObservabilityShutdownSummary, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingError](FfiConverterBindingError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_shutdown_process_observability(FfiConverterUint64INSTANCE.Lower(deadlineMs), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingObservabilityShutdownSummary + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingObservabilityShutdownSummaryINSTANCE.Lift(_uniffiRV), nil + } +} + +// 与原有 flush 一样,宿主须在原生后台工作队列调用,不能在 UI 主线程等待。 +func PrepareLocalDiagnosticExport(deadlineMs uint64) (BindingLocalDiagnosticExportReport, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingLocalDiagnosticError](FfiConverterBindingLocalDiagnosticError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_prepare_local_diagnostic_export(FfiConverterUint64INSTANCE.Lower(deadlineMs), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingLocalDiagnosticExportReport + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingLocalDiagnosticExportReportINSTANCE.Lift(_uniffiRV), nil + } +} + +func QueryLocalDiagnosticStatus() (BindingLocalDiagnosticStatus, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingLocalDiagnosticError](FfiConverterBindingLocalDiagnosticError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_query_local_diagnostic_status(_uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingLocalDiagnosticStatus + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingLocalDiagnosticStatusINSTANCE.Lift(_uniffiRV), nil + } +} + +func RecordHostDiagnostic(source BindingHostDiagnosticSource, event BindingHostDiagnosticEvent) (BindingHostDiagnosticReceipt, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingLocalDiagnosticError](FfiConverterBindingLocalDiagnosticError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_record_host_diagnostic(FfiConverterBindingHostDiagnosticSourceINSTANCE.Lower(source), FfiConverterBindingHostDiagnosticEventINSTANCE.Lower(event), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingHostDiagnosticReceipt + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingHostDiagnosticReceiptINSTANCE.Lift(_uniffiRV), nil + } +} + +func RegisterHostDiagnosticSource(source BindingHostDiagnosticSource, capability BindingSourceCapability) error { + _, _uniffiErr := rustCallWithError[*BindingLocalDiagnosticError](FfiConverterBindingLocalDiagnosticError{}, func(_uniffiStatus *C.RustCallStatus) bool { + C.uniffi_uc_engine_uniffi_fn_func_register_host_diagnostic_source(FfiConverterBindingHostDiagnosticSourceINSTANCE.Lower(source), FfiConverterBindingSourceCapabilityINSTANCE.Lower(capability), _uniffiStatus) + return false + }) + return _uniffiErr.AsError() +} + +func StartLocalDiagnosticCapture(durationMs uint64) (BindingLocalCaptureStatus, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingLocalDiagnosticError](FfiConverterBindingLocalDiagnosticError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_start_local_diagnostic_capture(FfiConverterUint64INSTANCE.Lower(durationMs), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingLocalCaptureStatus + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingLocalCaptureStatusINSTANCE.Lift(_uniffiRV), nil + } +} + +func StopLocalDiagnosticCapture(captureId string) (BindingStopCaptureResult, error) { + _uniffiRV, _uniffiErr := rustCallWithError[*BindingLocalDiagnosticError](FfiConverterBindingLocalDiagnosticError{}, func(_uniffiStatus *C.RustCallStatus) RustBufferI { + return GoRustBuffer{ + inner: C.uniffi_uc_engine_uniffi_fn_func_stop_local_diagnostic_capture(FfiConverterStringINSTANCE.Lower(captureId), _uniffiStatus), + } + }) + if _uniffiErr != nil { + var _uniffiDefaultValue BindingStopCaptureResult + return _uniffiDefaultValue, _uniffiErr + } else { + return FfiConverterBindingStopCaptureResultINSTANCE.Lift(_uniffiRV), nil + } +} diff --git a/bindings/go/uc_engine_uniffi/uc_engine_uniffi.h b/bindings/go/uc_engine_uniffi/uc_engine_uniffi.h new file mode 100644 index 00000000..9c65b8ba --- /dev/null +++ b/bindings/go/uc_engine_uniffi/uc_engine_uniffi.h @@ -0,0 +1,1853 @@ + + +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + + + +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V6 + #ifndef UNIFFI_SHARED_HEADER_V6 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V6 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V6 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V6 in this file. ⚠️ + +typedef struct RustBuffer { + uint64_t capacity; + uint64_t len; + uint8_t *data; +} RustBuffer; + +typedef struct ForeignBytes { + int32_t len; + const uint8_t *data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +#endif // UNIFFI_SHARED_H + + +#ifndef UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +#define UNIFFI_FFIDEF_RUST_FUTURE_CONTINUATION_CALLBACK +typedef void (*UniffiRustFutureContinuationCallback)(uint64_t data, int8_t poll_result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiRustFutureContinuationCallback( + UniffiRustFutureContinuationCallback cb, uint64_t data, int8_t poll_result) +{ + return cb(data, poll_result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK +typedef void (*UniffiForeignFutureDroppedCallback)(uint64_t handle); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureDroppedCallback( + UniffiForeignFutureDroppedCallback cb, uint64_t handle) +{ + return cb(handle); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_FREE +typedef void (*UniffiCallbackInterfaceFree)(uint64_t handle); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceFree( + UniffiCallbackInterfaceFree cb, uint64_t handle) +{ + return cb(handle); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_CLONE +typedef uint64_t (*UniffiCallbackInterfaceClone)(uint64_t handle); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static uint64_t call_UniffiCallbackInterfaceClone( + UniffiCallbackInterfaceClone cb, uint64_t handle) +{ + return cb(handle); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_DROPPED_CALLBACK_STRUCT +typedef struct UniffiForeignFutureDroppedCallbackStruct { + uint64_t handle; + UniffiForeignFutureDroppedCallback free; +} UniffiForeignFutureDroppedCallbackStruct; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U8 +typedef struct UniffiForeignFutureResultU8 { + uint8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U8 +typedef void (*UniffiForeignFutureCompleteU8)(uint64_t callback_data, UniffiForeignFutureResultU8 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteU8( + UniffiForeignFutureCompleteU8 cb, uint64_t callback_data, UniffiForeignFutureResultU8 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I8 +typedef struct UniffiForeignFutureResultI8 { + int8_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI8; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I8 +typedef void (*UniffiForeignFutureCompleteI8)(uint64_t callback_data, UniffiForeignFutureResultI8 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteI8( + UniffiForeignFutureCompleteI8 cb, uint64_t callback_data, UniffiForeignFutureResultI8 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U16 +typedef struct UniffiForeignFutureResultU16 { + uint16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U16 +typedef void (*UniffiForeignFutureCompleteU16)(uint64_t callback_data, UniffiForeignFutureResultU16 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteU16( + UniffiForeignFutureCompleteU16 cb, uint64_t callback_data, UniffiForeignFutureResultU16 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I16 +typedef struct UniffiForeignFutureResultI16 { + int16_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI16; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I16 +typedef void (*UniffiForeignFutureCompleteI16)(uint64_t callback_data, UniffiForeignFutureResultI16 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteI16( + UniffiForeignFutureCompleteI16 cb, uint64_t callback_data, UniffiForeignFutureResultI16 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U32 +typedef struct UniffiForeignFutureResultU32 { + uint32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U32 +typedef void (*UniffiForeignFutureCompleteU32)(uint64_t callback_data, UniffiForeignFutureResultU32 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteU32( + UniffiForeignFutureCompleteU32 cb, uint64_t callback_data, UniffiForeignFutureResultU32 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I32 +typedef struct UniffiForeignFutureResultI32 { + int32_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I32 +typedef void (*UniffiForeignFutureCompleteI32)(uint64_t callback_data, UniffiForeignFutureResultI32 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteI32( + UniffiForeignFutureCompleteI32 cb, uint64_t callback_data, UniffiForeignFutureResultI32 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_U64 +typedef struct UniffiForeignFutureResultU64 { + uint64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultU64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_U64 +typedef void (*UniffiForeignFutureCompleteU64)(uint64_t callback_data, UniffiForeignFutureResultU64 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteU64( + UniffiForeignFutureCompleteU64 cb, uint64_t callback_data, UniffiForeignFutureResultU64 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_I64 +typedef struct UniffiForeignFutureResultI64 { + int64_t returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultI64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_I64 +typedef void (*UniffiForeignFutureCompleteI64)(uint64_t callback_data, UniffiForeignFutureResultI64 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteI64( + UniffiForeignFutureCompleteI64 cb, uint64_t callback_data, UniffiForeignFutureResultI64 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F32 +typedef struct UniffiForeignFutureResultF32 { + float returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF32; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F32 +typedef void (*UniffiForeignFutureCompleteF32)(uint64_t callback_data, UniffiForeignFutureResultF32 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteF32( + UniffiForeignFutureCompleteF32 cb, uint64_t callback_data, UniffiForeignFutureResultF32 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_F64 +typedef struct UniffiForeignFutureResultF64 { + double returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultF64; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_F64 +typedef void (*UniffiForeignFutureCompleteF64)(uint64_t callback_data, UniffiForeignFutureResultF64 result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteF64( + UniffiForeignFutureCompleteF64 cb, uint64_t callback_data, UniffiForeignFutureResultF64 result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_RUST_BUFFER +typedef struct UniffiForeignFutureResultRustBuffer { + RustBuffer returnValue; + RustCallStatus callStatus; +} UniffiForeignFutureResultRustBuffer; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER +typedef void (*UniffiForeignFutureCompleteRustBuffer)(uint64_t callback_data, UniffiForeignFutureResultRustBuffer result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteRustBuffer( + UniffiForeignFutureCompleteRustBuffer cb, uint64_t callback_data, UniffiForeignFutureResultRustBuffer result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_RESULT_VOID +typedef struct UniffiForeignFutureResultVoid { + RustCallStatus callStatus; +} UniffiForeignFutureResultVoid; + +#endif +#ifndef UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FOREIGN_FUTURE_COMPLETE_VOID +typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t callback_data, UniffiForeignFutureResultVoid result); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiForeignFutureCompleteVoid( + UniffiForeignFutureCompleteVoid cb, uint64_t callback_data, UniffiForeignFutureResultVoid result) +{ + return cb(callback_data, result); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD0 +typedef void (*UniffiCallbackInterfaceBindingAnalyticsHostMethod0)(uint64_t uniffi_handle, RustBuffer event, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingAnalyticsHostMethod0( + UniffiCallbackInterfaceBindingAnalyticsHostMethod0 cb, uint64_t uniffi_handle, RustBuffer event, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, event, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD1 +typedef void (*UniffiCallbackInterfaceBindingAnalyticsHostMethod1)(uint64_t uniffi_handle, RustBuffer payload, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingAnalyticsHostMethod1( + UniffiCallbackInterfaceBindingAnalyticsHostMethod1 cb, uint64_t uniffi_handle, RustBuffer payload, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, payload, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD2 +typedef void (*UniffiCallbackInterfaceBindingAnalyticsHostMethod2)(uint64_t uniffi_handle, RustBuffer payload, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingAnalyticsHostMethod2( + UniffiCallbackInterfaceBindingAnalyticsHostMethod2 cb, uint64_t uniffi_handle, RustBuffer payload, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, payload, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD3 +typedef void (*UniffiCallbackInterfaceBindingAnalyticsHostMethod3)(uint64_t uniffi_handle, RustBuffer space_person_id, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingAnalyticsHostMethod3( + UniffiCallbackInterfaceBindingAnalyticsHostMethod3 cb, uint64_t uniffi_handle, RustBuffer space_person_id, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, space_person_id, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD4 +typedef void (*UniffiCallbackInterfaceBindingAnalyticsHostMethod4)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingAnalyticsHostMethod4( + UniffiCallbackInterfaceBindingAnalyticsHostMethod4 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD5 +typedef void (*UniffiCallbackInterfaceBindingAnalyticsHostMethod5)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingAnalyticsHostMethod5( + UniffiCallbackInterfaceBindingAnalyticsHostMethod5 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD6 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST_METHOD6 +typedef void (*UniffiCallbackInterfaceBindingAnalyticsHostMethod6)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingAnalyticsHostMethod6( + UniffiCallbackInterfaceBindingAnalyticsHostMethod6 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD0 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD0 +typedef void (*UniffiCallbackInterfaceBindingHostMethod0)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod0( + UniffiCallbackInterfaceBindingHostMethod0 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD1 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD1 +typedef void (*UniffiCallbackInterfaceBindingHostMethod1)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod1( + UniffiCallbackInterfaceBindingHostMethod1 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD2 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD2 +typedef void (*UniffiCallbackInterfaceBindingHostMethod2)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod2( + UniffiCallbackInterfaceBindingHostMethod2 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD3 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD3 +typedef void (*UniffiCallbackInterfaceBindingHostMethod3)(uint64_t uniffi_handle, RustBuffer key, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod3( + UniffiCallbackInterfaceBindingHostMethod3 cb, uint64_t uniffi_handle, RustBuffer key, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, key, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD4 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD4 +typedef void (*UniffiCallbackInterfaceBindingHostMethod4)(uint64_t uniffi_handle, RustBuffer key, RustBuffer value, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod4( + UniffiCallbackInterfaceBindingHostMethod4 cb, uint64_t uniffi_handle, RustBuffer key, RustBuffer value, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, key, value, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD5 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD5 +typedef void (*UniffiCallbackInterfaceBindingHostMethod5)(uint64_t uniffi_handle, RustBuffer key, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod5( + UniffiCallbackInterfaceBindingHostMethod5 cb, uint64_t uniffi_handle, RustBuffer key, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, key, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD6 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD6 +typedef void (*UniffiCallbackInterfaceBindingHostMethod6)(uint64_t uniffi_handle, RustBuffer handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod6( + UniffiCallbackInterfaceBindingHostMethod6 cb, uint64_t uniffi_handle, RustBuffer handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD7 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD7 +typedef void (*UniffiCallbackInterfaceBindingHostMethod7)(uint64_t uniffi_handle, RustBuffer handle, uint64_t offset, uint32_t max_bytes, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod7( + UniffiCallbackInterfaceBindingHostMethod7 cb, uint64_t uniffi_handle, RustBuffer handle, uint64_t offset, uint32_t max_bytes, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, handle, offset, max_bytes, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD8 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD8 +typedef void (*UniffiCallbackInterfaceBindingHostMethod8)(uint64_t uniffi_handle, RustBuffer handle, uint64_t offset, RustBuffer bytes, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod8( + UniffiCallbackInterfaceBindingHostMethod8 cb, uint64_t uniffi_handle, RustBuffer handle, uint64_t offset, RustBuffer bytes, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, handle, offset, bytes, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD9 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD9 +typedef void (*UniffiCallbackInterfaceBindingHostMethod9)(uint64_t uniffi_handle, RustBuffer handle, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod9( + UniffiCallbackInterfaceBindingHostMethod9 cb, uint64_t uniffi_handle, RustBuffer handle, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD10 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD10 +typedef void (*UniffiCallbackInterfaceBindingHostMethod10)(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod10( + UniffiCallbackInterfaceBindingHostMethod10 cb, uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD11 +#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_BINDING_HOST_METHOD11 +typedef void (*UniffiCallbackInterfaceBindingHostMethod11)(uint64_t uniffi_handle, RustBuffer snapshot, void* uniffi_out_return, RustCallStatus* callStatus ); + +// Making function static workaround: +// https://github.com/golang/go/issues/11263 +static void call_UniffiCallbackInterfaceBindingHostMethod11( + UniffiCallbackInterfaceBindingHostMethod11 cb, uint64_t uniffi_handle, RustBuffer snapshot, void* uniffi_out_return, RustCallStatus* callStatus ) +{ + return cb(uniffi_handle, snapshot, uniffi_out_return, callStatus ); +} + + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_BINDING_ANALYTICS_HOST +typedef struct UniffiVTableCallbackInterfaceBindingAnalyticsHost { + UniffiCallbackInterfaceFree uniffiFree; + UniffiCallbackInterfaceClone uniffiClone; + UniffiCallbackInterfaceBindingAnalyticsHostMethod0 capture; + UniffiCallbackInterfaceBindingAnalyticsHostMethod1 identify; + UniffiCallbackInterfaceBindingAnalyticsHostMethod2 groupIdentify; + UniffiCallbackInterfaceBindingAnalyticsHostMethod3 adoptSpacePerson; + UniffiCallbackInterfaceBindingAnalyticsHostMethod4 releaseSpacePerson; + UniffiCallbackInterfaceBindingAnalyticsHostMethod5 currentSpacePersonId; + UniffiCallbackInterfaceBindingAnalyticsHostMethod6 resetTelemetryIdentity; +} UniffiVTableCallbackInterfaceBindingAnalyticsHost; + +#endif +#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_BINDING_HOST +#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_BINDING_HOST +typedef struct UniffiVTableCallbackInterfaceBindingHost { + UniffiCallbackInterfaceFree uniffiFree; + UniffiCallbackInterfaceClone uniffiClone; + UniffiCallbackInterfaceBindingHostMethod0 privateDataDirectory; + UniffiCallbackInterfaceBindingHostMethod1 cacheDirectory; + UniffiCallbackInterfaceBindingHostMethod2 temporaryDirectory; + UniffiCallbackInterfaceBindingHostMethod3 secureStorageGet; + UniffiCallbackInterfaceBindingHostMethod4 secureStorageSet; + UniffiCallbackInterfaceBindingHostMethod5 secureStorageDelete; + UniffiCallbackInterfaceBindingHostMethod6 fileMetadata; + UniffiCallbackInterfaceBindingHostMethod7 fileReadChunk; + UniffiCallbackInterfaceBindingHostMethod8 fileWriteChunk; + UniffiCallbackInterfaceBindingHostMethod9 fileFinishWrite; + UniffiCallbackInterfaceBindingHostMethod10 clipboardRead; + UniffiCallbackInterfaceBindingHostMethod11 clipboardWrite; +} UniffiVTableCallbackInterfaceBindingHost; + +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_BINDINGANALYTICSHOST +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_BINDINGANALYTICSHOST +uint64_t uniffi_uc_engine_uniffi_fn_clone_bindinganalyticshost(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_BINDINGANALYTICSHOST +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_BINDINGANALYTICSHOST +void uniffi_uc_engine_uniffi_fn_free_bindinganalyticshost(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_INIT_CALLBACK_VTABLE_BINDINGANALYTICSHOST +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_INIT_CALLBACK_VTABLE_BINDINGANALYTICSHOST +void uniffi_uc_engine_uniffi_fn_init_callback_vtable_bindinganalyticshost(UniffiVTableCallbackInterfaceBindingAnalyticsHost* vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_CAPTURE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_CAPTURE +void uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_capture(uint64_t ptr, RustBuffer event, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_IDENTIFY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_IDENTIFY +void uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_identify(uint64_t ptr, RustBuffer payload, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_GROUP_IDENTIFY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_GROUP_IDENTIFY +void uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_group_identify(uint64_t ptr, RustBuffer payload, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_ADOPT_SPACE_PERSON +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_ADOPT_SPACE_PERSON +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_adopt_space_person(uint64_t ptr, RustBuffer space_person_id, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_RELEASE_SPACE_PERSON +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_RELEASE_SPACE_PERSON +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_release_space_person(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_CURRENT_SPACE_PERSON_ID +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_CURRENT_SPACE_PERSON_ID +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_current_space_person_id(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_RESET_TELEMETRY_IDENTITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGANALYTICSHOST_RESET_TELEMETRY_IDENTITY +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinganalyticshost_reset_telemetry_identity(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_BINDINGHOST +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_BINDINGHOST +uint64_t uniffi_uc_engine_uniffi_fn_clone_bindinghost(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_BINDINGHOST +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_BINDINGHOST +void uniffi_uc_engine_uniffi_fn_free_bindinghost(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_INIT_CALLBACK_VTABLE_BINDINGHOST +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_INIT_CALLBACK_VTABLE_BINDINGHOST +void uniffi_uc_engine_uniffi_fn_init_callback_vtable_bindinghost(UniffiVTableCallbackInterfaceBindingHost* vtable +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_PRIVATE_DATA_DIRECTORY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_PRIVATE_DATA_DIRECTORY +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinghost_private_data_directory(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_CACHE_DIRECTORY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_CACHE_DIRECTORY +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinghost_cache_directory(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_TEMPORARY_DIRECTORY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_TEMPORARY_DIRECTORY +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinghost_temporary_directory(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_SECURE_STORAGE_GET +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_SECURE_STORAGE_GET +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinghost_secure_storage_get(uint64_t ptr, RustBuffer key, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_SECURE_STORAGE_SET +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_SECURE_STORAGE_SET +void uniffi_uc_engine_uniffi_fn_method_bindinghost_secure_storage_set(uint64_t ptr, RustBuffer key, RustBuffer value, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_SECURE_STORAGE_DELETE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_SECURE_STORAGE_DELETE +void uniffi_uc_engine_uniffi_fn_method_bindinghost_secure_storage_delete(uint64_t ptr, RustBuffer key, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_METADATA +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_METADATA +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinghost_file_metadata(uint64_t ptr, RustBuffer handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_READ_CHUNK +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinghost_file_read_chunk(uint64_t ptr, RustBuffer handle, uint64_t offset, uint32_t max_bytes, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_WRITE_CHUNK +void uniffi_uc_engine_uniffi_fn_method_bindinghost_file_write_chunk(uint64_t ptr, RustBuffer handle, uint64_t offset, RustBuffer bytes, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_FINISH_WRITE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_FILE_FINISH_WRITE +void uniffi_uc_engine_uniffi_fn_method_bindinghost_file_finish_write(uint64_t ptr, RustBuffer handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_CLIPBOARD_READ +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_CLIPBOARD_READ +RustBuffer uniffi_uc_engine_uniffi_fn_method_bindinghost_clipboard_read(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_CLIPBOARD_WRITE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_BINDINGHOST_CLIPBOARD_WRITE +void uniffi_uc_engine_uniffi_fn_method_bindinghost_clipboard_write(uint64_t ptr, RustBuffer snapshot, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_MOBILEENGINE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_MOBILEENGINE +uint64_t uniffi_uc_engine_uniffi_fn_clone_mobileengine(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_MOBILEENGINE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_MOBILEENGINE +void uniffi_uc_engine_uniffi_fn_free_mobileengine(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START +uint64_t uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start(RustBuffer config, uint64_t host, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS +uint64_t uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start_with_analytics(RustBuffer config, uint64_t host, uint64_t analytics, RustBuffer context, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS_AND_LIFECYCLE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS_AND_LIFECYCLE +uint64_t uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start_with_analytics_and_lifecycle(RustBuffer config, uint64_t host, uint64_t analytics, RustBuffer context, uint64_t lifecycle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START_WITH_LIFECYCLE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILEENGINE_START_WITH_LIFECYCLE +uint64_t uniffi_uc_engine_uniffi_fn_constructor_mobileengine_start_with_lifecycle(RustBuffer config, uint64_t host, uint64_t lifecycle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_ADD_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_ADD_CUSTOM_RELAY +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_add_custom_relay(uint64_t ptr, RustBuffer url, RustBuffer access_token, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CANCEL_JOIN_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CANCEL_JOIN_SPACE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_cancel_join_space(uint64_t ptr, RustBuffer join_id, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CAPTURE_CURRENT_CLIPBOARD +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CAPTURE_CURRENT_CLIPBOARD +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_capture_current_clipboard(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CHANGE_ENCRYPTION_PASSPHRASE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CHANGE_ENCRYPTION_PASSPHRASE +void uniffi_uc_engine_uniffi_fn_method_mobileengine_change_encryption_passphrase(uint64_t ptr, RustBuffer passphrase, RustBuffer passphrase_confirmation, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CHOOSE_DEVICE_GROUP +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CHOOSE_DEVICE_GROUP +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_choose_device_group(uint64_t ptr, RustBuffer issue_id, RustBuffer choice_id, uint64_t expected_revision, int8_t confirm_local_removal, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CREATE_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_CREATE_SPACE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_create_space(uint64_t ptr, RustBuffer device_name, RustBuffer passphrase, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_DELETE_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_DELETE_CUSTOM_RELAY +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_delete_custom_relay(uint64_t ptr, RustBuffer url, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_EDIT_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_EDIT_CUSTOM_RELAY +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_edit_custom_relay(uint64_t ptr, RustBuffer previous_url, RustBuffer url, RustBuffer access_token, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_EXPORT_ENTRY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_EXPORT_ENTRY +void uniffi_uc_engine_uniffi_fn_method_mobileengine_export_entry(uint64_t ptr, RustBuffer entry_id, RustBuffer destination_handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_ISSUE_INVITATION +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_ISSUE_INVITATION +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_issue_invitation(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_JOIN_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_JOIN_SPACE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_join_space(uint64_t ptr, RustBuffer invitation_code, RustBuffer device_name, RustBuffer passphrase, int8_t preserve_unreadable_history, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_LEAVE_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_LEAVE_SPACE +void uniffi_uc_engine_uniffi_fn_method_mobileengine_leave_space(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_LIFECYCLE_STATE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_LIFECYCLE_STATE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_lifecycle_state(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_LIST_DEVICES +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_list_devices(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_NEXT_EVENT +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_NEXT_EVENT +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_next_event(uint64_t ptr, uint64_t timeout_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_NOTIFY_CONNECTIVITY_OPPORTUNITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_NOTIFY_CONNECTIVITY_OPPORTUNITY +void uniffi_uc_engine_uniffi_fn_method_mobileengine_notify_connectivity_opportunity(uint64_t ptr, RustBuffer reason, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_OBSERVE_CLIPBOARD_CHANGE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_OBSERVE_CLIPBOARD_CHANGE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_observe_clipboard_change(uint64_t ptr, int8_t dispatch, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_ACTIVE_CLIPBOARD +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_ACTIVE_CLIPBOARD +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_query_active_clipboard(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_CUSTOM_RELAYS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_CUSTOM_RELAYS +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_query_custom_relays(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_DEVICE_GROUP_CHOICES +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_DEVICE_GROUP_CHOICES +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_query_device_group_choices(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_LOCAL_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_LOCAL_DEVICE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_query_local_device(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_NETWORK_RECOVERY_STATUS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_NETWORK_RECOVERY_STATUS +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_query_network_recovery_status(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_RELAY_OVERVIEW +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_RELAY_OVERVIEW +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_query_relay_overview(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_SPACE_STATE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_QUERY_SPACE_STATE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_query_space_state(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RECOVER_NETWORK +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RECOVER_NETWORK +void uniffi_uc_engine_uniffi_fn_method_mobileengine_recover_network(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RECOVER_SESSION +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RECOVER_SESSION +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_recover_session(uint64_t ptr, int8_t allow_secure_storage_unlock, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_REFRESH_PEER_CONNECTIONS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_REFRESH_PEER_CONNECTIONS +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_refresh_peer_connections(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_REMOVE_MEMBER +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_REMOVE_MEMBER +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_remove_member(uint64_t ptr, RustBuffer device_id, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RESEND_ENTRY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RESEND_ENTRY +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_resend_entry(uint64_t ptr, RustBuffer entry_id, RustBuffer target_devices, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RESTORE_CLIPBOARD +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RESTORE_CLIPBOARD +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_restore_clipboard(uint64_t ptr, RustBuffer entry_id, RustBuffer mode, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RESUME +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_RESUME +void uniffi_uc_engine_uniffi_fn_method_mobileengine_resume(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SAVE_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SAVE_CUSTOM_RELAY +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_save_custom_relay(uint64_t ptr, RustBuffer url, RustBuffer access_token, RustBuffer previous_url, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SEND_FILES +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SEND_FILES +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_send_files(uint64_t ptr, RustBuffer file_handles, RustBuffer target_devices, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SEND_IMAGE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SEND_IMAGE +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_send_image(uint64_t ptr, RustBuffer bytes, RustBuffer mime_type, RustBuffer target_devices, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SEND_TEXT +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SEND_TEXT +RustBuffer uniffi_uc_engine_uniffi_fn_method_mobileengine_send_text(uint64_t ptr, RustBuffer text, RustBuffer target_devices, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SHUTDOWN +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SHUTDOWN +void uniffi_uc_engine_uniffi_fn_method_mobileengine_shutdown(uint64_t ptr, uint64_t deadline_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SUSPEND +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SUSPEND +void uniffi_uc_engine_uniffi_fn_method_mobileengine_suspend(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SUSPEND_WITH_DEADLINE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILEENGINE_SUSPEND_WITH_DEADLINE +void uniffi_uc_engine_uniffi_fn_method_mobileengine_suspend_with_deadline(uint64_t ptr, uint64_t deadline_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_MOBILESTARTUPLIFECYCLE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CLONE_MOBILESTARTUPLIFECYCLE +uint64_t uniffi_uc_engine_uniffi_fn_clone_mobilestartuplifecycle(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_MOBILESTARTUPLIFECYCLE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FREE_MOBILESTARTUPLIFECYCLE +void uniffi_uc_engine_uniffi_fn_free_mobilestartuplifecycle(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILESTARTUPLIFECYCLE_NEW +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_CONSTRUCTOR_MOBILESTARTUPLIFECYCLE_NEW +uint64_t uniffi_uc_engine_uniffi_fn_constructor_mobilestartuplifecycle_new(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILESTARTUPLIFECYCLE_RESUME +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILESTARTUPLIFECYCLE_RESUME +void uniffi_uc_engine_uniffi_fn_method_mobilestartuplifecycle_resume(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND +void uniffi_uc_engine_uniffi_fn_method_mobilestartuplifecycle_suspend(uint64_t ptr, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND_WITH_DEADLINE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND_WITH_DEADLINE +void uniffi_uc_engine_uniffi_fn_method_mobilestartuplifecycle_suspend_with_deadline(uint64_t ptr, uint64_t deadline_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_CORE_VERSION +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_CORE_VERSION +RustBuffer uniffi_uc_engine_uniffi_fn_func_core_version(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_FLUSH_PROCESS_OBSERVABILITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_FLUSH_PROCESS_OBSERVABILITY +RustBuffer uniffi_uc_engine_uniffi_fn_func_flush_process_observability(uint64_t deadline_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_INSTALL_PROCESS_OBSERVABILITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_INSTALL_PROCESS_OBSERVABILITY +RustBuffer uniffi_uc_engine_uniffi_fn_func_install_process_observability(RustBuffer config, uint64_t host, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_QUERY_PROCESS_OBSERVABILITY_HEALTH +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_QUERY_PROCESS_OBSERVABILITY_HEALTH +RustBuffer uniffi_uc_engine_uniffi_fn_func_query_process_observability_health(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_SHUTDOWN_PROCESS_OBSERVABILITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_SHUTDOWN_PROCESS_OBSERVABILITY +RustBuffer uniffi_uc_engine_uniffi_fn_func_shutdown_process_observability(uint64_t deadline_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_PREPARE_LOCAL_DIAGNOSTIC_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_PREPARE_LOCAL_DIAGNOSTIC_EXPORT +RustBuffer uniffi_uc_engine_uniffi_fn_func_prepare_local_diagnostic_export(uint64_t deadline_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_QUERY_LOCAL_DIAGNOSTIC_STATUS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_QUERY_LOCAL_DIAGNOSTIC_STATUS +RustBuffer uniffi_uc_engine_uniffi_fn_func_query_local_diagnostic_status(RustCallStatus *out_status + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_RECORD_HOST_DIAGNOSTIC +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_RECORD_HOST_DIAGNOSTIC +RustBuffer uniffi_uc_engine_uniffi_fn_func_record_host_diagnostic(RustBuffer source, RustBuffer event, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_REGISTER_HOST_DIAGNOSTIC_SOURCE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_REGISTER_HOST_DIAGNOSTIC_SOURCE +void uniffi_uc_engine_uniffi_fn_func_register_host_diagnostic_source(RustBuffer source, RustBuffer capability, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_START_LOCAL_DIAGNOSTIC_CAPTURE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_START_LOCAL_DIAGNOSTIC_CAPTURE +RustBuffer uniffi_uc_engine_uniffi_fn_func_start_local_diagnostic_capture(uint64_t duration_ms, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_STOP_LOCAL_DIAGNOSTIC_CAPTURE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_FN_FUNC_STOP_LOCAL_DIAGNOSTIC_CAPTURE +RustBuffer uniffi_uc_engine_uniffi_fn_func_stop_local_diagnostic_capture(RustBuffer capture_id, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_ALLOC +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_ALLOC +RustBuffer ffi_uc_engine_uniffi_rustbuffer_alloc(uint64_t size, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_FROM_BYTES +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_FROM_BYTES +RustBuffer ffi_uc_engine_uniffi_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_FREE +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_FREE +void ffi_uc_engine_uniffi_rustbuffer_free(RustBuffer buf, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_RESERVE +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUSTBUFFER_RESERVE +RustBuffer ffi_uc_engine_uniffi_rustbuffer_reserve(RustBuffer buf, uint64_t additional, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U8 +void ffi_uc_engine_uniffi_rust_future_poll_u8(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U8 +void ffi_uc_engine_uniffi_rust_future_cancel_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U8 +void ffi_uc_engine_uniffi_rust_future_free_u8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U8 +uint8_t ffi_uc_engine_uniffi_rust_future_complete_u8(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I8 +void ffi_uc_engine_uniffi_rust_future_poll_i8(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I8 +void ffi_uc_engine_uniffi_rust_future_cancel_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I8 +void ffi_uc_engine_uniffi_rust_future_free_i8(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I8 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I8 +int8_t ffi_uc_engine_uniffi_rust_future_complete_i8(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U16 +void ffi_uc_engine_uniffi_rust_future_poll_u16(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U16 +void ffi_uc_engine_uniffi_rust_future_cancel_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U16 +void ffi_uc_engine_uniffi_rust_future_free_u16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U16 +uint16_t ffi_uc_engine_uniffi_rust_future_complete_u16(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I16 +void ffi_uc_engine_uniffi_rust_future_poll_i16(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I16 +void ffi_uc_engine_uniffi_rust_future_cancel_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I16 +void ffi_uc_engine_uniffi_rust_future_free_i16(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I16 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I16 +int16_t ffi_uc_engine_uniffi_rust_future_complete_i16(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U32 +void ffi_uc_engine_uniffi_rust_future_poll_u32(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U32 +void ffi_uc_engine_uniffi_rust_future_cancel_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U32 +void ffi_uc_engine_uniffi_rust_future_free_u32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U32 +uint32_t ffi_uc_engine_uniffi_rust_future_complete_u32(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I32 +void ffi_uc_engine_uniffi_rust_future_poll_i32(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I32 +void ffi_uc_engine_uniffi_rust_future_cancel_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I32 +void ffi_uc_engine_uniffi_rust_future_free_i32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I32 +int32_t ffi_uc_engine_uniffi_rust_future_complete_i32(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_U64 +void ffi_uc_engine_uniffi_rust_future_poll_u64(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_U64 +void ffi_uc_engine_uniffi_rust_future_cancel_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_U64 +void ffi_uc_engine_uniffi_rust_future_free_u64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_U64 +uint64_t ffi_uc_engine_uniffi_rust_future_complete_u64(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_I64 +void ffi_uc_engine_uniffi_rust_future_poll_i64(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_I64 +void ffi_uc_engine_uniffi_rust_future_cancel_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_I64 +void ffi_uc_engine_uniffi_rust_future_free_i64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_I64 +int64_t ffi_uc_engine_uniffi_rust_future_complete_i64(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_F32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_F32 +void ffi_uc_engine_uniffi_rust_future_poll_f32(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_F32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_F32 +void ffi_uc_engine_uniffi_rust_future_cancel_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_F32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_F32 +void ffi_uc_engine_uniffi_rust_future_free_f32(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_F32 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_F32 +float ffi_uc_engine_uniffi_rust_future_complete_f32(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_F64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_F64 +void ffi_uc_engine_uniffi_rust_future_poll_f64(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_F64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_F64 +void ffi_uc_engine_uniffi_rust_future_cancel_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_F64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_F64 +void ffi_uc_engine_uniffi_rust_future_free_f64(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_F64 +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_F64 +double ffi_uc_engine_uniffi_rust_future_complete_f64(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_RUST_BUFFER +void ffi_uc_engine_uniffi_rust_future_poll_rust_buffer(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_RUST_BUFFER +void ffi_uc_engine_uniffi_rust_future_cancel_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_RUST_BUFFER +void ffi_uc_engine_uniffi_rust_future_free_rust_buffer(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_RUST_BUFFER +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_RUST_BUFFER +RustBuffer ffi_uc_engine_uniffi_rust_future_complete_rust_buffer(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_VOID +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_POLL_VOID +void ffi_uc_engine_uniffi_rust_future_poll_void(uint64_t handle, UniffiRustFutureContinuationCallback callback, uint64_t callback_data +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_VOID +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_CANCEL_VOID +void ffi_uc_engine_uniffi_rust_future_cancel_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_VOID +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_FREE_VOID +void ffi_uc_engine_uniffi_rust_future_free_void(uint64_t handle +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_VOID +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_RUST_FUTURE_COMPLETE_VOID +void ffi_uc_engine_uniffi_rust_future_complete_void(uint64_t handle, RustCallStatus *out_status +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_CORE_VERSION +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_CORE_VERSION +uint16_t uniffi_uc_engine_uniffi_checksum_func_core_version(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_FLUSH_PROCESS_OBSERVABILITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_FLUSH_PROCESS_OBSERVABILITY +uint16_t uniffi_uc_engine_uniffi_checksum_func_flush_process_observability(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_INSTALL_PROCESS_OBSERVABILITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_INSTALL_PROCESS_OBSERVABILITY +uint16_t uniffi_uc_engine_uniffi_checksum_func_install_process_observability(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_QUERY_PROCESS_OBSERVABILITY_HEALTH +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_QUERY_PROCESS_OBSERVABILITY_HEALTH +uint16_t uniffi_uc_engine_uniffi_checksum_func_query_process_observability_health(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_SHUTDOWN_PROCESS_OBSERVABILITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_SHUTDOWN_PROCESS_OBSERVABILITY +uint16_t uniffi_uc_engine_uniffi_checksum_func_shutdown_process_observability(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_PREPARE_LOCAL_DIAGNOSTIC_EXPORT +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_PREPARE_LOCAL_DIAGNOSTIC_EXPORT +uint16_t uniffi_uc_engine_uniffi_checksum_func_prepare_local_diagnostic_export(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_QUERY_LOCAL_DIAGNOSTIC_STATUS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_QUERY_LOCAL_DIAGNOSTIC_STATUS +uint16_t uniffi_uc_engine_uniffi_checksum_func_query_local_diagnostic_status(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_RECORD_HOST_DIAGNOSTIC +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_RECORD_HOST_DIAGNOSTIC +uint16_t uniffi_uc_engine_uniffi_checksum_func_record_host_diagnostic(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_REGISTER_HOST_DIAGNOSTIC_SOURCE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_REGISTER_HOST_DIAGNOSTIC_SOURCE +uint16_t uniffi_uc_engine_uniffi_checksum_func_register_host_diagnostic_source(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_START_LOCAL_DIAGNOSTIC_CAPTURE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_START_LOCAL_DIAGNOSTIC_CAPTURE +uint16_t uniffi_uc_engine_uniffi_checksum_func_start_local_diagnostic_capture(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_STOP_LOCAL_DIAGNOSTIC_CAPTURE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_FUNC_STOP_LOCAL_DIAGNOSTIC_CAPTURE +uint16_t uniffi_uc_engine_uniffi_checksum_func_stop_local_diagnostic_capture(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_CAPTURE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_CAPTURE +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_capture(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_IDENTIFY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_IDENTIFY +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_identify(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_GROUP_IDENTIFY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_GROUP_IDENTIFY +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_group_identify(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_ADOPT_SPACE_PERSON +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_ADOPT_SPACE_PERSON +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_adopt_space_person(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_RELEASE_SPACE_PERSON +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_RELEASE_SPACE_PERSON +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_release_space_person(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_CURRENT_SPACE_PERSON_ID +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_CURRENT_SPACE_PERSON_ID +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_current_space_person_id(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_RESET_TELEMETRY_IDENTITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGANALYTICSHOST_RESET_TELEMETRY_IDENTITY +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinganalyticshost_reset_telemetry_identity(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_PRIVATE_DATA_DIRECTORY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_PRIVATE_DATA_DIRECTORY +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_private_data_directory(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_CACHE_DIRECTORY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_CACHE_DIRECTORY +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_cache_directory(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_TEMPORARY_DIRECTORY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_TEMPORARY_DIRECTORY +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_temporary_directory(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_SECURE_STORAGE_GET +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_SECURE_STORAGE_GET +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_get(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_SECURE_STORAGE_SET +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_SECURE_STORAGE_SET +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_set(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_SECURE_STORAGE_DELETE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_SECURE_STORAGE_DELETE +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_secure_storage_delete(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_METADATA +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_METADATA +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_metadata(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_READ_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_READ_CHUNK +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_read_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_WRITE_CHUNK +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_WRITE_CHUNK +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_write_chunk(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_FINISH_WRITE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_FILE_FINISH_WRITE +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_file_finish_write(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_CLIPBOARD_READ +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_CLIPBOARD_READ +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_clipboard_read(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_CLIPBOARD_WRITE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_BINDINGHOST_CLIPBOARD_WRITE +uint16_t uniffi_uc_engine_uniffi_checksum_method_bindinghost_clipboard_write(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_ADD_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_ADD_CUSTOM_RELAY +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_add_custom_relay(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CANCEL_JOIN_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CANCEL_JOIN_SPACE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_cancel_join_space(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CAPTURE_CURRENT_CLIPBOARD +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CAPTURE_CURRENT_CLIPBOARD +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_capture_current_clipboard(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CHANGE_ENCRYPTION_PASSPHRASE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CHANGE_ENCRYPTION_PASSPHRASE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_change_encryption_passphrase(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CHOOSE_DEVICE_GROUP +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CHOOSE_DEVICE_GROUP +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_choose_device_group(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CREATE_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_CREATE_SPACE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_create_space(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_DELETE_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_DELETE_CUSTOM_RELAY +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_delete_custom_relay(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_EDIT_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_EDIT_CUSTOM_RELAY +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_edit_custom_relay(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_EXPORT_ENTRY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_EXPORT_ENTRY +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_export_entry(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_ISSUE_INVITATION +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_ISSUE_INVITATION +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_issue_invitation(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_JOIN_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_JOIN_SPACE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_join_space(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_LEAVE_SPACE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_LEAVE_SPACE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_leave_space(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_LIFECYCLE_STATE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_LIFECYCLE_STATE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_lifecycle_state(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_LIST_DEVICES +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_LIST_DEVICES +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_list_devices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_NEXT_EVENT +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_NEXT_EVENT +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_next_event(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_NOTIFY_CONNECTIVITY_OPPORTUNITY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_NOTIFY_CONNECTIVITY_OPPORTUNITY +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_notify_connectivity_opportunity(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_OBSERVE_CLIPBOARD_CHANGE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_OBSERVE_CLIPBOARD_CHANGE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_observe_clipboard_change(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_ACTIVE_CLIPBOARD +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_ACTIVE_CLIPBOARD +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_active_clipboard(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_CUSTOM_RELAYS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_CUSTOM_RELAYS +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_custom_relays(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_DEVICE_GROUP_CHOICES +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_DEVICE_GROUP_CHOICES +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_device_group_choices(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_LOCAL_DEVICE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_LOCAL_DEVICE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_local_device(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_NETWORK_RECOVERY_STATUS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_NETWORK_RECOVERY_STATUS +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_network_recovery_status(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_RELAY_OVERVIEW +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_RELAY_OVERVIEW +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_relay_overview(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_SPACE_STATE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_QUERY_SPACE_STATE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_query_space_state(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RECOVER_NETWORK +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RECOVER_NETWORK +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_recover_network(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RECOVER_SESSION +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RECOVER_SESSION +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_recover_session(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_REFRESH_PEER_CONNECTIONS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_REFRESH_PEER_CONNECTIONS +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_refresh_peer_connections(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_REMOVE_MEMBER +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_REMOVE_MEMBER +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_remove_member(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RESEND_ENTRY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RESEND_ENTRY +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_resend_entry(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RESTORE_CLIPBOARD +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RESTORE_CLIPBOARD +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_restore_clipboard(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RESUME +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_RESUME +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_resume(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SAVE_CUSTOM_RELAY +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SAVE_CUSTOM_RELAY +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_save_custom_relay(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SEND_FILES +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SEND_FILES +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_files(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SEND_IMAGE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SEND_IMAGE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_image(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SEND_TEXT +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SEND_TEXT +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_send_text(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SHUTDOWN +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SHUTDOWN +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_shutdown(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SUSPEND +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SUSPEND +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_suspend(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SUSPEND_WITH_DEADLINE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILEENGINE_SUSPEND_WITH_DEADLINE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobileengine_suspend_with_deadline(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILESTARTUPLIFECYCLE_RESUME +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILESTARTUPLIFECYCLE_RESUME +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_resume(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_suspend(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND_WITH_DEADLINE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_METHOD_MOBILESTARTUPLIFECYCLE_SUSPEND_WITH_DEADLINE +uint16_t uniffi_uc_engine_uniffi_checksum_method_mobilestartuplifecycle_suspend_with_deadline(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START +uint16_t uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS +uint16_t uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_analytics(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS_AND_LIFECYCLE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START_WITH_ANALYTICS_AND_LIFECYCLE +uint16_t uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_analytics_and_lifecycle(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START_WITH_LIFECYCLE +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILEENGINE_START_WITH_LIFECYCLE +uint16_t uniffi_uc_engine_uniffi_checksum_constructor_mobileengine_start_with_lifecycle(void + +); +#endif +#ifndef UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILESTARTUPLIFECYCLE_NEW +#define UNIFFI_FFIDEF_UNIFFI_UC_ENGINE_UNIFFI_CHECKSUM_CONSTRUCTOR_MOBILESTARTUPLIFECYCLE_NEW +uint16_t uniffi_uc_engine_uniffi_checksum_constructor_mobilestartuplifecycle_new(void + +); +#endif +#ifndef UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_UNIFFI_CONTRACT_VERSION +#define UNIFFI_FFIDEF_FFI_UC_ENGINE_UNIFFI_UNIFFI_CONTRACT_VERSION +uint32_t ffi_uc_engine_uniffi_uniffi_contract_version(void + +); +#endif + + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod0(uint64_t uniffi_handle, RustBuffer event, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod1(uint64_t uniffi_handle, RustBuffer payload, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod2(uint64_t uniffi_handle, RustBuffer payload, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod3(uint64_t uniffi_handle, RustBuffer space_person_id, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod4(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod5(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostMethod6(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostFree(uint64_t handle); +uint64_t uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingAnalyticsHostClone(uint64_t handle); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod0(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod1(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod2(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod3(uint64_t uniffi_handle, RustBuffer key, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod4(uint64_t uniffi_handle, RustBuffer key, RustBuffer value, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod5(uint64_t uniffi_handle, RustBuffer key, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod6(uint64_t uniffi_handle, RustBuffer handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod7(uint64_t uniffi_handle, RustBuffer handle, uint64_t offset, uint32_t max_bytes, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod8(uint64_t uniffi_handle, RustBuffer handle, uint64_t offset, RustBuffer bytes, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod9(uint64_t uniffi_handle, RustBuffer handle, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod10(uint64_t uniffi_handle, RustBuffer* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostMethod11(uint64_t uniffi_handle, RustBuffer snapshot, void* uniffi_out_return, RustCallStatus* callStatus ); + void uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostFree(uint64_t handle); +uint64_t uc_engine_uniffi_cgo_dispatchCallbackInterfaceBindingHostClone(uint64_t handle); diff --git a/tests/hosts/go/go.mod b/tests/hosts/go/go.mod new file mode 100644 index 00000000..7106812f --- /dev/null +++ b/tests/hosts/go/go.mod @@ -0,0 +1,7 @@ +module github.com/UniClipboard/Engine/tests/hosts/go + +go 1.24.0 + +require github.com/UniClipboard/Engine/bindings/go v0.0.0 + +replace github.com/UniClipboard/Engine/bindings/go => ../../../bindings/go diff --git a/tests/hosts/go/host.go b/tests/hosts/go/host.go new file mode 100644 index 00000000..a83ca794 --- /dev/null +++ b/tests/hosts/go/host.go @@ -0,0 +1,108 @@ +package main + +import ( + "crypto/sha256" + "encoding/hex" + "errors" + "os" + "path/filepath" + "sync" + "sync/atomic" + + "github.com/UniClipboard/Engine/bindings/go/engine" +) + +// fileHost 是验收用的隔离宿主:目录与安全存储都在一个临时根目录内, +// 安全存储以文件持久化,使第二个进程可以在同一 profile 上重启。 +// 它不接触真实 profile、钥匙串、剪贴板或网络。 +type fileHost struct { + root string + + privateCalls atomic.Int64 + cacheCalls atomic.Int64 + tempCalls atomic.Int64 + getCalls atomic.Int64 + setCalls atomic.Int64 + deleteCalls atomic.Int64 + + mu sync.Mutex + storedKeys map[string]bool + // failSet 非空时,安全存储写入返回该错误,用于验证宿主错误往返。 + failSet error + // secrets 记录 Rust 写入的全部密文字节,供日志扫描使用。 + secrets [][]byte +} + +func newFileHost(root string) (*fileHost, error) { + for _, dir := range []string{"private", "cache", "temp", "secure"} { + if err := os.MkdirAll(filepath.Join(root, dir), 0o700); err != nil { + return nil, err + } + } + return &fileHost{root: root, storedKeys: map[string]bool{}}, nil +} + +func (h *fileHost) PrivateDataDirectory() (string, error) { + h.privateCalls.Add(1) + return filepath.Join(h.root, "private"), nil +} + +func (h *fileHost) CacheDirectory() (string, error) { + h.cacheCalls.Add(1) + return filepath.Join(h.root, "cache"), nil +} + +func (h *fileHost) TemporaryDirectory() (string, error) { + h.tempCalls.Add(1) + return filepath.Join(h.root, "temp"), nil +} + +func (h *fileHost) securePath(key string) string { + sum := sha256.Sum256([]byte(key)) + return filepath.Join(h.root, "secure", hex.EncodeToString(sum[:])) +} + +func (h *fileHost) SecureStorageGet(key string) ([]byte, error) { + h.getCalls.Add(1) + value, err := os.ReadFile(h.securePath(key)) + if errors.Is(err, os.ErrNotExist) { + return nil, nil + } + if err != nil { + return nil, engine.ErrHostIO + } + return value, nil +} + +func (h *fileHost) SecureStorageSet(key string, value []byte) error { + h.setCalls.Add(1) + h.mu.Lock() + defer h.mu.Unlock() + if h.failSet != nil { + return h.failSet + } + if err := os.WriteFile(h.securePath(key), value, 0o600); err != nil { + return engine.ErrHostIO + } + h.secrets = append(h.secrets, append([]byte(nil), value...)) + return nil +} + +func (h *fileHost) SecureStorageDelete(key string) error { + h.deleteCalls.Add(1) + if err := os.Remove(h.securePath(key)); err != nil && !errors.Is(err, os.ErrNotExist) { + return engine.ErrHostIO + } + return nil +} + +func (h *fileHost) counters() map[string]int64 { + return map[string]int64{ + "private_data_directory": h.privateCalls.Load(), + "cache_directory": h.cacheCalls.Load(), + "temporary_directory": h.tempCalls.Load(), + "secure_storage_get": h.getCalls.Load(), + "secure_storage_set": h.setCalls.Load(), + "secure_storage_delete": h.deleteCalls.Load(), + } +} diff --git a/tests/hosts/go/lifecycle.go b/tests/hosts/go/lifecycle.go new file mode 100644 index 00000000..049fa4f4 --- /dev/null +++ b/tests/hosts/go/lifecycle.go @@ -0,0 +1,124 @@ +package main + +import ( + "context" + "errors" + "os" + "path/filepath" + "time" + + "github.com/UniClipboard/Engine/bindings/go/engine" +) + +const stepTimeout = 30 * time.Second + +func openEngine(host *fileHost, manifest string) (*engine.Engine, error) { + return engine.Open(engine.Config{ + AppVersion: appVersion, + ProfileID: profileID, + NativeManifest: manifest, + }, host) +} + +// drainStates 读取事件直到出现期望状态或超时,返回观察到的状态序列。 +func drainStates(eng *engine.Engine, want engine.State) ([]engine.State, bool) { + ctx, cancel := context.WithTimeout(context.Background(), stepTimeout) + defer cancel() + var seen []engine.State + for { + event, err := eng.NextEvent(ctx) + if err != nil { + return seen, false + } + if changed, ok := event.(engine.StateChanged); ok { + seen = append(seen, changed.State) + if changed.State == want { + return seen, true + } + } + } +} + +func runLifecycle(result *report, root, manifest string) { + host, err := newFileHost(root) + if err != nil || !result.record("host_ready", err == nil, nil) { + return + } + if err := installObservability(host, appVersion); !result.record("observability_local_only", err == nil, errString(err)) { + return + } + eng, err := openEngine(host, manifest) + if !result.record("open_after_native_verify", err == nil, errString(err)) { + return + } + ctx, cancel := context.WithTimeout(context.Background(), stepTimeout) + defer cancel() + + device, err := eng.LocalDevice(ctx) + if !result.record("query_local_device", err == nil && device.DeviceID != "", errString(err)) { + return + } + space, err := eng.SpaceState(ctx) + result.record("query_space_state_fresh_profile", err == nil && !space.HasCompleted, map[string]any{"has_completed": space.HasCompleted}) + + leaveErr := eng.LeaveSpace(ctx) + var typed *engine.EngineError + if errors.As(leaveErr, &typed) { + result.record("typed_engine_error", true, map[string]any{"code": typed.Code, "category": typed.Category, "retryable": typed.Retryable}) + } else { + result.record("typed_engine_error", false, errString(leaveErr)) + } + + counters := host.counters() + result.record("host_callbacks_succeeded", counters["private_data_directory"] > 0 && counters["secure_storage_get"] > 0 && counters["secure_storage_set"] > 0, counters) + + suspendErr := eng.Suspend(ctx) + _, suspended := drainStates(eng, engine.StateSuspended) + result.record("suspend_emits_state_changed", suspendErr == nil && suspended, errString(suspendErr)) + resumeErr := eng.Resume(ctx) + _, running := drainStates(eng, engine.StateRunning) + result.record("resume_emits_state_changed", resumeErr == nil && running, errString(resumeErr)) + + closeErr := eng.Close(15 * time.Second) + result.record("shutdown_with_deadline_and_join", closeErr == nil, errString(closeErr)) + _, afterErr := eng.LocalDevice(ctx) + result.record("call_after_close_is_rejected", errors.Is(afterErr, engine.ErrClosed), errString(afterErr)) + result.record("close_is_idempotent", eng.Close(time.Second) == nil, nil) + + state, _ := marshalJSON(map[string]string{"device_id": device.DeviceID}) + if err := os.WriteFile(filepath.Join(root, "device.json"), state, 0o600); err != nil { + result.record("persist_device_identity", false, errString(err)) + } + hits, scanErr := scanForLeaks(root, []string{profileID}, host.secrets) + result.record("no_secret_in_logs_or_profile", scanErr == nil && len(hits) == 0, map[string]any{"hits": hits}) +} + +func runRestart(result *report, root, manifest string) { + host, err := newFileHost(root) + if err != nil || !result.record("host_ready", err == nil, nil) { + return + } + previous, err := os.ReadFile(filepath.Join(root, "device.json")) + if !result.record("previous_identity_present", err == nil, errString(err)) { + return + } + eng, err := openEngine(host, manifest) + if !result.record("reopen_same_profile", err == nil, errString(err)) { + return + } + ctx, cancel := context.WithTimeout(context.Background(), stepTimeout) + defer cancel() + device, err := eng.LocalDevice(ctx) + expected, _ := marshalJSON(map[string]string{"device_id": device.DeviceID}) + result.record("same_device_identity_after_restart", err == nil && string(expected) == string(previous), errString(err)) + result.record("close_after_restart", eng.Close(15*time.Second) == nil, nil) + hits, scanErr := scanForLeaks(root, []string{profileID}, host.secrets) + result.record("no_secret_in_logs_or_profile", scanErr == nil && len(hits) == 0, map[string]any{"hits": hits}) +} + +func errString(err error) any { + if err == nil { + return nil + } + return err.Error() +} diff --git a/tests/hosts/go/main.go b/tests/hosts/go/main.go new file mode 100644 index 00000000..165dba42 --- /dev/null +++ b/tests/hosts/go/main.go @@ -0,0 +1,71 @@ +// 命令 go-engine-host 是 Go 绑定的真实进程验收宿主,不承载产品功能。 +// +// go-engine-host --phase lifecycle|restart|negative --root <隔离目录> --manifest +// +// 每个阶段是一次独立进程:向 stdout 输出一个 JSON 结果,任一步失败则退出码为 1。 +// 隔离目录之外不读写任何文件;网络隔离由外部驱动脚本(沙箱)保证。 +package main + +import ( + "encoding/json" + "flag" + "fmt" + "os" +) + +const ( + appVersion = "go-binding-acceptance" + profileID = "go-binding-sentinel-profile" +) + +type step struct { + Name string `json:"name"` + OK bool `json:"ok"` + Detail any `json:"detail,omitempty"` +} + +type report struct { + Phase string `json:"phase"` + Steps []step `json:"steps"` + OK bool `json:"ok"` +} + +func (r *report) record(name string, ok bool, detail any) bool { + r.Steps = append(r.Steps, step{Name: name, OK: ok, Detail: detail}) + return ok +} + +func main() { + phase := flag.String("phase", "", "lifecycle, restart or negative") + root := flag.String("root", "", "isolated root directory") + manifest := flag.String("manifest", "", "native-manifest.json path") + flag.Parse() + if *phase == "" || *root == "" || *manifest == "" { + fmt.Fprintln(os.Stderr, "usage: go-engine-host --phase P --root DIR --manifest FILE") + os.Exit(2) + } + result := &report{Phase: *phase} + switch *phase { + case "lifecycle": + runLifecycle(result, *root, *manifest) + case "restart": + runRestart(result, *root, *manifest) + case "negative": + runNegative(result, *root, *manifest) + default: + fmt.Fprintln(os.Stderr, "unknown phase") + os.Exit(2) + } + result.OK = true + for _, s := range result.Steps { + result.OK = result.OK && s.OK + } + encoded, err := json.MarshalIndent(result, "", " ") + if err != nil { + os.Exit(2) + } + fmt.Println(string(encoded)) + if !result.OK { + os.Exit(1) + } +} diff --git a/tests/hosts/go/negative.go b/tests/hosts/go/negative.go new file mode 100644 index 00000000..bb705e0c --- /dev/null +++ b/tests/hosts/go/negative.go @@ -0,0 +1,146 @@ +package main + +import ( + "context" + "errors" + "os" + "path/filepath" + "sync" + "time" + + "github.com/UniClipboard/Engine/bindings/go/engine" + "github.com/UniClipboard/Engine/bindings/go/native" +) + +func runNegative(result *report, root, manifest string) { + // 输入校验:零值枚举与空配置在进入 Rust 之前被拒绝。 + _, err := engine.Open(engine.Config{}, nil) + result.record("open_rejects_empty_config", errors.Is(err, engine.ErrInvalidInput), errString(err)) + + // 清单缺失、哈希被篡改:Open 必须拒绝,且不启动 Engine。 + missing := filepath.Join(root, "absent-manifest.json") + host, err := newFileHost(root) + if err != nil { + result.record("host_ready", false, errString(err)) + return + } + _, err = openEngine(host, missing) + result.record("open_rejects_missing_manifest", errors.Is(err, native.ErrMismatch), errString(err)) + tampered, err := tamperedManifest(manifest, root) + if err == nil { + _, err = openEngine(host, tampered) + } + result.record("open_rejects_digest_mismatch", errors.Is(err, native.ErrMismatch), errString(err)) + result.record("no_engine_started_by_rejected_open", host.counters()["private_data_directory"] == 0, host.counters()) + + // 宿主错误往返:安全存储写入被拒绝,Open 返回同一稳定分类。 + failing, _ := newFileHost(filepath.Join(root, "failing")) + failing.failSet = engine.ErrHostPermissionDenied + _, err = openEngine(failing, manifest) + result.record("host_error_roundtrip", errors.Is(err, engine.ErrHostPermissionDenied), errString(err)) + + eng, err := openEngine(host, manifest) + if !result.record("open_for_negative_checks", err == nil, errString(err)) { + return + } + ctx := context.Background() + result.record("zero_enum_rejected_before_rust", errors.Is(eng.NotifyConnectivityOpportunity(ctx, 0), engine.ErrInvalidInput), nil) + result.record("out_of_range_enum_rejected", errors.Is(eng.NotifyConnectivityOpportunity(ctx, 99), engine.ErrInvalidInput), nil) + result.record("valid_enum_accepted", eng.NotifyConnectivityOpportunity(ctx, engine.OpportunityNetworkChanged) == nil, nil) + + // context 取消只停止等待:Engine 之后仍可用。 + short, cancel := context.WithTimeout(ctx, 300*time.Millisecond) + _, err = eng.NextEvent(short) + cancel() + result.record("context_deadline_stops_waiting", errors.Is(err, context.DeadlineExceeded), errString(err)) + _, err = eng.LocalDevice(ctx) + result.record("engine_usable_after_context_deadline", err == nil, errString(err)) + + // 并发调用与 Close:全部调用得到结果或 ErrClosed,没有 panic,Close 在期限内完成。 + var wg sync.WaitGroup + var mu sync.Mutex + outcomes := map[string]int{} + for i := 0; i < 32; i++ { + wg.Add(1) + go func(i int) { + defer wg.Done() + defer func() { + if recover() != nil { + mu.Lock() + outcomes["panic"]++ + mu.Unlock() + } + }() + for j := 0; j < 50; j++ { + var err error + if i%4 == 0 { + short, cancel := context.WithTimeout(ctx, 100*time.Millisecond) + _, err = eng.NextEvent(short) + cancel() + if errors.Is(err, context.DeadlineExceeded) { + err = nil + } + } else { + _, err = eng.LocalDevice(ctx) + } + mu.Lock() + switch { + case err == nil: + outcomes["ok"]++ + case errors.Is(err, engine.ErrClosed): + outcomes["closed"]++ + default: + outcomes["other:"+err.Error()]++ + } + mu.Unlock() + if errors.Is(err, engine.ErrClosed) { + return + } + } + }(i) + } + time.Sleep(150 * time.Millisecond) + started := time.Now() + closeErr := eng.Close(20 * time.Second) + closeTook := time.Since(started) + wg.Wait() + mu.Lock() + clean := outcomes["panic"] == 0 + for key := range outcomes { + if len(key) > 6 && key[:6] == "other:" { + clean = false + } + } + snapshot := map[string]any{"outcomes": outcomes, "close_ms": closeTook.Milliseconds()} + mu.Unlock() + result.record("concurrent_calls_with_close", closeErr == nil && clean, snapshot) + _, err = eng.NextEvent(ctx) + result.record("next_event_after_close_is_rejected", errors.Is(err, engine.ErrClosed), errString(err)) + + hits, scanErr := scanForLeaks(root, []string{profileID}, host.secrets) + result.record("no_secret_in_logs_or_profile", scanErr == nil && len(hits) == 0, map[string]any{"hits": hits}) +} + +// tamperedManifest 复制清单并改动库摘要,验证 Verify 逐项比对而不是只检查存在。 +func tamperedManifest(path, root string) (string, error) { + data, err := os.ReadFile(path) + if err != nil { + return "", err + } + var parsed map[string]any + if err := unmarshalJSON(data, &parsed); err != nil { + return "", err + } + library := parsed["library"].(map[string]any) + digest := library["sha256"].(string) + library["sha256"] = "0" + digest[1:] + if digest[0] == '0' { + library["sha256"] = "1" + digest[1:] + } + out, err := marshalJSON(parsed) + if err != nil { + return "", err + } + target := filepath.Join(root, "tampered-manifest.json") + return target, os.WriteFile(target, out, 0o600) +} diff --git a/tests/hosts/go/observability.go b/tests/hosts/go/observability.go new file mode 100644 index 00000000..69fa907e --- /dev/null +++ b/tests/hosts/go/observability.go @@ -0,0 +1,108 @@ +package main + +import ( + "bytes" + "encoding/base64" + "encoding/hex" + "os" + "path/filepath" + + ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" +) + +// ffiHost 把 fileHost 暴露为生成层的完整宿主接口,仅用于安装进程级观测: +// 本地文件观测写入隔离根目录,远端导出关闭。门面本身不开放观测安装,验收宿主 +// 直接使用生成层以取得 Rust 侧的原始日志。 +type ffiHost struct{ *fileHost } + +func (h ffiHost) SecureStorageGet(key string) (*[]byte, error) { + value, err := h.fileHost.SecureStorageGet(key) + if err != nil || value == nil { + return nil, err + } + return &value, nil +} + +func (ffiHost) FileMetadata(string) (ffi.BindingFileMetadata, error) { + return ffi.BindingFileMetadata{}, ffi.NewHostBindingErrorUnavailable() +} + +func (ffiHost) FileReadChunk(string, uint64, uint32) ([]byte, error) { + return nil, ffi.NewHostBindingErrorUnavailable() +} + +func (ffiHost) FileWriteChunk(string, uint64, []byte) error { + return ffi.NewHostBindingErrorUnavailable() +} + +func (ffiHost) FileFinishWrite(string) error { return ffi.NewHostBindingErrorUnavailable() } + +func (ffiHost) ClipboardRead() (ffi.BindingClipboardSnapshot, error) { + return ffi.BindingClipboardSnapshot{}, ffi.NewHostBindingErrorUnavailable() +} + +func (ffiHost) ClipboardWrite(ffi.BindingClipboardSnapshot) error { + return ffi.NewHostBindingErrorUnavailable() +} + +func installObservability(host *fileHost, version string) error { + _, err := ffi.InstallProcessObservability(ffi.BindingObservabilityConfig{ + ServiceVersion: version, + Environment: ffi.BindingDeploymentEnvironmentTest, + AppChannel: "go-binding-acceptance", + RemoteDiagnosticsEnabled: false, + Collector: nil, + }, ffiHost{host}) + return err +} + +// scanForLeaks 在隔离根目录的全部文件(Rust 写入的观测日志等,不含安全存储本身)中查找哨兵与密钥字节 +// 的原文、hex、base64 形式,返回命中的文件相对路径与种类;不输出命中的内容。 +func scanForLeaks(root string, sentinels []string, secrets [][]byte) ([]string, error) { + var needles []struct { + kind string + data []byte + } + for _, sentinel := range sentinels { + needles = append(needles, struct { + kind string + data []byte + }{"sentinel", []byte(sentinel)}) + } + for _, secret := range secrets { + if len(secret) < 8 { + continue + } + for kind, data := range map[string][]byte{ + "secret-raw": secret, + "secret-hex": []byte(hex.EncodeToString(secret)), + "secret-base64": []byte(base64.StdEncoding.EncodeToString(secret)), + } { + needles = append(needles, struct { + kind string + data []byte + }{kind, data}) + } + } + var hits []string + err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + if err != nil || info.IsDir() { + return err + } + rel, _ := filepath.Rel(root, path) + if filepath.Dir(rel) == "secure" { + return nil + } + content, err := os.ReadFile(path) + if err != nil { + return err + } + for _, needle := range needles { + if bytes.Contains(content, needle.data) { + hits = append(hits, rel+":"+needle.kind) + } + } + return nil + }) + return hits, err +} diff --git a/tests/hosts/go/util.go b/tests/hosts/go/util.go new file mode 100644 index 00000000..064478ad --- /dev/null +++ b/tests/hosts/go/util.go @@ -0,0 +1,7 @@ +package main + +import "encoding/json" + +func marshalJSON(value any) ([]byte, error) { return json.Marshal(value) } + +func unmarshalJSON(data []byte, target any) error { return json.Unmarshal(data, target) } From a0bae5a2915081bddcfa5fafbbade0186b1c8a0d Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:10:50 -0700 Subject: [PATCH 03/13] test(go-binding): isolate network by loopback sandbox, fix host inputs --- bindings/go/engine/engine.go | 18 +++++ tests/hosts/go/lifecycle.go | 4 +- tests/hosts/go/main.go | 2 +- tests/hosts/go/observability.go | 11 ++- tests/hosts/go/run-e2e.mjs | 132 ++++++++++++++++++++++++++++++++ 5 files changed, 161 insertions(+), 6 deletions(-) create mode 100644 tests/hosts/go/run-e2e.mjs diff --git a/bindings/go/engine/engine.go b/bindings/go/engine/engine.go index 925aa77e..92890924 100644 --- a/bindings/go/engine/engine.go +++ b/bindings/go/engine/engine.go @@ -183,6 +183,24 @@ func (e *Engine) Devices(ctx context.Context) ([]Device, error) { }) } +// Invitation 是一次性邀请。内容属于敏感信息:String 与 GoString 固定脱敏,调用方不得记录其字段。 +type Invitation struct { + Code string + Full string + ExpiresAtMs int64 +} + +func (Invitation) String() string { return "Invitation(REDACTED)" } +func (Invitation) GoString() string { return "Invitation(REDACTED)" } + +// IssueInvitation 为当前空间签发邀请;没有可邀请的空间时返回 EngineError。 +func (e *Engine) IssueInvitation(ctx context.Context) (Invitation, error) { + return call(ctx, e, func(inner *ffi.MobileEngine) (Invitation, error) { + issued, err := inner.IssueInvitation() + return Invitation{Code: issued.InvitationCode, Full: issued.FullInvitation, ExpiresAtMs: issued.ExpiresAtMs}, err + }) +} + // LeaveSpace 退出当前空间;没有可退出的空间时返回 EngineError。 func (e *Engine) LeaveSpace(ctx context.Context) error { _, err := call(ctx, e, func(inner *ffi.MobileEngine) (struct{}, error) { diff --git a/tests/hosts/go/lifecycle.go b/tests/hosts/go/lifecycle.go index 049fa4f4..40f12fe6 100644 --- a/tests/hosts/go/lifecycle.go +++ b/tests/hosts/go/lifecycle.go @@ -44,7 +44,7 @@ func runLifecycle(result *report, root, manifest string) { if err != nil || !result.record("host_ready", err == nil, nil) { return } - if err := installObservability(host, appVersion); !result.record("observability_local_only", err == nil, errString(err)) { + if err := installObservability(host, "0.0.1"); !result.record("observability_local_only", err == nil, errString(err)) { return } eng, err := openEngine(host, manifest) @@ -61,7 +61,7 @@ func runLifecycle(result *report, root, manifest string) { space, err := eng.SpaceState(ctx) result.record("query_space_state_fresh_profile", err == nil && !space.HasCompleted, map[string]any{"has_completed": space.HasCompleted}) - leaveErr := eng.LeaveSpace(ctx) + _, leaveErr := eng.IssueInvitation(ctx) var typed *engine.EngineError if errors.As(leaveErr, &typed) { result.record("typed_engine_error", true, map[string]any{"code": typed.Code, "category": typed.Category, "retryable": typed.Retryable}) diff --git a/tests/hosts/go/main.go b/tests/hosts/go/main.go index 165dba42..cf3c6a6d 100644 --- a/tests/hosts/go/main.go +++ b/tests/hosts/go/main.go @@ -14,7 +14,7 @@ import ( ) const ( - appVersion = "go-binding-acceptance" + appVersion = "1.1.0-rc.22" profileID = "go-binding-sentinel-profile" ) diff --git a/tests/hosts/go/observability.go b/tests/hosts/go/observability.go index 69fa907e..5fd9d91f 100644 --- a/tests/hosts/go/observability.go +++ b/tests/hosts/go/observability.go @@ -49,15 +49,16 @@ func installObservability(host *fileHost, version string) error { _, err := ffi.InstallProcessObservability(ffi.BindingObservabilityConfig{ ServiceVersion: version, Environment: ffi.BindingDeploymentEnvironmentTest, - AppChannel: "go-binding-acceptance", + AppChannel: "test", RemoteDiagnosticsEnabled: false, Collector: nil, }, ffiHost{host}) return err } -// scanForLeaks 在隔离根目录的全部文件(Rust 写入的观测日志等,不含安全存储本身)中查找哨兵与密钥字节 -// 的原文、hex、base64 形式,返回命中的文件相对路径与种类;不输出命中的内容。 +// scanForLeaks 查找泄露并返回命中的文件相对路径与种类,不输出命中的内容: +// - 密钥字节的原文、hex、base64 形式:扫描隔离根目录的全部文件(观测日志、profile 数据库等),不含安全存储本身; +// - 哨兵字符串:只扫描观测日志目录,profile 标识属于存储结构,不是日志可携带的内容。 func scanForLeaks(root string, sentinels []string, secrets [][]byte) ([]string, error) { var needles []struct { kind string @@ -97,7 +98,11 @@ func scanForLeaks(root string, sentinels []string, secrets [][]byte) ([]string, if err != nil { return err } + inLogs := strings.HasPrefix(rel, filepath.Join("cache", "logs")+string(filepath.Separator)) for _, needle := range needles { + if needle.kind == "sentinel" && !inLogs { + continue + } if bytes.Contains(content, needle.data) { hits = append(hits, rel+":"+needle.kind) } diff --git a/tests/hosts/go/run-e2e.mjs b/tests/hosts/go/run-e2e.mjs new file mode 100644 index 00000000..973ca350 --- /dev/null +++ b/tests/hosts/go/run-e2e.mjs @@ -0,0 +1,132 @@ +// Go 绑定真实进程验收驱动。 +// +// node tests/hosts/go/run-e2e.mjs --native --evidence <新的证据目录> [--go ] +// +// 在 macOS 沙箱(拒绝全部网络)内依次运行三个独立进程:lifecycle(启动→查询→类型化错误→宿主回调→事件→ +// 关闭)、restart(同一 profile 重启并核对身份)、negative(输入校验、清单错配、并发关闭等)。 +// 证据目录保存每个命令、退出码、原始 stdout/stderr、工具版本、清单与产物哈希;任一阶段失败则退出码非 0。 +// 只读写 --evidence 与其下的隔离根目录,不触碰真实 profile、钥匙串、剪贴板或网络。 +import { spawnSync } from 'node:child_process' +import { createHash } from 'node:crypto' +import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs' +import { join, resolve } from 'node:path' + +const options = new Map() +for (let index = 2; index < process.argv.length; index += 2) { + options.set(process.argv[index], process.argv[index + 1]) +} +const native = resolve(options.get('--native') ?? '') +const evidence = resolve(options.get('--evidence') ?? '') +const go = options.get('--go') ?? 'go' +if (!options.has('--native') || !options.has('--evidence')) { + console.error('usage: run-e2e.mjs --native DIR --evidence DIR [--go PATH]') + process.exit(2) +} +if (process.platform !== 'darwin') { + console.error('network isolation uses sandbox-exec and is only implemented for macOS') + process.exit(2) +} +if (existsSync(evidence) && readdirSync(evidence).length > 0) { + console.error(`evidence directory must be empty: ${evidence}`) + process.exit(2) +} +mkdirSync(evidence, { recursive: true, mode: 0o700 }) + +const hostDir = resolve(import.meta.dirname) +const manifestPath = join(native, 'native-manifest.json') +const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) +const sha256 = (path) => createHash('sha256').update(readFileSync(path)).digest('hex') +const commands = [] + +function run(name, command, args, extra = {}) { + const started = Date.now() + const result = spawnSync(command, args, { + encoding: 'utf8', + timeout: extra.timeoutMs ?? 180_000, + cwd: extra.cwd, + env: { ...process.env, ...(extra.env ?? {}) }, + maxBuffer: 64 * 1024 * 1024, + }) + writeFileSync(join(evidence, `${name}.stdout`), result.stdout ?? '') + writeFileSync(join(evidence, `${name}.stderr`), result.stderr ?? '') + const record = { + name, + command: [command, ...args], + exit: result.status, + signal: result.signal, + timed_out: result.error?.code === 'ETIMEDOUT', + duration_ms: Date.now() - started, + } + commands.push(record) + return { ...record, stdout: result.stdout ?? '', stderr: result.stderr ?? '' } +} + +const toolVersions = { + go: run('tool-go-version', go, ['version']).stdout.trim(), + node: process.version, + host: run('tool-uname', 'uname', ['-srm']).stdout.trim(), +} + +// 构建验收宿主:动态库经 -L 与 rpath 提供,loader 路径由命令显式给出而不是依赖开发者 shell。 +const binary = join(evidence, 'go-engine-host') +const build = run('go-build', go, ['build', '-o', binary, '.'], { + cwd: hostDir, + env: { CGO_ENABLED: '1', CGO_LDFLAGS: `-L${native} -Wl,-rpath,${native}` }, +}) + +// 启动会绑定本机 P2P 套接字,因此允许 bind 与回环;其余入站/出站(含 DNS、中继、局域网发现)一律拒绝。 +const sandboxProfile = [ + '(version 1)(allow default)(deny network*)', + '(allow network-bind)', + '(allow network* (local ip "localhost:*") (remote ip "localhost:*"))', +].join('') +const sandboxed = (name, args, extra) => + run(name, '/usr/bin/sandbox-exec', ['-p', sandboxProfile, ...args], extra) + +// 控制实验:同一沙箱下真实网络访问必须失败,否则“离线”不成立。 +const control = sandboxed('network-control', ['/usr/bin/curl', '-sS', '--max-time', '5', 'https://example.com/'], { + timeoutMs: 20_000, +}) +const networkDenied = control.exit !== 0 + +const phases = [] +if (build.exit === 0 && networkDenied) { + const root = join(evidence, 'root') + const negativeRoot = join(evidence, 'root-negative') + mkdirSync(root, { recursive: true, mode: 0o700 }) + mkdirSync(negativeRoot, { recursive: true, mode: 0o700 }) + for (const [phase, phaseRoot] of [ + ['lifecycle', root], + ['restart', root], + ['negative', negativeRoot], + ]) { + const result = sandboxed(`phase-${phase}`, [binary, '--phase', phase, '--root', phaseRoot, '--manifest', manifestPath]) + let parsed = null + try { + parsed = JSON.parse(result.stdout) + } catch { + parsed = null + } + phases.push({ phase, exit: result.exit, ok: result.exit === 0 && parsed?.ok === true, report: parsed }) + if (result.exit !== 0 && phase === 'lifecycle') break + } +} + +const allOk = + build.exit === 0 && networkDenied && phases.length === 3 && phases.every((phase) => phase.ok) +const summary = { + ok: allOk, + network_isolation: { mechanism: 'sandbox-exec (deny network*; allow bind and loopback only)', profile: sandboxProfile, control_exit: control.exit, denied: networkDenied }, + tools: toolVersions, + native: { + manifest: manifest, + manifest_sha256: sha256(manifestPath), + library_sha256_on_disk: sha256(join(native, manifest.library.file)), + }, + host_binary_sha256: existsSync(binary) ? sha256(binary) : null, + phases, + commands, +} +writeFileSync(join(evidence, 'e2e-result.json'), `${JSON.stringify(summary, null, 2)}\n`) +console.log(JSON.stringify({ ok: allOk, evidence }, null, 2)) +process.exit(allOk ? 0 : 1) From d96b3e558e8c2d5bf894692c207fbae9bfb56a78 Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:12:58 -0700 Subject: [PATCH 04/13] test(go-binding): meaningful concurrent close and host error checks --- tests/hosts/go/host.go | 11 +++++++++++ tests/hosts/go/lifecycle.go | 3 ++- tests/hosts/go/negative.go | 31 +++++++++++++++++++++++++------ tests/hosts/go/observability.go | 1 + 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/tests/hosts/go/host.go b/tests/hosts/go/host.go index a83ca794..64a66cd5 100644 --- a/tests/hosts/go/host.go +++ b/tests/hosts/go/host.go @@ -29,6 +29,8 @@ type fileHost struct { storedKeys map[string]bool // failSet 非空时,安全存储写入返回该错误,用于验证宿主错误往返。 failSet error + // failDirectory 非空时,三个目录能力返回该错误。 + failDirectory error // secrets 记录 Rust 写入的全部密文字节,供日志扫描使用。 secrets [][]byte } @@ -43,16 +45,25 @@ func newFileHost(root string) (*fileHost, error) { } func (h *fileHost) PrivateDataDirectory() (string, error) { + if h.failDirectory != nil { + return "", h.failDirectory + } h.privateCalls.Add(1) return filepath.Join(h.root, "private"), nil } func (h *fileHost) CacheDirectory() (string, error) { + if h.failDirectory != nil { + return "", h.failDirectory + } h.cacheCalls.Add(1) return filepath.Join(h.root, "cache"), nil } func (h *fileHost) TemporaryDirectory() (string, error) { + if h.failDirectory != nil { + return "", h.failDirectory + } h.tempCalls.Add(1) return filepath.Join(h.root, "temp"), nil } diff --git a/tests/hosts/go/lifecycle.go b/tests/hosts/go/lifecycle.go index 40f12fe6..a60365ac 100644 --- a/tests/hosts/go/lifecycle.go +++ b/tests/hosts/go/lifecycle.go @@ -79,8 +79,9 @@ func runLifecycle(result *report, root, manifest string) { _, running := drainStates(eng, engine.StateRunning) result.record("resume_emits_state_changed", resumeErr == nil && running, errString(resumeErr)) + closeStarted := time.Now() closeErr := eng.Close(15 * time.Second) - result.record("shutdown_with_deadline_and_join", closeErr == nil, errString(closeErr)) + result.record("shutdown_with_deadline_and_join", closeErr == nil, map[string]any{"error": errString(closeErr), "close_ms": time.Since(closeStarted).Milliseconds()}) _, afterErr := eng.LocalDevice(ctx) result.record("call_after_close_is_rejected", errors.Is(afterErr, engine.ErrClosed), errString(afterErr)) result.record("close_is_idempotent", eng.Close(time.Second) == nil, nil) diff --git a/tests/hosts/go/negative.go b/tests/hosts/go/negative.go index bb705e0c..7197ae0a 100644 --- a/tests/hosts/go/negative.go +++ b/tests/hosts/go/negative.go @@ -33,11 +33,19 @@ func runNegative(result *report, root, manifest string) { result.record("open_rejects_digest_mismatch", errors.Is(err, native.ErrMismatch), errString(err)) result.record("no_engine_started_by_rejected_open", host.counters()["private_data_directory"] == 0, host.counters()) - // 宿主错误往返:安全存储写入被拒绝,Open 返回同一稳定分类。 + // 宿主错误:目录能力失败以同一稳定分类原样返回;安全存储失败发生在启动内部, + // 由 Engine 归类为稳定的启动失败(1101),宿主回调确实被调用过。 + denied, _ := newFileHost(filepath.Join(root, "denied")) + denied.failDirectory = engine.ErrHostPermissionDenied + _, err = openEngine(denied, manifest) + result.record("host_directory_error_roundtrip", errors.Is(err, engine.ErrHostPermissionDenied), errString(err)) failing, _ := newFileHost(filepath.Join(root, "failing")) - failing.failSet = engine.ErrHostPermissionDenied + failing.failSet = engine.ErrHostIO _, err = openEngine(failing, manifest) - result.record("host_error_roundtrip", errors.Is(err, engine.ErrHostPermissionDenied), errString(err)) + var startup *engine.EngineError + result.record("host_secure_storage_failure_is_stable_startup_error", + errors.As(err, &startup) && startup.Code == 1101 && failing.setCalls.Load() > 0, + map[string]any{"error": errString(err), "set_calls": failing.setCalls.Load()}) eng, err := openEngine(host, manifest) if !result.record("open_for_negative_checks", err == nil, errString(err)) { @@ -49,8 +57,11 @@ func runNegative(result *report, root, manifest string) { result.record("valid_enum_accepted", eng.NotifyConnectivityOpportunity(ctx, engine.OpportunityNetworkChanged) == nil, nil) // context 取消只停止等待:Engine 之后仍可用。 - short, cancel := context.WithTimeout(ctx, 300*time.Millisecond) - _, err = eng.NextEvent(short) + // 先取尽已排队的事件,之后 NextEvent 只能等到 ctx 期限。 + short, cancel := context.WithTimeout(ctx, 600*time.Millisecond) + for err = nil; err == nil; { + _, err = eng.NextEvent(short) + } cancel() result.record("context_deadline_stops_waiting", errors.Is(err, context.DeadlineExceeded), errString(err)) _, err = eng.LocalDevice(ctx) @@ -71,7 +82,7 @@ func runNegative(result *report, root, manifest string) { mu.Unlock() } }() - for j := 0; j < 50; j++ { + for j := 0; j < 100000; j++ { var err error if i%4 == 0 { short, cancel := context.WithTimeout(ctx, 100*time.Millisecond) @@ -89,6 +100,9 @@ func runNegative(result *report, root, manifest string) { outcomes["ok"]++ case errors.Is(err, engine.ErrClosed): outcomes["closed"]++ + case isShutdownRace(err): + // 调用在 Close 之前已进入 Rust,与关闭竞争,得到 Engine 的稳定 InvalidState 错误。 + outcomes["engine_invalid_state_during_shutdown"]++ default: outcomes["other:"+err.Error()]++ } @@ -144,3 +158,8 @@ func tamperedManifest(path, root string) (string, error) { target := filepath.Join(root, "tampered-manifest.json") return target, os.WriteFile(target, out, 0o600) } + +func isShutdownRace(err error) bool { + var typed *engine.EngineError + return errors.As(err, &typed) && typed.Category == engine.CategoryInvalidState +} diff --git a/tests/hosts/go/observability.go b/tests/hosts/go/observability.go index 5fd9d91f..453e5252 100644 --- a/tests/hosts/go/observability.go +++ b/tests/hosts/go/observability.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "os" "path/filepath" + "strings" ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" ) From d93d0bacf2c6a29475433728ac3f1613cd6c667b Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:13:12 -0700 Subject: [PATCH 05/13] build(go-binding): add native build script --- bindings/go/native/build-native.sh | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 bindings/go/native/build-native.sh diff --git a/bindings/go/native/build-native.sh b/bindings/go/native/build-native.sh new file mode 100755 index 00000000..5c90bfd1 --- /dev/null +++ b/bindings/go/native/build-native.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# 构建 Go 宿主使用的 uc-engine-uniffi 动态库(当前主机目标)。 +# +# build-native.sh +# +# release 与移动包使用同一发布配置(panic=abort、LTO、符号剥离)并重映射构建机路径, +# 构建后断言产物不含本机路径。随后用 stage-native.sh 整理交付目录并写入来源清单。 +set -euo pipefail + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +profile="${1:?usage: build-native.sh }" +# 当前脚本与嵌套 Cargo 调用统一经由 MBX。 +source "$here/../../../scripts/build-cache/env.sh" +REPO_ROOT="$(cd "$here/../../.." && pwd)" +TARGET_DIR="${CARGO_TARGET_DIR:-$REPO_ROOT/target}" +BUILD_PROFILE="$profile" +case "$profile" in + dev) profile_dir=debug ;; + release) profile_dir=release ;; + *) echo "profile must be dev or release" >&2; exit 2 ;; +esac + +cd "$REPO_ROOT" +source "$REPO_ROOT/bindings/uc-engine-uniffi/scripts/release-path-remap.sh" +export CARGO_TARGET_DIR="$TARGET_DIR" +with_release_path_remap cargo build -p uc-engine-uniffi --profile "$profile" --lib --locked + +case "$(uname -s)" in + Darwin) library="$TARGET_DIR/$profile_dir/libuc_engine_uniffi.dylib" ;; + Linux) library="$TARGET_DIR/$profile_dir/libuc_engine_uniffi.so" ;; + *) echo "unsupported host: $(uname -s)" >&2; exit 1 ;; +esac +[[ -f "$library" ]] || { echo "missing $library" >&2; exit 1; } +verify_release_paths "$library" +echo "built $library" From 76addccbfd6baebe089a9449a59f8a6c81bd94f9 Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:15:19 -0700 Subject: [PATCH 06/13] docs(go-binding): add README, ADR-034, static checks and CI workflow --- .github/workflows/go-binding.yml | 161 ++++++++++++++++++ AGENTS.md | 2 +- ARCHITECTURE.md | 2 +- bindings/go/README.md | 88 ++++++++++ .../034-go-binding-via-generated-uniffi.md | 29 ++++ docs/design-docs/decisions/index.md | 1 + scripts/architecture/check-go-binding.mjs | 51 ++++++ 7 files changed, 332 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/go-binding.yml create mode 100644 bindings/go/README.md create mode 100644 docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md create mode 100644 scripts/architecture/check-go-binding.mjs diff --git a/.github/workflows/go-binding.yml b/.github/workflows/go-binding.yml new file mode 100644 index 00000000..72223143 --- /dev/null +++ b/.github/workflows/go-binding.yml @@ -0,0 +1,161 @@ +name: Go binding + +# Go module(bindings/go)的生成、原生构建与真实进程验收。 +# - macOS arm64:重新生成并要求零差异;构建发布配置原生库;Go 1.24 与 1.27 编译、链接;在拒绝外网的沙箱里运行三个验收进程。 +# - Linux amd64 / arm64:在对应原生 runner 上构建发布配置原生库并编译、链接 Go 门面与验收宿主。 +# Linux 与 Windows 的真实进程验收、macOS amd64、Windows 均未覆盖,见 bindings/go/README.md。 +on: + workflow_dispatch: + pull_request: + branches: [main] + paths: + - bindings/go/** + - bindings/uc-engine-uniffi/** + - tests/hosts/go/** + - scripts/architecture/check-go-binding.mjs + - .github/workflows/go-binding.yml + push: + branches: [main] + paths: + - bindings/go/** + - bindings/uc-engine-uniffi/** + - tests/hosts/go/** + +permissions: + contents: read + +concurrency: + group: go-binding-${{ github.ref }} + cancel-in-progress: true + +jobs: + macos-arm64: + name: Go binding (macOS arm64) + runs-on: macos-14 + environment: + name: ${{ github.ref == 'refs/heads/main' && 'engine-build-cache-writer' || 'engine-build-cache-reader' }} + deployment: false + timeout-minutes: 90 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + fetch-depth: 0 + + - name: Prepare Rust build + uses: ./.github/actions/rust-ci-setup + with: + cache-key: go-binding-macos + compile-cache-access: ${{ github.ref == 'refs/heads/main' && 'write' || 'read' }} + compile-cache-r2-endpoint: ${{ secrets.BUILD_CACHE_R2_ENDPOINT }} + compile-cache-r2-access-key-id: ${{ secrets.BUILD_CACHE_R2_ACCESS_KEY_ID }} + compile-cache-r2-secret-access-key: ${{ secrets.BUILD_CACHE_R2_SECRET_ACCESS_KEY }} + + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 + with: + go-version: "1.24.0" + + - name: Static checks + run: node scripts/architecture/check-go-binding.mjs + + - name: Build pinned generator + run: bash bindings/go/generator/build-generator.sh "$RUNNER_TEMP/generator" + + - name: Build development library for interface metadata + run: bash bindings/go/native/build-native.sh dev + + - name: Regenerate and require zero drift + run: | + bash bindings/go/generator/generate.sh "$RUNNER_TEMP/generator/bin/uniffi-bindgen-go" target/debug/libuc_engine_uniffi.dylib + git diff --exit-code -- bindings/go/uc_engine_uniffi + + - name: Build release library and stage with provenance manifest + run: | + bash bindings/go/native/build-native.sh release + bash bindings/go/native/stage-native.sh release "$RUNNER_TEMP/native" + + - name: Real-process acceptance (Go 1.24) + run: node tests/hosts/go/run-e2e.mjs --native "$RUNNER_TEMP/native" --evidence "$RUNNER_TEMP/e2e-go124" + + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 + with: + go-version: "1.27.1" + + - name: Real-process acceptance (Go 1.27) + run: node tests/hosts/go/run-e2e.mjs --native "$RUNNER_TEMP/native" --evidence "$RUNNER_TEMP/e2e-go127" + + - name: Retain acceptance evidence + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: go-binding-macos-arm64-evidence + path: | + ${{ runner.temp }}/e2e-go124 + ${{ runner.temp }}/e2e-go127 + ${{ runner.temp }}/native/native-manifest.json + if-no-files-found: warn + + - name: Retain MBX compiler evidence + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: mbx-${{ github.job }}-${{ runner.os }}-${{ runner.arch }} + path: ${{ runner.temp }}/mbx-evidence + if-no-files-found: warn + + linux-native-link: + name: Go binding link check (${{ matrix.name }}) + strategy: + fail-fast: false + matrix: + include: + - name: linux amd64 + runner: ubuntu-24.04 + - name: linux arm64 + runner: ubuntu-24.04-arm + runs-on: ${{ matrix.runner }} + environment: + name: ${{ github.ref == 'refs/heads/main' && 'engine-build-cache-writer' || 'engine-build-cache-reader' }} + deployment: false + timeout-minutes: 90 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + with: + fetch-depth: 0 + + - name: Install build tools + run: sudo apt-get update && sudo apt-get install -y clang libclang-dev cmake patchelf + + - name: Prepare Rust build + uses: ./.github/actions/rust-ci-setup + with: + cache-key: go-binding-${{ matrix.runner }} + compile-cache-access: ${{ github.ref == 'refs/heads/main' && 'write' || 'read' }} + compile-cache-r2-endpoint: ${{ secrets.BUILD_CACHE_R2_ENDPOINT }} + compile-cache-r2-access-key-id: ${{ secrets.BUILD_CACHE_R2_ACCESS_KEY_ID }} + compile-cache-r2-secret-access-key: ${{ secrets.BUILD_CACHE_R2_SECRET_ACCESS_KEY }} + + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 + with: + go-version: "1.24.0" + + - name: Build release library and stage with provenance manifest + run: | + bash bindings/go/native/build-native.sh release + bash bindings/go/native/stage-native.sh release "$RUNNER_TEMP/native" + + - name: Compile and link the facade and acceptance host + env: + CGO_ENABLED: "1" + run: | + export CGO_LDFLAGS="-L$RUNNER_TEMP/native -Wl,-rpath,$RUNNER_TEMP/native" + (cd bindings/go && go vet ./... && go build ./...) + (cd tests/hosts/go && go build -o "$RUNNER_TEMP/go-engine-host" .) + ldd "$RUNNER_TEMP/go-engine-host" | grep libuc_engine_uniffi + + - name: Retain MBX compiler evidence + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: mbx-${{ github.job }}-${{ matrix.runner }} + path: ${{ runner.temp }}/mbx-evidence + if-no-files-found: warn diff --git a/AGENTS.md b/AGENTS.md index 54964505..fc2238e0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,7 +30,7 @@ ## 目录地图 - `crates/`:Core 规则、Application 流程、Infra 实现与 Engine 稳定入口。 -- `bindings/`:iOS、Android、HarmonyOS 薄绑定。 +- `bindings/`:iOS、Android、HarmonyOS 薄绑定,以及 Go module(`bindings/go`)。 - `compatibility/`:独立版本、独立发布的 LAN 兼容线。 - `tests/hosts/`:移动平台验收宿主,不承载产品功能。 - `scripts/architecture/`:所有权、依赖方向和发布来源检查。 diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index cb068378..905738d5 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -43,7 +43,7 @@ Port 归需要能力的层所有,因此 Infra 既可以实现 Core port,也 | `crates/uc-infra-profile/` | Profile 升级/备份/恢复、配置迁移与跨存储的 Space 准入激活 | | `crates/uc-sync-protocol/` | 传输无关的同步线上格式(帧、版本、上限、编解码与 golden 向量),只依赖 `uc-core`,被 `uc-infra-p2p`/`uc-infra-profile` 使用 | | `crates/uc-engine/` | 唯一稳定 Rust 入口、生命周期、运行期与依赖组装 | -| `bindings/` | iOS、Android、HarmonyOS 的薄语言绑定 | +| `bindings/` | iOS、Android、HarmonyOS 的薄语言绑定,以及 Go module(`bindings/go`) | | `compatibility/` | 用户显式启用、独立版本与发布的 LAN 兼容线 | | `tests/hosts/` | 平台验收宿主,不承载产品业务 | diff --git a/bindings/go/README.md b/bindings/go/README.md new file mode 100644 index 00000000..99c8f30d --- /dev/null +++ b/bindings/go/README.md @@ -0,0 +1,88 @@ +# Go binding + +Go module `github.com/UniClipboard/Engine/bindings/go`:让 Go 宿主(例如后续的 Go daemon)在同一进程内托管真实的 Rust Engine。 +Engine、Iroh、加密与持久化仍由 Rust 负责;本模块只提供生成的 UniFFI 绑定、一个薄 Go 门面和原生库身份校验。 +设计取舍、失败模型与验收契约见[执行计划](../../docs/exec-plans/active/2026-10-07-go-binding.md)与[ADR-034](../../docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md)。 + +## 目录 + +| 路径 | 内容 | 维护方式 | +|---|---|---| +| `engine/` | 门面:`Open`、查询、事件、`Close`、稳定错误、输入校验 | 手写 | +| `native/` | 原生库来源清单校验(`Verify`)、构建与整理脚本 | 手写 | +| `uc_engine_uniffi/` | 生成的 UniFFI 绑定(`.go` 与 `.h`);`link.go` 为手写 cgo 指令 | 生成,禁止手改 | +| `generator/` | 固定的生成器来源、模板补丁、构建与生成脚本 | 手写 | + +## 使用方式 + +这不是纯 Go 包:需要 `CGO_ENABLED=1`、C 编译器,以及与源码提交匹配的原生库。`go get` 不会下载或构建原生库。 + +```bash +# 1. 在 Engine 仓库根目录构建并整理原生库(macOS arm64 已实测) +bash bindings/go/native/build-native.sh release +bash bindings/go/native/stage-native.sh release <交付目录> + +# 2. 在宿主构建环境提供库路径与 rpath,然后正常 go build +export CGO_ENABLED=1 +export CGO_LDFLAGS="-L<交付目录> -Wl,-rpath,<交付目录>" +``` + +交付目录包含 `libuc_engine_uniffi.` 与 `native-manifest.json`。宿主应用打包时必须把库放在可执行文件能解析的位置 +(`@rpath`/`$ORIGIN`),不要依赖开发者 shell 环境。macOS 上 `stage-native.sh` 把 install_name 改为 `@rpath/…` 并重新 ad-hoc 签名; +面向用户分发仍须宿主自己的 Developer ID 签名与公证。 + +```go +import "github.com/UniClipboard/Engine/bindings/go/engine" + +eng, err := engine.Open(engine.Config{ + AppVersion: "1.1.0-rc.22", + ProfileID: "default", + NativeManifest: "/path/to/native-manifest.json", // 必填;校验失败即拒绝启动 +}, myHost) +if err != nil { /* engine.EngineError / ErrHost* / native.ErrMismatch … */ } +defer eng.Close(10 * time.Second) + +device, err := eng.LocalDevice(ctx) +for { event, err := eng.NextEvent(ctx); … } +``` + +## 契约摘要 + +- **来源校验**:`Open` 读取清单,核对 `core_version`、动态链接器实际映射的库文件名与 sha256/size。清单缺失、字段不符或库被替换返回 `native.ErrMismatch`; + 没有跳过校验的模式。Windows 暂无加载路径解析,返回 `native.ErrUnsupported`。 +- **关闭**:`Close(deadline)` 先拒绝新调用,再请求 Rust 在期限内关闭并 join,排空在途调用后释放对象。期限内未完成返回 `ErrCloseIncomplete`,可重试。 + `Close` 后调用返回 `ErrClosed`;与 `Close` 竞争的在途调用可能得到 Engine 的 `InvalidState` 稳定错误。 +- **取消**:`context` 取消只让调用方停止等待,Rust 调用继续,`Close` 仍等待其结束。 +- **事件**:Rust 队列容量 256,溢出时丢最旧事件并给出 `RefreshRequired(ConsumerLagged)`,收到后重新查询。门面不再缓冲。未映射的事件只报告种类,不携带载荷。 +- **输入**:零值或越界枚举、空配置在进入 Rust 之前返回 `ErrInvalidInput`。 +- **宿主回调**:只能返回能力结果,不得在回调内调用同一个 Engine(同步请求会等待正在执行回调的线程)。目录回调失败原样映射为 `ErrHost*`;启动期间安全存储失败由 Engine 归类为稳定的启动错误 `1101`。 +- **崩溃隔离**:发布构建 `panic=abort`,Rust 崩溃会终止整个宿主进程,Go 的 `recover` 无效。嵌入后宿主与 Engine 同生共死,Engine 不再有进程隔离; + GUI/CLI 若仍是独立进程经 HTTP 连接 daemon,则它们不受 daemon 崩溃影响。这是 daemon 重写评审时需要明确讨论的取舍。 +- **敏感信息**:错误与事件不含内容、路径或设备信息;`Invitation` 的 `String` 固定脱敏。 + +## 重新生成 + +```bash +bash bindings/go/generator/build-generator.sh <外置空目录> # 固定 revision + 模板补丁 +bash bindings/go/generator/generate.sh <生成器>/bin/uniffi-bindgen-go target/debug/libuc_engine_uniffi.dylib +git diff --exit-code bindings/go/uc_engine_uniffi +``` + +生成物提交入库,CI 重新生成并要求零差异。模板补丁把模板引入的局部变量统一加 `_uniffi` 前缀,避免与用户方法参数同名(上游原样生成器因 `handle` 撞名无法编译)。 +生成器与模板为 MPL-2.0,许可证文本随生成包保留为 `uc_engine_uniffi/LICENSE-uniffi-bindgen-go`;本仓其余部分为 Apache-2.0。 + +## 平台状态 + +| 目标 | 状态 | +|---|---| +| macOS arm64(本机) | 构建、链接、真实进程验收已实测,见执行计划证据 | +| Linux amd64/arm64 | CI 做原生构建与 Go 编译/链接检查;真实进程验收未覆盖 | +| macOS amd64、Windows amd64/arm64 | 未验证;Windows 需要与 Go C 链接器匹配的导入库,且尚无库身份校验 | + +交叉编译不记为原生验证。 + +## 能力范围 + +门面当前覆盖:启动/关闭、本机设备、空间状态、设备列表、邀请签发、退出空间、网络时机通知、生命周期(暂停/恢复/状态)与事件。 +现有 `MobileEngine` 是 `uc-engine` Operation 的子集;历史、设置、搜索、诊断、解锁与恢复、升级、LAN 兼容等 Desktop 需要的能力 +尚未暴露,也未声称覆盖全部 62 个 Desktop 宿主命令。剪贴板与文件句柄宿主能力固定返回“不可用”。后续新增必须经 `uc-engine` Operation 加性补入统一绑定,并核对 Swift/Kotlin。 diff --git a/docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md b/docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md new file mode 100644 index 00000000..af064e31 --- /dev/null +++ b/docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md @@ -0,0 +1,29 @@ +# ADR-034:Go 绑定使用生成的 UniFFI 包与薄 Go 门面 + +- **状态**:Accepted(第一片:macOS arm64 实测;其余平台按能力覆盖) +- **相关文档**:[执行计划](../../exec-plans/active/2026-10-07-go-binding.md)、[`bindings/go/README.md`](../../../bindings/go/README.md)、[uc-engine 接口](../uc-engine-interface.md) + +## 背景 + +后续 Go daemon 需要在同一进程内托管 Rust Engine。现有 UniFFI 绑定只服务 Swift 与 Kotlin。重写 Iroh、加密或持久化不在考虑内。 + +## 决策 + +- 复用现有 UniFFI(`=0.31.1`)元数据,用 NordSecurity `uniffi-bindgen-go` 固定 revision 生成 Go/cgo 包;生成器自身 `Cargo.lock` 与模板补丁的 sha256 固定在 `bindings/go/generator/PIN.env`,不进入本仓 workspace 和 `Cargo.lock`。 +- 上游模板的局部变量与用户方法参数同名时生成物无法编译;修复只通过生成器源码补丁交付,禁止手改生成文件。生成物提交入库,CI 重新生成要求零差异。 +- Go 门面只做 Go 侧所有权:一次 `Open`、调用 `uc-engine` 既有动作、读取事件、确定性 `Close`、稳定错误与输入校验。业务流程、恢复与重试仍由 Rust 负责。 +- 原生库不进入 Go module。`stage-native.sh` 为库生成来源清单(Engine revision、`Cargo.lock` sha256、目标、profile、工具链、生成器 pin、库 sha256/size),`Open` 强制核对动态链接器实际映射的库,没有跳过模式。 +- 第一片不修改 Rust 源码与公共 UniFFI 表面,因此 Swift/Kotlin 契约与移动 pin 不受影响。 + +## 取舍与代价 + +- 嵌入后 Rust 崩溃(`panic=abort`、越界、OOM)会终止整个宿主进程,Go 的 `recover` 无效,失去现有 daemon 与 GUI/CLI 之间的进程隔离。是否为 Go daemon 采用嵌入模式、 + GUI/CLI 是否仍经 HTTP 连接独立 daemon,须在 daemon 重写评审中明确决定,不默认嵌入更优。 +- 生成器仍是 0.x 第三方项目,约半年无新提交;固定 revision 与补丁降低漂移,但维护来源(fork 或上游贡献)尚待决定。 +- 动态库需要宿主打包与签名;Windows 的导入库与库身份校验尚无方案。 + +## 被放弃的方案 + +- 手写窄 C ABI:重复 UniFFI 已有的对象、错误与回调机制,维护面更大。仅在生成器出现无法解决的缺口时作为备选。 +- 手改生成后的 Go 文件:重新生成即丢失,无法重复。 +- 在 Go 门面再设事件缓冲:与 Rust 已有的有限队列和 `RefreshRequired` 形成两层背压。 diff --git a/docs/design-docs/decisions/index.md b/docs/design-docs/decisions/index.md index 7c268248..3ad54c2e 100644 --- a/docs/design-docs/decisions/index.md +++ b/docs/design-docs/decisions/index.md @@ -32,3 +32,4 @@ ADR 记录重要取舍的背景、备选方案和后果。编号保持历史稳 - [ADR-032:传输无关的同步线上格式独立为 uc-sync-protocol](032-transport-independent-sync-wire-crate.md) - [ADR-033:Rust 构建与测试统一使用 MBX](033-unified-mbx-rust-builds.md) +- [ADR-034:Go 绑定使用生成的 UniFFI 包与薄 Go 门面](034-go-binding-via-generated-uniffi.md) diff --git a/scripts/architecture/check-go-binding.mjs b/scripts/architecture/check-go-binding.mjs new file mode 100644 index 00000000..77681a42 --- /dev/null +++ b/scripts/architecture/check-go-binding.mjs @@ -0,0 +1,51 @@ +// Go binding 的静态约束:生成器来源固定、模板补丁与声明一致、许可证随生成包、生成文件不含手写入口。 +// 重新生成并比较零差异由 go-binding 工作流执行(需要构建生成器与原生库)。 +import assert from 'node:assert/strict' +import { createHash } from 'node:crypto' +import { existsSync, readFileSync, readdirSync } from 'node:fs' +import { join, resolve } from 'node:path' + +const root = resolve(import.meta.dirname, '../..') +const goDir = join(root, 'bindings/go') +const sha256 = (path) => createHash('sha256').update(readFileSync(path)).digest('hex') + +const pin = Object.fromEntries( + readFileSync(join(goDir, 'generator/PIN.env'), 'utf8') + .split('\n') + .filter((line) => line && !line.startsWith('#')) + .map((line) => line.split(/=(.*)/s).slice(0, 2)), +) +assert.match(pin.UNIFFI_BINDGEN_GO_REVISION, /^[0-9a-f]{40}$/, 'generator revision must be a full commit') +assert.match(pin.UNIFFI_BINDGEN_GO_LOCK_SHA256, /^[0-9a-f]{64}$/) +assert.equal( + sha256(join(goDir, 'generator', pin.UNIFFI_BINDGEN_GO_PATCH)), + pin.UNIFFI_BINDGEN_GO_PATCH_SHA256, + 'template patch differs from PIN.env', +) + +const generated = join(goDir, 'uc_engine_uniffi') +assert.ok(existsSync(join(generated, 'uc_engine_uniffi.go')) && existsSync(join(generated, 'uc_engine_uniffi.h'))) +assert.match(readFileSync(join(generated, 'LICENSE-uniffi-bindgen-go'), 'utf8'), /Mozilla Public License Version 2\.0/) +// 生成目录只允许两个生成文件、手写 link.go 与许可证;其余入口说明有人把手写代码混入生成包。 +assert.deepEqual( + readdirSync(generated).sort(), + ['LICENSE-uniffi-bindgen-go', 'link.go', 'uc_engine_uniffi.go', 'uc_engine_uniffi.h'], +) + +// go 指令不得高于 Desktop 声明的 1.26,避免把消费者工具链强行抬高。 +const goMod = readFileSync(join(goDir, 'go.mod'), 'utf8') +const directive = /^go (\d+)\.(\d+)/m.exec(goMod) +assert.ok(directive && Number(directive[1]) === 1 && Number(directive[2]) <= 26, 'go directive must be <= 1.26') + +// 门面不得绕过稳定入口:只允许依赖生成包与 native 校验。 +for (const file of readdirSync(join(goDir, 'engine')).filter((name) => name.endsWith('.go'))) { + const text = readFileSync(join(goDir, 'engine', file), 'utf8') + for (const [, path] of text.matchAll(/"(github\.com\/UniClipboard\/[^"]+)"/g)) { + assert.ok( + path === 'github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi' || + path === 'github.com/UniClipboard/Engine/bindings/go/native', + `engine/${file} imports ${path}`, + ) + } +} +console.log('Go binding static checks passed') From 06001a0600519df9fb77de52ea2181cc09165980 Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:16:41 -0700 Subject: [PATCH 07/13] test(go-binding): assert embedded source identity matches the manifest --- tests/hosts/go/run-e2e.mjs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/hosts/go/run-e2e.mjs b/tests/hosts/go/run-e2e.mjs index 973ca350..ab7d0cad 100644 --- a/tests/hosts/go/run-e2e.mjs +++ b/tests/hosts/go/run-e2e.mjs @@ -112,10 +112,44 @@ if (build.exit === 0 && networkDenied) { } } +// 链接进产物的来源身份:Rust 观测日志的每条记录携带构建时嵌入的 source_commit/source_state, +// 必须与来源清单的 revision 一致且工作区干净,证明被执行的库就是清单所述的源码。 +const sourceCommits = new Set() +const sourceStates = new Set() +const logDir = join(evidence, 'root', 'cache', 'logs') +if (existsSync(logDir)) { + for (const name of readdirSync(logDir)) { + for (const line of readFileSync(join(logDir, name), 'utf8').split('\n')) { + try { + const record = JSON.parse(line) + if (record.source_commit) sourceCommits.add(record.source_commit) + if (record.source_state) sourceStates.add(record.source_state) + } catch { + // 非 JSON 行不含来源字段。 + } + } + } +} +const sourceIdentity = { + manifest_revision: manifest.engine_revision, + embedded_source_commits: [...sourceCommits], + embedded_source_states: [...sourceStates], + matches: + sourceCommits.size === 1 && + sourceCommits.has(manifest.engine_revision) && + sourceStates.size === 1 && + sourceStates.has('clean'), +} + const allOk = - build.exit === 0 && networkDenied && phases.length === 3 && phases.every((phase) => phase.ok) + build.exit === 0 && + networkDenied && + sourceIdentity.matches && + phases.length === 3 && + phases.every((phase) => phase.ok) const summary = { ok: allOk, + source_identity: sourceIdentity, network_isolation: { mechanism: 'sandbox-exec (deny network*; allow bind and loopback only)', profile: sandboxProfile, control_exit: control.exit, denied: networkDenied }, tools: toolVersions, native: { From 59b666db4e196476bf78db41a6a7f4a7d922dd8e Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:18:18 -0700 Subject: [PATCH 08/13] test(go-binding): cover short-deadline close retry; mark generated files --- .gitattributes | 5 +++++ .github/workflows/go-binding.yml | 4 +++- bindings/go/README.md | 2 +- tests/hosts/go/negative.go | 13 +++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index ccaa4342..f6a0529f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -37,3 +37,8 @@ # setup does not add "ruby" and then fail finalize with "no source code seen" # (the brew cask added in #1086 is the only Ruby in the repo). packaging/**/*.rb linguist-detectable=false + +# Go binding:生成文件由 bindings/go/generator 重写,评审时折叠 +bindings/go/uc_engine_uniffi/uc_engine_uniffi.go linguist-generated=true text eol=lf +bindings/go/uc_engine_uniffi/uc_engine_uniffi.h linguist-generated=true text eol=lf +*.go text eol=lf diff --git a/.github/workflows/go-binding.yml b/.github/workflows/go-binding.yml index 72223143..86dbbab5 100644 --- a/.github/workflows/go-binding.yml +++ b/.github/workflows/go-binding.yml @@ -55,7 +55,9 @@ jobs: go-version: "1.24.0" - name: Static checks - run: node scripts/architecture/check-go-binding.mjs + run: | + node scripts/architecture/check-go-binding.mjs + test -z "$(gofmt -l bindings/go/engine bindings/go/native tests/hosts/go)" - name: Build pinned generator run: bash bindings/go/generator/build-generator.sh "$RUNNER_TEMP/generator" diff --git a/bindings/go/README.md b/bindings/go/README.md index 99c8f30d..f2390bf9 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -50,7 +50,7 @@ for { event, err := eng.NextEvent(ctx); … } - **来源校验**:`Open` 读取清单,核对 `core_version`、动态链接器实际映射的库文件名与 sha256/size。清单缺失、字段不符或库被替换返回 `native.ErrMismatch`; 没有跳过校验的模式。Windows 暂无加载路径解析,返回 `native.ErrUnsupported`。 -- **关闭**:`Close(deadline)` 先拒绝新调用,再请求 Rust 在期限内关闭并 join,排空在途调用后释放对象。期限内未完成返回 `ErrCloseIncomplete`,可重试。 +- **关闭**:`Close(deadline)` 先拒绝新调用,再请求 Rust 在期限内关闭并 join,排空在途调用后释放对象。期限内未完成返回 `ErrCloseIncomplete` 或 Rust 的 `DeadlineExceeded` 稳定错误,可用新期限重试直至成功。 `Close` 后调用返回 `ErrClosed`;与 `Close` 竞争的在途调用可能得到 Engine 的 `InvalidState` 稳定错误。 - **取消**:`context` 取消只让调用方停止等待,Rust 调用继续,`Close` 仍等待其结束。 - **事件**:Rust 队列容量 256,溢出时丢最旧事件并给出 `RefreshRequired(ConsumerLagged)`,收到后重新查询。门面不再缓冲。未映射的事件只报告种类,不携带载荷。 diff --git a/tests/hosts/go/negative.go b/tests/hosts/go/negative.go index 7197ae0a..de95a3d8 100644 --- a/tests/hosts/go/negative.go +++ b/tests/hosts/go/negative.go @@ -131,6 +131,19 @@ func runNegative(result *report, root, manifest string) { _, err = eng.NextEvent(ctx) result.record("next_event_after_close_is_rejected", errors.Is(err, engine.ErrClosed), errString(err)) + // 期限极短的 Close:未完成时返回明确错误、仍拒绝新调用,并可用新期限继续收尾直至成功。 + slowHost, _ := newFileHost(filepath.Join(root, "deadline")) + slow, err := openEngine(slowHost, manifest) + if result.record("open_for_deadline_retry", err == nil, errString(err)) { + first := slow.Close(time.Millisecond) + _, during := slow.LocalDevice(ctx) + second := slow.Close(20 * time.Second) + _, after := slow.LocalDevice(ctx) + result.record("close_deadline_then_retry_succeeds", + second == nil && errors.Is(during, engine.ErrClosed) && errors.Is(after, engine.ErrClosed), + map[string]any{"first_close": errString(first), "second_close": errString(second)}) + } + hits, scanErr := scanForLeaks(root, []string{profileID}, host.secrets) result.record("no_secret_in_logs_or_profile", scanErr == nil && len(hits) == 0, map[string]any{"hits": hits}) } From 18fce3a7d734437e91e6e91ad233c04f5cd641b5 Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:29:11 -0700 Subject: [PATCH 09/13] fix(go-binding): address independent review findings --- .gitattributes | 4 +- .github/workflows/go-binding.yml | 14 +++- .github/workflows/pr-check.yml | 3 + bindings/go/README.md | 14 ++-- bindings/go/engine/engine.go | 38 ++++++++-- bindings/go/engine/events.go | 7 +- bindings/go/engine/host.go | 32 ++++++--- bindings/go/generator/generate.sh | 13 +++- bindings/go/native/stage-native.sh | 70 +++++++++++++------ bindings/go/native/verify.go | 34 +++++++-- .../go/uc_engine_uniffi/generated_sources.go | 6 ++ bindings/go/uc_engine_uniffi/link.go | 2 +- .../034-go-binding-via-generated-uniffi.md | 2 +- .../active/2026-10-07-go-binding.md | 14 ++-- scripts/architecture/check-go-binding.mjs | 4 +- tests/hosts/go/negative.go | 42 ++++++++++- tests/hosts/go/run-e2e.mjs | 67 +++++++++++++++--- 17 files changed, 290 insertions(+), 76 deletions(-) create mode 100644 bindings/go/uc_engine_uniffi/generated_sources.go diff --git a/.gitattributes b/.gitattributes index f6a0529f..68a18d00 100644 --- a/.gitattributes +++ b/.gitattributes @@ -41,4 +41,6 @@ packaging/**/*.rb linguist-detectable=false # Go binding:生成文件由 bindings/go/generator 重写,评审时折叠 bindings/go/uc_engine_uniffi/uc_engine_uniffi.go linguist-generated=true text eol=lf bindings/go/uc_engine_uniffi/uc_engine_uniffi.h linguist-generated=true text eol=lf -*.go text eol=lf +bindings/go/uc_engine_uniffi/generated_sources.go linguist-generated=true +bindings/go/**/*.go text eol=lf +tests/hosts/go/*.go text eol=lf diff --git a/.github/workflows/go-binding.yml b/.github/workflows/go-binding.yml index 86dbbab5..757e108a 100644 --- a/.github/workflows/go-binding.yml +++ b/.github/workflows/go-binding.yml @@ -11,6 +11,11 @@ on: paths: - bindings/go/** - bindings/uc-engine-uniffi/** + - crates/uc-engine/** + - Cargo.toml + - Cargo.lock + - rust-toolchain.toml + - scripts/build-cache/** - tests/hosts/go/** - scripts/architecture/check-go-binding.mjs - .github/workflows/go-binding.yml @@ -19,6 +24,9 @@ on: paths: - bindings/go/** - bindings/uc-engine-uniffi/** + - crates/uc-engine/** + - Cargo.toml + - Cargo.lock - tests/hosts/go/** permissions: @@ -57,7 +65,7 @@ jobs: - name: Static checks run: | node scripts/architecture/check-go-binding.mjs - test -z "$(gofmt -l bindings/go/engine bindings/go/native tests/hosts/go)" + test -z "$(gofmt -l bindings/go/engine bindings/go/native bindings/go/uc_engine_uniffi/link.go bindings/go/uc_engine_uniffi/generated_sources.go tests/hosts/go)" - name: Build pinned generator run: bash bindings/go/generator/build-generator.sh "$RUNNER_TEMP/generator" @@ -76,14 +84,14 @@ jobs: bash bindings/go/native/stage-native.sh release "$RUNNER_TEMP/native" - name: Real-process acceptance (Go 1.24) - run: node tests/hosts/go/run-e2e.mjs --native "$RUNNER_TEMP/native" --evidence "$RUNNER_TEMP/e2e-go124" + run: node tests/hosts/go/run-e2e.mjs --native "$RUNNER_TEMP/native" --evidence "$RUNNER_TEMP/e2e-go124" --require-network-positive-control - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 with: go-version: "1.27.1" - name: Real-process acceptance (Go 1.27) - run: node tests/hosts/go/run-e2e.mjs --native "$RUNNER_TEMP/native" --evidence "$RUNNER_TEMP/e2e-go127" + run: node tests/hosts/go/run-e2e.mjs --native "$RUNNER_TEMP/native" --evidence "$RUNNER_TEMP/e2e-go127" --require-network-positive-control - name: Retain acceptance evidence if: always() diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index a8b62a03..fd6cffb9 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -65,6 +65,9 @@ jobs: - name: Check no direct tracing log macros run: node scripts/architecture/check-direct-log-macros.mjs + - name: Check Go binding static rules + run: node scripts/architecture/check-go-binding.mjs + # 公告库在运行时拉取最新版本,工具版本固定并与本地 cargo audit 一致。漏洞与 unsound 公告都会阻断, # 当前锁无需任何例外;新增公告必须通过升级修复,不得以忽略方式放行。 - name: Install cargo-audit diff --git a/bindings/go/README.md b/bindings/go/README.md index f2390bf9..30ee77f9 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -48,14 +48,16 @@ for { event, err := eng.NextEvent(ctx); … } ## 契约摘要 -- **来源校验**:`Open` 读取清单,核对 `core_version`、动态链接器实际映射的库文件名与 sha256/size。清单缺失、字段不符或库被替换返回 `native.ErrMismatch`; - 没有跳过校验的模式。Windows 暂无加载路径解析,返回 `native.ErrUnsupported`。 -- **关闭**:`Close(deadline)` 先拒绝新调用,再请求 Rust 在期限内关闭并 join,排空在途调用后释放对象。期限内未完成返回 `ErrCloseIncomplete` 或 Rust 的 `DeadlineExceeded` 稳定错误,可用新期限重试直至成功。 - `Close` 后调用返回 `ErrClosed`;与 `Close` 竞争的在途调用可能得到 Engine 的 `InvalidState` 稳定错误。 +- **来源校验**:`Open` 读取清单,要求关键字段齐全,并核对目标与当前 `GOOS/GOARCH`、清单中的生成源摘要与已编译绑定一致、`core_version`、动态链接器报告的库文件名与该文件的 sha256/size。 + 清单缺失、字段不符、版本错配或库与清单不一致返回 `native.ErrMismatch`;没有跳过校验的模式。这是完整性与一致性自检,用于发现错配和陈旧库, + **不是认证**:清单与库通常在同一目录,它不防御有本地写权限的攻击者。静态链接(库不是独立文件)时库名比较失败,按错配拒绝。Windows 暂无加载路径解析,返回 `native.ErrUnsupported`。 +- **关闭**:`Close(deadline)` 先拒绝新调用,再请求 Rust 在期限内关闭并 join,排空在途调用后释放对象。期限内未完成返回 `ErrCloseIncomplete`(Rust 的可重试等待超时,实测 `1108`,被包装为它并保留原始 `EngineError`),可用新期限重试直至成功。 + `Close` 后调用返回 `ErrClosed`(`NextEvent` 也是,关闭期间已入队的事件不再可见);并发的 `Close` 被串行化;与 `Close` 竞争的在途调用可能得到 Engine 的 `InvalidState` 稳定错误。 + 负载下 `Close` 要排空积压的在途调用(实测 32 个并发调用方时约 5 秒,空闲时约 1 秒),期限应按负载放宽。 - **取消**:`context` 取消只让调用方停止等待,Rust 调用继续,`Close` 仍等待其结束。 - **事件**:Rust 队列容量 256,溢出时丢最旧事件并给出 `RefreshRequired(ConsumerLagged)`,收到后重新查询。门面不再缓冲。未映射的事件只报告种类,不携带载荷。 - **输入**:零值或越界枚举、空配置在进入 Rust 之前返回 `ErrInvalidInput`。 -- **宿主回调**:只能返回能力结果,不得在回调内调用同一个 Engine(同步请求会等待正在执行回调的线程)。目录回调失败原样映射为 `ErrHost*`;启动期间安全存储失败由 Engine 归类为稳定的启动错误 `1101`。 +- **宿主回调**:只能返回能力结果,不得在回调内调用同一个 Engine(同步请求会等待正在执行回调的线程;本片未提供能触发该情形的真实进程用例,仅作文档约束)。回调 panic 被门面转为 `ErrHostIO`,不终止进程。目录回调失败原样映射为 `ErrHost*`;启动期间安全存储失败由 Engine 归类为稳定的启动错误 `1101`。 - **崩溃隔离**:发布构建 `panic=abort`,Rust 崩溃会终止整个宿主进程,Go 的 `recover` 无效。嵌入后宿主与 Engine 同生共死,Engine 不再有进程隔离; GUI/CLI 若仍是独立进程经 HTTP 连接 daemon,则它们不受 daemon 崩溃影响。这是 daemon 重写评审时需要明确讨论的取舍。 - **敏感信息**:错误与事件不含内容、路径或设备信息;`Invitation` 的 `String` 固定脱敏。 @@ -75,7 +77,7 @@ git diff --exit-code bindings/go/uc_engine_uniffi | 目标 | 状态 | |---|---| -| macOS arm64(本机) | 构建、链接、真实进程验收已实测,见执行计划证据 | +| macOS arm64(本机) | 构建、链接、真实进程验收已实测(Go 1.24.0 与 1.27.1),证据见本任务报告与 CI 工件 `go-binding-macos-arm64-evidence` | | Linux amd64/arm64 | CI 做原生构建与 Go 编译/链接检查;真实进程验收未覆盖 | | macOS amd64、Windows amd64/arm64 | 未验证;Windows 需要与 Go C 链接器匹配的导入库,且尚无库身份校验 | diff --git a/bindings/go/engine/engine.go b/bindings/go/engine/engine.go index 92890924..ceab542a 100644 --- a/bindings/go/engine/engine.go +++ b/bindings/go/engine/engine.go @@ -14,6 +14,8 @@ package engine import ( "context" "errors" + "fmt" + "log/slog" "sync" "time" @@ -68,6 +70,7 @@ const ( type Engine struct { inner *ffi.MobileEngine + closeMu sync.Mutex // 串行化 Close,避免第二个 Close 对已释放的对象调用 Shutdown mu sync.Mutex inflight int closing bool @@ -128,6 +131,12 @@ func call[T any](ctx context.Context, e *Engine, fn func(*ffi.MobileEngine) (T, done := make(chan outcome, 1) go func() { defer e.end() + // 生成层的 panic(例如对象已释放)不能终止宿主进程;Rust 侧的 abort 不在此列。 + defer func() { + if recover() != nil { + done <- outcome{err: ErrUnexpectedResult} + } + }() value, err := fn(e.inner) done <- outcome{value, convertError(err)} }() @@ -193,6 +202,10 @@ type Invitation struct { func (Invitation) String() string { return "Invitation(REDACTED)" } func (Invitation) GoString() string { return "Invitation(REDACTED)" } +// MarshalJSON 与 LogValue 同样固定脱敏,避免序列化或结构化日志意外带出邀请内容。 +func (Invitation) MarshalJSON() ([]byte, error) { return []byte(`"REDACTED"`), nil } +func (Invitation) LogValue() slog.Value { return slog.StringValue("REDACTED") } + // IssueInvitation 为当前空间签发邀请;没有可邀请的空间时返回 EngineError。 func (e *Engine) IssueInvitation(ctx context.Context) (Invitation, error) { return call(ctx, e, func(inner *ffi.MobileEngine) (Invitation, error) { @@ -274,12 +287,16 @@ func (e *Engine) NextEvent(ctx context.Context) (Event, error) { // Close 请求 Rust 在 deadline 内关闭并 join,排空在途调用后释放对象。 // -// 期限内未完成时返回 ErrCloseIncomplete(或 Rust 的 DeadlineExceeded EngineError), -// 此后新调用仍被拒绝,可再次调用 Close 继续收尾。Close 成功后重复调用返回 nil。 +// 期限内未完成时返回 ErrCloseIncomplete(Rust 的可重试等待超时同样包装为它,并保留原始 EngineError), +// 此后新调用仍被拒绝,可再次调用 Close 继续收尾。Close 成功后重复调用返回 nil;并发的 Close 被串行化。 +// 关闭期间已入队的事件对消费者不再可见:NextEvent 在 Close 开始后立即返回 ErrClosed。 +// 负载下 Close 需要排空积压的在途调用(实测 32 个并发调用方时约 5 秒),期限应按负载放宽。 func (e *Engine) Close(deadline time.Duration) error { if deadline <= 0 { return ErrInvalidInput } + e.closeMu.Lock() + defer e.closeMu.Unlock() started := time.Now() e.mu.Lock() if e.closed { @@ -301,16 +318,25 @@ func (e *Engine) Close(deadline time.Duration) error { converted = nil } if converted != nil { + var engineErr *EngineError + if errors.As(converted, &engineErr) && engineErr.Retryable { + // Rust 的等待超时(实测 1108)可重试:统一为可判定的 ErrCloseIncomplete,同时保留原始稳定错误。 + return fmt.Errorf("%w: %w", ErrCloseIncomplete, converted) + } return converted } } - timer := time.NewTimer(max(deadline-time.Since(started), 0)) - defer timer.Stop() select { case <-e.idle: - case <-timer.C: - return ErrCloseIncomplete + default: + timer := time.NewTimer(max(deadline-time.Since(started), 0)) + defer timer.Stop() + select { + case <-e.idle: + case <-timer.C: + return ErrCloseIncomplete + } } e.mu.Lock() defer e.mu.Unlock() diff --git a/bindings/go/engine/events.go b/bindings/go/engine/events.go index ca0052eb..0bf4ad69 100644 --- a/bindings/go/engine/events.go +++ b/bindings/go/engine/events.go @@ -10,6 +10,9 @@ import ( // State 是 Engine 的生命周期状态。 type State int +// StateUnknown 表示 Rust 返回了本门面尚不认识的状态变体;消费者不得把它当作已停止。 +const StateUnknown State = 0 + const ( StateRunning State = iota + 1 StateQuiescing @@ -61,8 +64,10 @@ func stateFrom(state ffi.BindingEngineState) State { return StateSuspended case ffi.BindingEngineStateShuttingDown: return StateShuttingDown - default: + case ffi.BindingEngineStateStopped: return StateStopped + default: + return StateUnknown } } diff --git a/bindings/go/engine/host.go b/bindings/go/engine/host.go index 851a31dc..607398ad 100644 --- a/bindings/go/engine/host.go +++ b/bindings/go/engine/host.go @@ -25,10 +25,18 @@ type Host interface { } // hostAdapter 把 Host 适配为生成层的回调接口,并把 Go 错误映射为稳定的宿主错误分类。 +// 宿主回调的 panic 发生在 Rust 线程调用 Go 的栈上,无法被调用方 recover;这里统一转为 ErrHostIO, +// 不携带 panic 值,避免宿主自身的缺陷终止整个进程。 type hostAdapter struct { host Host } +func guard(err *error) { + if recover() != nil { + *err = ffi.NewHostBindingErrorIo() + } +} + func hostError(err error) error { switch { case err == nil: @@ -44,22 +52,26 @@ func hostError(err error) error { } } -func (a hostAdapter) PrivateDataDirectory() (string, error) { - value, err := a.host.PrivateDataDirectory() +func (a hostAdapter) PrivateDataDirectory() (value string, err error) { + defer guard(&err) + value, err = a.host.PrivateDataDirectory() return value, hostError(err) } -func (a hostAdapter) CacheDirectory() (string, error) { - value, err := a.host.CacheDirectory() +func (a hostAdapter) CacheDirectory() (value string, err error) { + defer guard(&err) + value, err = a.host.CacheDirectory() return value, hostError(err) } -func (a hostAdapter) TemporaryDirectory() (string, error) { - value, err := a.host.TemporaryDirectory() +func (a hostAdapter) TemporaryDirectory() (value string, err error) { + defer guard(&err) + value, err = a.host.TemporaryDirectory() return value, hostError(err) } -func (a hostAdapter) SecureStorageGet(key string) (*[]byte, error) { +func (a hostAdapter) SecureStorageGet(key string) (result *[]byte, err error) { + defer guard(&err) value, err := a.host.SecureStorageGet(key) if err != nil { return nil, hostError(err) @@ -70,11 +82,13 @@ func (a hostAdapter) SecureStorageGet(key string) (*[]byte, error) { return &value, nil } -func (a hostAdapter) SecureStorageSet(key string, value []byte) error { +func (a hostAdapter) SecureStorageSet(key string, value []byte) (err error) { + defer guard(&err) return hostError(a.host.SecureStorageSet(key, value)) } -func (a hostAdapter) SecureStorageDelete(key string) error { +func (a hostAdapter) SecureStorageDelete(key string) (err error) { + defer guard(&err) return hostError(a.host.SecureStorageDelete(key)) } diff --git a/bindings/go/generator/generate.sh b/bindings/go/generator/generate.sh index 7fdf0fca..6bb5db8a 100755 --- a/bindings/go/generator/generate.sh +++ b/bindings/go/generator/generate.sh @@ -4,7 +4,7 @@ # generate.sh # # 元数据来自库,不依赖库的 profile;dev 与 release 构建生成的结果必须一致。 -# 只改写两个生成文件,同目录的手写文件(link.go)保持不变。生成结果提交入库, +# 只改写生成文件(两个绑定文件与 generated_sources.go),同目录的手写文件(link.go)保持不变。生成结果提交入库, # CI 重新生成后要求零差异;禁止手改生成文件,修正只能走 generator/*.patch。 set -euo pipefail @@ -19,3 +19,14 @@ trap 'rm -rf "$work"' EXIT for file in uc_engine_uniffi.go uc_engine_uniffi.h; do cp "$work/uc_engine_uniffi/$file" "$module_dir/uc_engine_uniffi/$file" done + +# 把两个生成文件的摘要编译进包,使 native.Verify 能核对来源清单与实际编译的绑定一致。 +digest="$(cd "$module_dir/uc_engine_uniffi" && shasum -a 256 uc_engine_uniffi.go uc_engine_uniffi.h | shasum -a 256 | cut -d' ' -f1)" +cat > "$module_dir/uc_engine_uniffi/generated_sources.go" <&2 + exit 1 +fi + +# 全部值经环境变量交给 python,避免命令输出中的引号或 $ 破坏脚本。 +UC_MANIFEST_OUT="$out/native-manifest.json" \ +UC_REVISION="$revision" \ +UC_VERSION="$version" \ +UC_LOCK_SHA256="$(sha256_of Cargo.lock)" \ +UC_UNIFFI_VERSION="$uniffi_version" \ +UC_TARGET="$(rustc -vV | sed -n 's/^host: //p')" \ +UC_PROFILE="$profile" \ +UC_RUSTC="$(rustc --version)" \ +UC_CARGO="$(cargo --version | tail -1)" \ +UC_GENERATOR_REVISION="$UNIFFI_BINDGEN_GO_REVISION" \ +UC_GENERATOR_TAG="$UNIFFI_BINDGEN_GO_TAG" \ +UC_GENERATOR_LOCK_SHA256="$UNIFFI_BINDGEN_GO_LOCK_SHA256" \ +UC_GENERATOR_PATCH_SHA256="$UNIFFI_BINDGEN_GO_PATCH_SHA256" \ +UC_GENERATED_SHA256="$(cd bindings/go/uc_engine_uniffi && shasum -a 256 uc_engine_uniffi.go uc_engine_uniffi.h | shasum -a 256 | cut -d' ' -f1)" \ +UC_LIBRARY_FILE="libuc_engine_uniffi.$ext" \ +UC_LIBRARY_SHA256="$(sha256_of "$staged")" \ +UC_LIBRARY_SIZE="$(stat -f%z "$staged" 2>/dev/null || stat -c%s "$staged")" \ +UC_RAW_SHA256="$raw_sha256" \ +python3 - <<'PY' +import json, os +e = os.environ manifest = { "schema": 1, - "engine_revision": "$(git rev-parse HEAD)", - "engine_version": "$version", - "cargo_lock_sha256": "$(sha256_of Cargo.lock)", - "uniffi_version": "$uniffi_version", - "target": "$(rustc -vV | sed -n 's/^host: //p')", - "profile": "$profile", + "engine_revision": e["UC_REVISION"], + "engine_version": e["UC_VERSION"], + "cargo_lock_sha256": e["UC_LOCK_SHA256"], + "uniffi_version": e["UC_UNIFFI_VERSION"], + "target": e["UC_TARGET"], + "profile": e["UC_PROFILE"], "features": [], - "rustc": "$(rustc --version)", - "cargo": "$(cargo --version | tail -1)", + "rustc": e["UC_RUSTC"], + "cargo": e["UC_CARGO"], "generator": { - "revision": "$UNIFFI_BINDGEN_GO_REVISION", - "tag": "$UNIFFI_BINDGEN_GO_TAG", - "lock_sha256": "$UNIFFI_BINDGEN_GO_LOCK_SHA256", - "patch_sha256": "$UNIFFI_BINDGEN_GO_PATCH_SHA256", + "revision": e["UC_GENERATOR_REVISION"], + "tag": e["UC_GENERATOR_TAG"], + "lock_sha256": e["UC_GENERATOR_LOCK_SHA256"], + "patch_sha256": e["UC_GENERATOR_PATCH_SHA256"], }, - "generated_sources_sha256": "$generated_sha256", + "generated_sources_sha256": e["UC_GENERATED_SHA256"], "library": { - "file": "libuc_engine_uniffi.$ext", - "sha256": "$(sha256_of "$staged")", - "size": $(stat -f%z "$staged" 2>/dev/null || stat -c%s "$staged"), - "cargo_artifact_sha256": "$raw_sha256", + "file": e["UC_LIBRARY_FILE"], + "sha256": e["UC_LIBRARY_SHA256"], + "size": int(e["UC_LIBRARY_SIZE"]), + "cargo_artifact_sha256": e["UC_RAW_SHA256"], }, } -open(sys.argv[1], "w").write(json.dumps(manifest, indent=2) + "\n") +with open(e["UC_MANIFEST_OUT"], "w") as handle: + handle.write(json.dumps(manifest, indent=2) + "\n") PY echo "staged $staged" diff --git a/bindings/go/native/verify.go b/bindings/go/native/verify.go index 887c27b2..ca2c5142 100644 --- a/bindings/go/native/verify.go +++ b/bindings/go/native/verify.go @@ -13,6 +13,8 @@ import ( "io" "os" "path/filepath" + "runtime" + "strings" "sync" ffi "github.com/UniClipboard/Engine/bindings/go/uc_engine_uniffi" @@ -60,6 +62,10 @@ var ( ) // Verify 读取清单并核对实际加载的原生库;同一路径在进程内只做一次完整校验。 +// +// 这是完整性与一致性自检:能发现版本错配、陈旧库、目标不符和与已编译绑定不一致的清单, +// 但清单与库通常在同一目录,它不是认证,也不防御有本地写权限的攻击者。校验对象是动态链接器 +// 报告的文件路径上的内容;静态链接(库不是独立文件)时库名比较失败,按错配拒绝。 func Verify(manifestPath string) (*Manifest, error) { absolute, err := filepath.Abs(manifestPath) if err != nil { @@ -94,10 +100,16 @@ func readManifest(path string) (*Manifest, error) { return nil, fmt.Errorf("%w: manifest schema %d", ErrMismatch, manifest.Schema) } for field, value := range map[string]string{ - "engine_revision": manifest.EngineRevision, - "engine_version": manifest.EngineVersion, - "library.file": manifest.Library.File, - "library.sha256": manifest.Library.SHA256, + "engine_revision": manifest.EngineRevision, + "engine_version": manifest.EngineVersion, + "cargo_lock_sha256": manifest.CargoLockSHA256, + "target": manifest.Target, + "profile": manifest.Profile, + "generator.revision": manifest.Generator.Revision, + "generator.patch_sha256": manifest.Generator.PatchSHA256, + "generated_sources_sha256": manifest.GeneratedSourcesSHA256, + "library.file": manifest.Library.File, + "library.sha256": manifest.Library.SHA256, } { if value == "" { return nil, fmt.Errorf("%w: manifest field %s is empty", ErrMismatch, field) @@ -106,7 +118,21 @@ func readManifest(path string) (*Manifest, error) { return &manifest, nil } +// targetMatches 判断清单的 Rust 目标三元组是否对应当前 Go 进程的 GOOS/GOARCH。 +func targetMatches(target string) bool { + arch := map[string]string{"arm64": "aarch64", "amd64": "x86_64"}[runtime.GOARCH] + osName := map[string]string{"darwin": "apple-darwin", "linux": "linux", "windows": "windows"}[runtime.GOOS] + return arch != "" && osName != "" && + strings.HasPrefix(target, arch+"-") && strings.Contains(target, osName) +} + func checkLoadedLibrary(manifest *Manifest) error { + if !targetMatches(manifest.Target) { + return fmt.Errorf("%w: manifest target does not match this process", ErrMismatch) + } + if manifest.GeneratedSourcesSHA256 != ffi.GeneratedSourcesSHA256 { + return fmt.Errorf("%w: manifest was produced for different generated bindings", ErrMismatch) + } if got, want := ffi.CoreVersion(), "v"+manifest.EngineVersion; got != want { return fmt.Errorf("%w: core version %s, manifest %s", ErrMismatch, got, want) } diff --git a/bindings/go/uc_engine_uniffi/generated_sources.go b/bindings/go/uc_engine_uniffi/generated_sources.go new file mode 100644 index 00000000..1598c553 --- /dev/null +++ b/bindings/go/uc_engine_uniffi/generated_sources.go @@ -0,0 +1,6 @@ +// 由 generator/generate.sh 生成,勿手改:uc_engine_uniffi.go 与 uc_engine_uniffi.h 的合并摘要。 + +package uc_engine_uniffi + +// GeneratedSourcesSHA256 是两个生成文件的合并 sha256,来源清单的 generated_sources_sha256 必须与之相同。 +const GeneratedSourcesSHA256 = "a79faeb44cf0f35e7eba6f4a199e2aad9834451161d335015c1353577e84a7b0" diff --git a/bindings/go/uc_engine_uniffi/link.go b/bindings/go/uc_engine_uniffi/link.go index 8679fd04..338f9906 100644 --- a/bindings/go/uc_engine_uniffi/link.go +++ b/bindings/go/uc_engine_uniffi/link.go @@ -1,7 +1,7 @@ // 手写文件:cgo 编译与链接指令。生成文件由 generator/generate.sh 重写,本文件不受影响。 // // 头文件随模块分发;原生库不在 Go module 内,由宿主构建环境经 CGO_LDFLAGS 提供 -L 与 rpath, -// 见 ../native/README.md。动态库身份由 ../native 的清单校验。 +// 见 ../README.md。动态库身份由 ../native 的清单校验。 package uc_engine_uniffi diff --git a/docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md b/docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md index af064e31..fa6abe8d 100644 --- a/docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md +++ b/docs/design-docs/decisions/034-go-binding-via-generated-uniffi.md @@ -12,7 +12,7 @@ - 复用现有 UniFFI(`=0.31.1`)元数据,用 NordSecurity `uniffi-bindgen-go` 固定 revision 生成 Go/cgo 包;生成器自身 `Cargo.lock` 与模板补丁的 sha256 固定在 `bindings/go/generator/PIN.env`,不进入本仓 workspace 和 `Cargo.lock`。 - 上游模板的局部变量与用户方法参数同名时生成物无法编译;修复只通过生成器源码补丁交付,禁止手改生成文件。生成物提交入库,CI 重新生成要求零差异。 - Go 门面只做 Go 侧所有权:一次 `Open`、调用 `uc-engine` 既有动作、读取事件、确定性 `Close`、稳定错误与输入校验。业务流程、恢复与重试仍由 Rust 负责。 -- 原生库不进入 Go module。`stage-native.sh` 为库生成来源清单(Engine revision、`Cargo.lock` sha256、目标、profile、工具链、生成器 pin、库 sha256/size),`Open` 强制核对动态链接器实际映射的库,没有跳过模式。 +- 原生库不进入 Go module。`stage-native.sh` 为库生成来源清单(Engine revision、`Cargo.lock` sha256、目标、profile、工具链、生成器 pin、库 sha256/size),`Open` 强制核对清单与动态链接器报告的库文件(完整性自检,不防御有本地写权限的攻击者),没有跳过模式。 - 第一片不修改 Rust 源码与公共 UniFFI 表面,因此 Swift/Kotlin 契约与移动 pin 不受影响。 ## 取舍与代价 diff --git a/docs/exec-plans/active/2026-10-07-go-binding.md b/docs/exec-plans/active/2026-10-07-go-binding.md index bb282a09..b24f07a0 100644 --- a/docs/exec-plans/active/2026-10-07-go-binding.md +++ b/docs/exec-plans/active/2026-10-07-go-binding.md @@ -1,6 +1,6 @@ # Go binding 基础 -状态:失败模型与验收契约已先行;实现按本文顺序分片。关联研究:t-0196。基线:main `e86f94cebcec46c1b3a6f49f88cce7a833777640`。 +状态:失败模型与验收契约已先行;实现按本文顺序分片。关联研究:Engine Go binding 调研(生成器可行性、失败边界与 API 清单)。基线:main `e86f94cebcec46c1b3a6f49f88cce7a833777640`。 ## 目标与边界 @@ -22,20 +22,20 @@ Engine 仓库拥有一个可重复生成、可 `import` 的版本化 Go module | # | 失败 | 契约 | |---|---|---| | F1 | 上游原样生成器因局部变量撞名无法编译 | 原失败证据保留;补丁只通过生成器源码补丁交付,禁止手改生成后的 Go 文件;重新生成必须字节一致 | -| F2 | 补丁只修已知撞名,其他模板局部变量仍可能与用户参数同名 | 审计 VTableImpl/callback/async 模板的全部局部名;验收为完整组件编译,不称通用卫生修复 | +| F2 | 补丁只修已知撞名,其他模板局部变量仍可能与用户参数同名 | 模板引入的局部名统一加 `_uniffi` 前缀;验收为完整组件编译,不称通用卫生修复。回调分发函数的 `uniffi*`/`callStatus` 形参仍未加前缀;async 回调分支当前组件不含,未被编译覆盖 | | F3 | 生成物与 native 库错配(版本、UniFFI contract、API checksum) | 生成包 init 的 checksum 检查必须失败即 panic;facade 另在 Open 时核对 `core_version` 与来源清单 | -| F4 | 加载了非预期的动态库(路径、替换、旧库) | facade 通过 `dladdr` 取实际加载路径,对其计算 sha256 并与来源清单比对;不一致返回 `ErrNativeMismatch`。Windows 暂不支持该校验,明确返回不支持而非静默通过 | -| F5 | 来源清单缺失或字段不符 | 校验失败即拒绝启动,不降级为未验证模式;清单含 Engine revision、`Cargo.lock` sha256、目标、profile、toolchain、features、生成器 revision 与补丁 hash、库 sha256/size | +| F4 | 加载了非预期的动态库(路径、替换、旧库) | facade 通过 `dladdr` 取动态链接器报告的文件路径,对该文件计算 sha256 并与来源清单比对;不一致返回 `native.ErrMismatch`。这是完整性自检而非认证,不防御有本地写权限的攻击者。Windows 暂不支持,明确返回不支持而非静默通过 | +| F5 | 来源清单缺失或字段不符 | 校验失败即拒绝启动,不降级为未验证模式;清单含 Engine revision、`Cargo.lock` sha256、目标、profile、toolchain、features、生成器 revision 与补丁 hash、生成源摘要、库 sha256/size。运行期要求关键字段齐全,并比较目标、生成源摘要、`core_version` 与库文件;`Cargo.lock`、profile、生成器字段与工具链字段只记录,由构建流程与 CI 保证 | | F6 | Go 零值枚举/必填字段转 Rust 时 panic | facade 在越界前校验所有输入枚举与必填字段,返回 `ErrInvalidInput`;不得依赖生成层 panic | | F7 | Rust release `panic=abort`、段错误或 OOM | Go `recover` 无效,进程直接退出;契约明确声明。嵌入后宿主与 Engine 同生共死,不再有进程隔离。崩溃隔离作为 daemon 重写评审时的显式取舍,不默认嵌入更优。GUI 仍可保持为独立进程经 HTTP 连接 daemon | | F8 | Close 与进行中的调用并发 | Close 先标记关闭,不持锁调用 `shutdown(deadline)`(这会关闭事件队列并唤醒 `next_event`),再取写锁等待在途调用排空,最后 Destroy。重复 Close 幂等;Close 后调用返回 `ErrClosed`,不 panic | | F9 | Go `context` 取消被误当作 Rust 取消 | 只让调用方停止等待;Rust 调用继续,Close 仍等待被放弃的调用。文档与测试明确 | | F10 | `Destroy` 被误当作 shutdown | `Destroy` 只释放引用。唯一关闭边界是 `shutdown(deadline)` 成功返回与 worker join;deadline 超时返回错误且不声称已停止,可重试 | | F11 | 事件消费者落后 | Rust 侧容量 256,丢最旧并给出 `RefreshRequired(ConsumerLagged)`;Go 不再设第二层丢弃缓冲。消费者收到后重新查询权威状态 | -| F12 | 宿主回调重入同一 Engine 的阻塞 API 造成环形等待 | 回调只能返回能力结果;facade 文档禁止在回调内调用同一实例。E2E 用带超时的真实进程断言重入被拒绝或有界失败,不允许无限挂起 | -| F13 | 回调返回的类型化宿主错误丢失 | 往返断言 `PermissionDenied`、`Unavailable` 映射到 `BindingError` 且 `errors.Is` 成立 | +| F12 | 宿主回调重入同一 Engine 的阻塞 API 造成环形等待 | 回调只能返回能力结果;facade 文档禁止在回调内调用同一实例。本片的 facade 没有能在 Open 之后触发宿主回调的操作,因此不提供真实进程用例,仅作文档约束;随首个会回调宿主的能力补入时同步补验收 | +| F13 | 回调返回的类型化宿主错误丢失 | 目录回调的 `PermissionDenied` 往返为同一稳定错误;启动期间安全存储失败由 Engine 归类为稳定的 `1101`;回调 panic 转为 `ErrHostIO` | | F14 | 重启后加密 profile 不可读 | 安全存储以临时文件持久化,第二个进程用同一 profile 重启并断言同一本地设备身份 | -| F15 | 测试触碰真实 profile、钥匙串、剪贴板或网络 | 全部使用临时目录和内存/文件 host;剪贴板与文件回调返回 Unavailable;E2E 在 macOS `sandbox-exec` 的拒绝网络配置下运行,网络不可达本身即证据 | +| F15 | 测试触碰真实 profile、钥匙串、剪贴板或网络 | 全部使用临时目录和文件 host;剪贴板与文件回调返回 Unavailable;E2E 在 macOS `sandbox-exec` 内运行:外网(含 IP 字面量与 UDP)被拒,只允许 bind 与回环;文件写入限于证据目录,真实钥匙串目录不可读,HOME/TMPDIR 指向证据目录。负控制与沙箱外正控制(CI 强制)一并记录,正控制失败时报告 `isolation_proven: false` | | F16 | 日志泄露内容或秘密 | 观测只写本地文件到临时目录;E2E 在日志与 stdout/stderr 中扫描哨兵字符串,必须零命中 | | F17 | 并发调用过载 | Engine 命令队列无界;本片不引入限流,文档声明并发调用语义,调用方负责背压 | | F18 | 跨目标构建被当作原生验证 | 仅 macOS arm64 做本机链接与真实进程;其他目标只记录实际执行的生成/编译/link 检查,交叉编译不记通过 | diff --git a/scripts/architecture/check-go-binding.mjs b/scripts/architecture/check-go-binding.mjs index 77681a42..73cdecfb 100644 --- a/scripts/architecture/check-go-binding.mjs +++ b/scripts/architecture/check-go-binding.mjs @@ -26,10 +26,10 @@ assert.equal( const generated = join(goDir, 'uc_engine_uniffi') assert.ok(existsSync(join(generated, 'uc_engine_uniffi.go')) && existsSync(join(generated, 'uc_engine_uniffi.h'))) assert.match(readFileSync(join(generated, 'LICENSE-uniffi-bindgen-go'), 'utf8'), /Mozilla Public License Version 2\.0/) -// 生成目录只允许两个生成文件、手写 link.go 与许可证;其余入口说明有人把手写代码混入生成包。 +// 生成目录只允许生成文件、手写 link.go 与许可证;其余入口说明有人把手写代码混入生成包。 assert.deepEqual( readdirSync(generated).sort(), - ['LICENSE-uniffi-bindgen-go', 'link.go', 'uc_engine_uniffi.go', 'uc_engine_uniffi.h'], + ['LICENSE-uniffi-bindgen-go', 'generated_sources.go', 'link.go', 'uc_engine_uniffi.go', 'uc_engine_uniffi.h'], ) // go 指令不得高于 Desktop 声明的 1.26,避免把消费者工具链强行抬高。 diff --git a/tests/hosts/go/negative.go b/tests/hosts/go/negative.go index de95a3d8..e5cae04f 100644 --- a/tests/hosts/go/negative.go +++ b/tests/hosts/go/negative.go @@ -140,8 +140,38 @@ func runNegative(result *report, root, manifest string) { second := slow.Close(20 * time.Second) _, after := slow.LocalDevice(ctx) result.record("close_deadline_then_retry_succeeds", - second == nil && errors.Is(during, engine.ErrClosed) && errors.Is(after, engine.ErrClosed), - map[string]any{"first_close": errString(first), "second_close": errString(second)}) + second == nil && errors.Is(during, engine.ErrClosed) && errors.Is(after, engine.ErrClosed) && + (first == nil || errors.Is(first, engine.ErrCloseIncomplete)), + map[string]any{"first_close": errString(first), "second_close": errString(second), "retry_path_exercised": first != nil}) + } + + // 多个 goroutine 同时 Close:全部返回,至多一个真正执行关闭,没有 panic。 + multi, err := openEngine(mustHost(filepath.Join(root, "multi-close")), manifest) + if result.record("open_for_concurrent_close", err == nil, errString(err)) { + var group sync.WaitGroup + results := make([]error, 8) + panics := 0 + var panicMu sync.Mutex + for i := range results { + group.Add(1) + go func(i int) { + defer group.Done() + defer func() { + if recover() != nil { + panicMu.Lock() + panics++ + panicMu.Unlock() + } + }() + results[i] = multi.Close(20 * time.Second) + }(i) + } + group.Wait() + allNil := true + for _, closeErr := range results { + allNil = allNil && closeErr == nil + } + result.record("concurrent_close_is_serialized", panics == 0 && allNil, map[string]any{"panics": panics}) } hits, scanErr := scanForLeaks(root, []string{profileID}, host.secrets) @@ -176,3 +206,11 @@ func isShutdownRace(err error) bool { var typed *engine.EngineError return errors.As(err, &typed) && typed.Category == engine.CategoryInvalidState } + +func mustHost(root string) *fileHost { + host, err := newFileHost(root) + if err != nil { + panic(err) + } + return host +} diff --git a/tests/hosts/go/run-e2e.mjs b/tests/hosts/go/run-e2e.mjs index ab7d0cad..e4673f56 100644 --- a/tests/hosts/go/run-e2e.mjs +++ b/tests/hosts/go/run-e2e.mjs @@ -1,6 +1,6 @@ // Go 绑定真实进程验收驱动。 // -// node tests/hosts/go/run-e2e.mjs --native --evidence <新的证据目录> [--go ] +// node tests/hosts/go/run-e2e.mjs --native --evidence <新的证据目录> [--go ] [--require-network-positive-control] // // 在 macOS 沙箱(拒绝全部网络)内依次运行三个独立进程:lifecycle(启动→查询→类型化错误→宿主回调→事件→ // 关闭)、restart(同一 profile 重启并核对身份)、negative(输入校验、清单错配、并发关闭等)。 @@ -8,16 +8,19 @@ // 只读写 --evidence 与其下的隔离根目录,不触碰真实 profile、钥匙串、剪贴板或网络。 import { spawnSync } from 'node:child_process' import { createHash } from 'node:crypto' -import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs' +import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs' import { join, resolve } from 'node:path' const options = new Map() -for (let index = 2; index < process.argv.length; index += 2) { - options.set(process.argv[index], process.argv[index + 1]) +const args = process.argv.slice(2).filter((arg) => arg !== '--require-network-positive-control') +for (let index = 0; index < args.length; index += 2) { + options.set(args[index], args[index + 1]) } const native = resolve(options.get('--native') ?? '') const evidence = resolve(options.get('--evidence') ?? '') const go = options.get('--go') ?? 'go' +// CI 加此开关:沙箱外同一访问必须成功,才能证明“拒绝”来自沙箱而不是机器本身离线。 +const requirePositiveControl = process.argv.includes('--require-network-positive-control') if (!options.has('--native') || !options.has('--evidence')) { console.error('usage: run-e2e.mjs --native DIR --evidence DIR [--go PATH]') process.exit(2) @@ -74,23 +77,50 @@ const build = run('go-build', go, ['build', '-o', binary, '.'], { env: { CGO_ENABLED: '1', CGO_LDFLAGS: `-L${native} -Wl,-rpath,${native}` }, }) +const evidenceReal = realpathSync(evidence) +const isolatedHome = join(evidenceReal, 'home') +const isolatedTmp = join(evidenceReal, 'tmp') +mkdirSync(isolatedHome, { recursive: true, mode: 0o700 }) +mkdirSync(isolatedTmp, { recursive: true, mode: 0o700 }) +const realHome = process.env.HOME ?? '' + // 启动会绑定本机 P2P 套接字,因此允许 bind 与回环;其余入站/出站(含 DNS、中继、局域网发现)一律拒绝。 +// 文件写入只允许证据目录与 /dev,读取拒绝真实用户的钥匙串目录;HOME 与 TMPDIR 改指证据目录。 const sandboxProfile = [ '(version 1)(allow default)(deny network*)', '(allow network-bind)', '(allow network* (local ip "localhost:*") (remote ip "localhost:*"))', + `(deny file-write* (require-not (require-any (subpath "${evidenceReal}") (subpath "/dev"))))`, + realHome ? `(deny file-read* (subpath "${realHome}/Library/Keychains"))` : '', ].join('') -const sandboxed = (name, args, extra) => - run(name, '/usr/bin/sandbox-exec', ['-p', sandboxProfile, ...args], extra) +const sandboxed = (name, args, extra = {}) => + run(name, '/usr/bin/sandbox-exec', ['-p', sandboxProfile, ...args], { + ...extra, + env: { HOME: isolatedHome, TMPDIR: `${isolatedTmp}/`, ...(extra.env ?? {}) }, + }) -// 控制实验:同一沙箱下真实网络访问必须失败,否则“离线”不成立。 -const control = sandboxed('network-control', ['/usr/bin/curl', '-sS', '--max-time', '5', 'https://example.com/'], { +// 控制实验。正控制:沙箱外同一访问应成功,否则无法区分“沙箱拒绝”与“本机离线”。 +// 负控制:沙箱内域名 TCP、IP 字面量 TCP、UDP 与越界文件写入都必须被拒绝。 +const curlArgs = (url) => ['/usr/bin/curl', '-sS', '--max-time', '5', '-o', '/dev/null', url] +const outside = run('network-positive-control-outside-sandbox', curlArgs('https://example.com/')[0], curlArgs('https://example.com/').slice(1), { timeoutMs: 20_000, }) -const networkDenied = control.exit !== 0 +const controlDns = sandboxed('network-control-dns', curlArgs('https://example.com/'), { timeoutMs: 20_000 }) +const controlIp = sandboxed('network-control-ip-tcp', curlArgs('https://1.1.1.1/'), { timeoutMs: 20_000 }) +const udpProbe = + "import socket,sys\ns=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)\ns.settimeout(2)\ntry:\n s.sendto(b'x',('1.1.1.1',53))\nexcept OSError:\n sys.exit(0)\nsys.exit(1)" +const controlUdp = sandboxed('network-control-ip-udp', ['python3', '-c', udpProbe], { timeoutMs: 20_000 }) +const writeProbe = join(realpathSync('/private/tmp'), `uc-go-binding-write-probe-${process.pid}`) +const controlWrite = sandboxed('file-write-control', ['/usr/bin/touch', writeProbe], { timeoutMs: 20_000 }) +const writeEscaped = existsSync(writeProbe) +if (writeEscaped) rmSync(writeProbe) +const networkDenied = + controlDns.exit !== 0 && controlIp.exit !== 0 && controlUdp.exit === 0 && controlWrite.exit !== 0 && !writeEscaped +const positiveControl = outside.exit === 0 +const isolationProven = networkDenied && positiveControl const phases = [] -if (build.exit === 0 && networkDenied) { +if (build.exit === 0 && networkDenied && (!requirePositiveControl || positiveControl)) { const root = join(evidence, 'root') const negativeRoot = join(evidence, 'root-negative') mkdirSync(root, { recursive: true, mode: 0o700 }) @@ -144,13 +174,28 @@ const sourceIdentity = { const allOk = build.exit === 0 && networkDenied && + (!requirePositiveControl || positiveControl) && sourceIdentity.matches && phases.length === 3 && phases.every((phase) => phase.ok) const summary = { ok: allOk, source_identity: sourceIdentity, - network_isolation: { mechanism: 'sandbox-exec (deny network*; allow bind and loopback only)', profile: sandboxProfile, control_exit: control.exit, denied: networkDenied }, + isolation: { + mechanism: 'sandbox-exec: network denied except bind and loopback; file writes limited to the evidence directory; real Keychains directory unreadable; HOME/TMPDIR redirected', + profile: sandboxProfile.replace(realHome, ''), + controls: { + outside_sandbox_exit: outside.exit, + sandbox_dns_tcp_exit: controlDns.exit, + sandbox_ip_tcp_exit: controlIp.exit, + sandbox_udp_denied: controlUdp.exit === 0, + sandbox_out_of_tree_write_exit: controlWrite.exit, + out_of_tree_file_created: writeEscaped, + }, + denied: networkDenied, + positive_control_succeeded: positiveControl, + isolation_proven: isolationProven, + }, tools: toolVersions, native: { manifest: manifest, From 3f9a2a2c917eb4569a319fd8fa4b1fa3efc0c471 Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:31:16 -0700 Subject: [PATCH 10/13] fix(go-binding): deny non-loopback egress in acceptance sandbox --- tests/hosts/go/run-e2e.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/hosts/go/run-e2e.mjs b/tests/hosts/go/run-e2e.mjs index e4673f56..0738cde8 100644 --- a/tests/hosts/go/run-e2e.mjs +++ b/tests/hosts/go/run-e2e.mjs @@ -89,7 +89,8 @@ const realHome = process.env.HOME ?? '' const sandboxProfile = [ '(version 1)(allow default)(deny network*)', '(allow network-bind)', - '(allow network* (local ip "localhost:*") (remote ip "localhost:*"))', + '(allow network-outbound (remote ip "localhost:*"))', + '(allow network-inbound (local ip "localhost:*"))', `(deny file-write* (require-not (require-any (subpath "${evidenceReal}") (subpath "/dev"))))`, realHome ? `(deny file-read* (subpath "${realHome}/Library/Keychains"))` : '', ].join('') From de0416facf2e726273ad78beca3692fd2d4a6d26 Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 07:49:10 -0700 Subject: [PATCH 11/13] fix(go-binding): resolve loaded library via dlsym, harden close and CI filters --- .github/workflows/go-binding.yml | 10 ++++++++++ bindings/go/engine/engine.go | 6 +++++- bindings/go/native/loaded_unix.go | 7 ++++--- docs/exec-plans/active/2026-10-07-go-binding.md | 2 +- tests/hosts/go/main.go | 6 ++++-- tests/hosts/go/negative.go | 6 ++++++ 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/go-binding.yml b/.github/workflows/go-binding.yml index 757e108a..abadcce2 100644 --- a/.github/workflows/go-binding.yml +++ b/.github/workflows/go-binding.yml @@ -27,7 +27,11 @@ on: - crates/uc-engine/** - Cargo.toml - Cargo.lock + - rust-toolchain.toml + - scripts/build-cache/** + - scripts/architecture/check-go-binding.mjs - tests/hosts/go/** + - .github/workflows/go-binding.yml permissions: contents: read @@ -77,6 +81,7 @@ jobs: run: | bash bindings/go/generator/generate.sh "$RUNNER_TEMP/generator/bin/uniffi-bindgen-go" target/debug/libuc_engine_uniffi.dylib git diff --exit-code -- bindings/go/uc_engine_uniffi + test -z "$(git status --porcelain --untracked-files=all -- bindings/go/uc_engine_uniffi)" - name: Build release library and stage with provenance manifest run: | @@ -162,6 +167,11 @@ jobs: (cd tests/hosts/go && go build -o "$RUNNER_TEMP/go-engine-host" .) ldd "$RUNNER_TEMP/go-engine-host" | grep libuc_engine_uniffi + # 只运行来源校验(不启动 Engine):证明 Linux 上 dladdr 解析到的是共享库而不是可执行文件。 + - name: Verify native library identity at runtime + run: | + "$RUNNER_TEMP/go-engine-host" --phase verify --root "$RUNNER_TEMP/verify-root" --manifest "$RUNNER_TEMP/native/native-manifest.json" + - name: Retain MBX compiler evidence if: always() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 diff --git a/bindings/go/engine/engine.go b/bindings/go/engine/engine.go index ceab542a..85129fe7 100644 --- a/bindings/go/engine/engine.go +++ b/bindings/go/engine/engine.go @@ -134,7 +134,11 @@ func call[T any](ctx context.Context, e *Engine, fn func(*ffi.MobileEngine) (T, // 生成层的 panic(例如对象已释放)不能终止宿主进程;Rust 侧的 abort 不在此列。 defer func() { if recover() != nil { - done <- outcome{err: ErrUnexpectedResult} + // 缓冲只有一格:结果可能已写入,恢复分支不得阻塞,否则 end() 永不执行、Close 一直等到期限。 + select { + case done <- outcome{err: ErrUnexpectedResult}: + default: + } } }() value, err := fn(e.inner) diff --git a/bindings/go/native/loaded_unix.go b/bindings/go/native/loaded_unix.go index cede3fc8..cff4fef3 100644 --- a/bindings/go/native/loaded_unix.go +++ b/bindings/go/native/loaded_unix.go @@ -8,11 +8,12 @@ package native #include #include -extern uint32_t ffi_uc_engine_uniffi_uniffi_contract_version(void); - +// 经 dlsym 取符号:直接取导入函数的地址在 Linux 上可能得到可执行文件内的 PLT 桩, +// dladdr 会返回可执行文件而不是共享库。 static const char *uc_loaded_library_path(void) { + void *symbol = dlsym(RTLD_DEFAULT, "ffi_uc_engine_uniffi_uniffi_contract_version"); Dl_info info; - if (dladdr((void *)ffi_uc_engine_uniffi_uniffi_contract_version, &info) == 0) { + if (symbol == 0 || dladdr(symbol, &info) == 0) { return 0; } return info.dli_fname; diff --git a/docs/exec-plans/active/2026-10-07-go-binding.md b/docs/exec-plans/active/2026-10-07-go-binding.md index b24f07a0..d48365f4 100644 --- a/docs/exec-plans/active/2026-10-07-go-binding.md +++ b/docs/exec-plans/active/2026-10-07-go-binding.md @@ -40,7 +40,7 @@ Engine 仓库拥有一个可重复生成、可 `import` 的版本化 Go module | F17 | 并发调用过载 | Engine 命令队列无界;本片不引入限流,文档声明并发调用语义,调用方负责背压 | | F18 | 跨目标构建被当作原生验证 | 仅 macOS arm64 做本机链接与真实进程;其他目标只记录实际执行的生成/编译/link 检查,交叉编译不记通过 | | F19 | 公共 UniFFI 表面变化破坏 Swift/Kotlin | 第一片不改 Rust 表面。任何后续新增必须加性,并运行 `bindings/uc-engine-uniffi` 契约测试 | -| F20 | 生成物许可证头丢失 | 生成包保留模板 MPL header,并随附生成器 LICENSE;检查脚本断言存在 | +| F20 | 生成物许可证义务丢失 | 生成器不在输出文件中写入许可证头;MPL-2.0 许可证文本随生成包保留为 `LICENSE-uniffi-bindgen-go`,静态检查断言其存在,生成文件的来源与补丁记录在 `generator/PIN.env`。生成文件本身不带 MPL 头,这是上游模板的行为 | ## 验收契约 diff --git a/tests/hosts/go/main.go b/tests/hosts/go/main.go index cf3c6a6d..e7e3a59e 100644 --- a/tests/hosts/go/main.go +++ b/tests/hosts/go/main.go @@ -1,6 +1,6 @@ // 命令 go-engine-host 是 Go 绑定的真实进程验收宿主,不承载产品功能。 // -// go-engine-host --phase lifecycle|restart|negative --root <隔离目录> --manifest +// go-engine-host --phase lifecycle|restart|negative|verify --root <隔离目录> --manifest // // 每个阶段是一次独立进程:向 stdout 输出一个 JSON 结果,任一步失败则退出码为 1。 // 隔离目录之外不读写任何文件;网络隔离由外部驱动脚本(沙箱)保证。 @@ -36,7 +36,7 @@ func (r *report) record(name string, ok bool, detail any) bool { } func main() { - phase := flag.String("phase", "", "lifecycle, restart or negative") + phase := flag.String("phase", "", "lifecycle, restart, negative or verify") root := flag.String("root", "", "isolated root directory") manifest := flag.String("manifest", "", "native-manifest.json path") flag.Parse() @@ -52,6 +52,8 @@ func main() { runRestart(result, *root, *manifest) case "negative": runNegative(result, *root, *manifest) + case "verify": + runVerify(result, *manifest) default: fmt.Fprintln(os.Stderr, "unknown phase") os.Exit(2) diff --git a/tests/hosts/go/negative.go b/tests/hosts/go/negative.go index e5cae04f..9ef2ebe8 100644 --- a/tests/hosts/go/negative.go +++ b/tests/hosts/go/negative.go @@ -214,3 +214,9 @@ func mustHost(root string) *fileHost { } return host } + +// runVerify 只核对原生库来源,不启动 Engine;供没有沙箱的平台(Linux CI)确认库身份解析正确。 +func runVerify(result *report, manifest string) { + _, err := native.Verify(manifest) + result.record("native_verify_loaded_library", err == nil, errString(err)) +} From 807f9ec235b200a03eff7cf02f4dfc013aff500d Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 08:57:05 -0700 Subject: [PATCH 12/13] ci(go-binding): report leaked build paths and cache the pinned generator --- .github/workflows/go-binding.yml | 9 +++++++++ bindings/go/native/build-native.sh | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go-binding.yml b/.github/workflows/go-binding.yml index abadcce2..adfc3631 100644 --- a/.github/workflows/go-binding.yml +++ b/.github/workflows/go-binding.yml @@ -71,7 +71,16 @@ jobs: node scripts/architecture/check-go-binding.mjs test -z "$(gofmt -l bindings/go/engine bindings/go/native bindings/go/uc_engine_uniffi/link.go bindings/go/uc_engine_uniffi/generated_sources.go tests/hosts/go)" + # 生成器按固定 revision 与补丁构建,输入不变时复用(无缓存的构建约 45 分钟)。 + - name: Restore pinned generator + id: generator-cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/generator + key: uniffi-bindgen-go-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('bindings/go/generator/PIN.env', 'bindings/go/generator/template-local-names.patch', 'bindings/go/generator/build-generator.sh', 'rust-toolchain.toml') }} + - name: Build pinned generator + if: steps.generator-cache.outputs.cache-hit != 'true' run: bash bindings/go/generator/build-generator.sh "$RUNNER_TEMP/generator" - name: Build development library for interface metadata diff --git a/bindings/go/native/build-native.sh b/bindings/go/native/build-native.sh index 5c90bfd1..33b20feb 100755 --- a/bindings/go/native/build-native.sh +++ b/bindings/go/native/build-native.sh @@ -31,5 +31,14 @@ case "$(uname -s)" in *) echo "unsupported host: $(uname -s)" >&2; exit 1 ;; esac [[ -f "$library" ]] || { echo "missing $library" >&2; exit 1; } -verify_release_paths "$library" +if ! (verify_release_paths "$library") 2>/dev/null; then + # 构建机路径不是秘密;列出命中的前缀与样例,便于定位新的路径来源。 + for prefix in ${RELEASE_PATH_REMAP_PREFIXES[@]+"${RELEASE_PATH_REMAP_PREFIXES[@]}"}; do + if LC_ALL=C grep -a -F -q -- "$prefix" "$library"; then + echo "leaked prefix: $prefix" >&2 + LC_ALL=C strings -a "$library" | grep -F -- "$prefix" | sort | uniq -c | sort -rn | head -5 >&2 + fi + done + exit 1 +fi echo "built $library" From 2bf8ed272e58d1a7b6524f59934f3851a4ff15ad Mon Sep 17 00:00:00 2001 From: mkdir700 Date: Wed, 7 Oct 2026 09:14:09 -0700 Subject: [PATCH 13/13] fix(go-binding): check build paths on the staged library after rewriting install_name --- bindings/go/native/build-native.sh | 14 +++----------- bindings/go/native/stage-native.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bindings/go/native/build-native.sh b/bindings/go/native/build-native.sh index 33b20feb..d2429053 100755 --- a/bindings/go/native/build-native.sh +++ b/bindings/go/native/build-native.sh @@ -4,7 +4,7 @@ # build-native.sh # # release 与移动包使用同一发布配置(panic=abort、LTO、符号剥离)并重映射构建机路径, -# 构建后断言产物不含本机路径。随后用 stage-native.sh 整理交付目录并写入来源清单。 +# 路径检查在 stage-native.sh 改写 install_name 之后进行。随后用 stage-native.sh 整理交付目录并写入来源清单。 set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -31,14 +31,6 @@ case "$(uname -s)" in *) echo "unsupported host: $(uname -s)" >&2; exit 1 ;; esac [[ -f "$library" ]] || { echo "missing $library" >&2; exit 1; } -if ! (verify_release_paths "$library") 2>/dev/null; then - # 构建机路径不是秘密;列出命中的前缀与样例,便于定位新的路径来源。 - for prefix in ${RELEASE_PATH_REMAP_PREFIXES[@]+"${RELEASE_PATH_REMAP_PREFIXES[@]}"}; do - if LC_ALL=C grep -a -F -q -- "$prefix" "$library"; then - echo "leaked prefix: $prefix" >&2 - LC_ALL=C strings -a "$library" | grep -F -- "$prefix" | sort | uniq -c | sort -rn | head -5 >&2 - fi - done - exit 1 -fi +# cdylib 自带指向构建目录的 install_name(LC_ID_DYLIB),属于预期;路径检查在 stage-native.sh +# 改写 install_name 之后对交付库执行。 echo "built $library" diff --git a/bindings/go/native/stage-native.sh b/bindings/go/native/stage-native.sh index 541053d0..496bee66 100755 --- a/bindings/go/native/stage-native.sh +++ b/bindings/go/native/stage-native.sh @@ -54,6 +54,14 @@ else patchelf --set-soname libuc_engine_uniffi.so "$staged" fi +# 交付库不得含构建机路径。cargo 产物的 install_name 指向构建目录,上面已改写为 @rpath; +# 其余来源(panic 位置、调试信息)由发布构建的路径重映射消除,这里与移动包使用同一检查。 +REPO_ROOT="$repo_root" +TARGET_DIR="$target_dir" +BUILD_PROFILE="$profile" +source "$repo_root/bindings/uc-engine-uniffi/scripts/release-path-remap.sh" +verify_release_paths "$staged" + version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" uniffi_version="$(sed -n 's/^uniffi = "=\(.*\)"/\1/p' bindings/uc-engine-uniffi/Cargo.toml)" revision="$(git rev-parse HEAD)"