---
source: boltffi_bindgen/src/render/typescript/templates.rs
expression: template.render().unwrap()
---
/**
 * A user record
 */
export interface User {
  readonly id: number;
  /**
   * The user's display name
   */
  readonly name: string;
}

const UserCodec: WireCodec<User> = {
  size: (v) => 4 + wireStringSize(v.name),
  encode: (writer, v) => {
    writer.writeI32(v.id);
    writer.writeString(v.name);
  },
  decode: (reader) => {
    return {
      id: reader.readI32(),
      name: reader.readString(),
    };
  },
};
