(ctx: EncodeContext, layout: ReasonLayout, value: unknown, w: Writer)
| 3297 | } |
| 3298 | |
| 3299 | function encodeReason(ctx: EncodeContext, layout: ReasonLayout, value: unknown, w: Writer) { |
| 3300 | const reason = value as Cause.Reason<unknown> |
| 3301 | switch (reason._tag) { |
| 3302 | case "Fail": |
| 3303 | w.byte(0) |
| 3304 | encodeValue(ctx, layout.error, reason.error, w) |
| 3305 | return |
| 3306 | case "Die": |
| 3307 | w.byte(1) |
| 3308 | encodeValue(ctx, layout.defect, reason.defect, w) |
| 3309 | return |
| 3310 | case "Interrupt": |
| 3311 | if (reason.fiberId === undefined) { |
| 3312 | w.byte(2) |
| 3313 | } else { |
| 3314 | w.byte(3) |
| 3315 | w.f64(reason.fiberId) |
| 3316 | } |
| 3317 | } |
| 3318 | } |
| 3319 | |
| 3320 | // `keyBytes` stays undefined while every key is ASCII, where code unit order |
| 3321 | // and length already match raw UTF-8. |
no test coverage detected