Skip to content

Swift: Inspect

inspect() answers the same five-field snapshot KizunaSyncInspector.snapshot() reads, decoded as a plain dictionary rather than the typed KizunaSyncInspectorSnapshot. Most apps call Inspector instead; this method is the one the typed reading is built on.

Examples#

Basic#

// TodoApp/TodoListView.swift (excerpt)
import KizunaSync

let raw = try await kizunasync.inspect()
let depth = raw["depth"] as? Int ?? 0

Parameters#

NameTypeRequiredDescription
(none)——This method takes no arguments.

Returns#

[String: Any], decoded from the engine's JSON, with these keys.

NameTypeRequiredDescription
queued[[String: Any]]—The head of the outbox, oldest first.
depthInt—The same count Outbox depth returns.
last_mutation_idString?—The exactly-once push watermark: the mutation id of the last entry the server confirmed applied, not the last mutation queued. nil until a push lands.
cursorString—The durable pull cursor, also on Checkpoint.
client_idString—The client's current registered identity. It changes after Reset.

Errors#

CodeCondition
ENGINE_UNAVAILABLEThe bridge answered with bytes that do not decode to a JSON object.
ENGINE_UNAVAILABLEThe client has no engine because Initializing has not run.

Notes#

last_mutation_id is the watermark a completed push advances, not a record of what is queued. A device with ten mutations waiting in the outbox and none pushed answers nil here even though depth reads 10. Inspector wraps this call, adds the bounded verdict ring, and answers a typed KizunaSyncInspectorSnapshot. Reach for inspect() directly only when the raw dictionary is what the call site wants.

Found a problem? Edit this page on GitHub