// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { MailMessage, MailMessageT } from '../diplomail/mail-message.js';


export class MessageGetResponse implements flatbuffers.IUnpackableObject<MessageGetResponseT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):MessageGetResponse {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsMessageGetResponse(bb:flatbuffers.ByteBuffer, obj?:MessageGetResponse):MessageGetResponse {
  return (obj || new MessageGetResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsMessageGetResponse(bb:flatbuffers.ByteBuffer, obj?:MessageGetResponse):MessageGetResponse {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new MessageGetResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

message(obj?:MailMessage):MailMessage|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? (obj || new MailMessage()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

static startMessageGetResponse(builder:flatbuffers.Builder) {
  builder.startObject(1);
}

static addMessage(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, messageOffset, 0);
}

static endMessageGetResponse(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static createMessageGetResponse(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset):flatbuffers.Offset {
  MessageGetResponse.startMessageGetResponse(builder);
  MessageGetResponse.addMessage(builder, messageOffset);
  return MessageGetResponse.endMessageGetResponse(builder);
}

unpack(): MessageGetResponseT {
  return new MessageGetResponseT(
    (this.message() !== null ? this.message()!.unpack() : null)
  );
}


unpackTo(_o: MessageGetResponseT): void {
  _o.message = (this.message() !== null ? this.message()!.unpack() : null);
}
}

export class MessageGetResponseT implements flatbuffers.IGeneratedObject {
constructor(
  public message: MailMessageT|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const message = (this.message !== null ? this.message!.pack(builder) : 0);

  return MessageGetResponse.createMessageGetResponse(builder,
    message
  );
}
}
