import Foundation // Network awaits alone do not move JSON processing off the main actor. actor SheetWireWorker { func decode(_ data: Data) throws -> GridResponse { try JSONDecoder().decode(GridResponse.self, from: data) } func encode(_ writes: [CellWrite], startingAt offset: Int) throws -> (data: Data, count: Int) { struct Batch: Encodable { let cells: [CellWrite] } var count = min(500, writes.count - offset) var data = try JSONEncoder().encode(Batch(cells: Array(writes[offset.. 1 << 20 && count > 1 { count /= 2 data = try JSONEncoder().encode(Batch(cells: Array(writes[offset..