// 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 SendResponse implements flatbuffers.IUnpackableObject<SendResponseT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):SendResponse {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

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

static getSizePrefixedRootAsSendResponse(bb:flatbuffers.ByteBuffer, obj?:SendResponse):SendResponse {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new SendResponse()).__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 startSendResponse(builder:flatbuffers.Builder) {
  builder.startObject(1);
}

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

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

static createSendResponse(builder:flatbuffers.Builder, messageOffset:flatbuffers.Offset):flatbuffers.Offset {
  SendResponse.startSendResponse(builder);
  SendResponse.addMessage(builder, messageOffset);
  return SendResponse.endSendResponse(builder);
}

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


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

export class SendResponseT 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 SendResponse.createSendResponse(builder,
    message
  );
}
}
