ClawdisKit: accept jpg for canvas.snapshot
This commit is contained in:
@@ -19,6 +19,24 @@ public struct ClawdisCanvasEvalParams: Codable, Sendable, Equatable {
|
||||
public enum ClawdisCanvasSnapshotFormat: String, Codable, Sendable {
|
||||
case png
|
||||
case jpeg
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let c = try decoder.singleValueContainer()
|
||||
let raw = try c.decode(String.self).trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
|
||||
switch raw {
|
||||
case "png":
|
||||
self = .png
|
||||
case "jpeg", "jpg":
|
||||
self = .jpeg
|
||||
default:
|
||||
throw DecodingError.dataCorruptedError(in: c, debugDescription: "Invalid snapshot format: \(raw)")
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var c = encoder.singleValueContainer()
|
||||
try c.encode(self.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
public struct ClawdisCanvasSnapshotParams: Codable, Sendable, Equatable {
|
||||
|
||||
Reference in New Issue
Block a user