// Code generated by the FlatBuffers compiler. DO NOT EDIT.

package fbast

import (
	flatbuffers "github.com/google/flatbuffers/go"
)

type Duration struct {
	_tab flatbuffers.Table
}

func GetRootAsDuration(buf []byte, offset flatbuffers.UOffsetT) *Duration {
	n := flatbuffers.GetUOffsetT(buf[offset:])
	x := &Duration{}
	x.Init(buf, n+offset)
	return x
}

func (rcv *Duration) Init(buf []byte, i flatbuffers.UOffsetT) {
	rcv._tab.Bytes = buf
	rcv._tab.Pos = i
}

func (rcv *Duration) Table() flatbuffers.Table {
	return rcv._tab
}

func (rcv *Duration) Magnitude() int64 {
	o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
	if o != 0 {
		return rcv._tab.GetInt64(o + rcv._tab.Pos)
	}
	return 0
}

func (rcv *Duration) MutateMagnitude(n int64) bool {
	return rcv._tab.MutateInt64Slot(4, n)
}

func (rcv *Duration) Unit() TimeUnit {
	o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
	if o != 0 {
		return rcv._tab.GetInt8(o + rcv._tab.Pos)
	}
	return 0
}

func (rcv *Duration) MutateUnit(n TimeUnit) bool {
	return rcv._tab.MutateInt8Slot(6, n)
}

func DurationStart(builder *flatbuffers.Builder) {
	builder.StartObject(2)
}
func DurationAddMagnitude(builder *flatbuffers.Builder, magnitude int64) {
	builder.PrependInt64Slot(0, magnitude, 0)
}
func DurationAddUnit(builder *flatbuffers.Builder, unit int8) {
	builder.PrependInt8Slot(1, unit, 0)
}
func DurationEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
	return builder.EndObject()
}
