---
source: boltffi_bindgen/src/render/typescript/templates.rs
expression: template.render().unwrap()
---
/**
 * Byte-sized enum
 */
export enum ByteState {
  None = 0,
  Some = 255,
}

const ByteStateCodec: WireCodec<ByteState> = {
  size: (_v) => 4,
  encode: (writer, v) => {
    switch (v) {
      case ByteState.None:
        writer.writeI32(0);
        break;
      case ByteState.Some:
        writer.writeI32(1);
        break;
    }
  },
  decode: (reader) => {
    const value = reader.readI32();
    switch (value) {
      case 0: return ByteState.None;
      case 1: return ByteState.Some;
      default: throw new Error(`Unknown ByteState wire tag: ${value}`);
    }
  },
};
