# automatically generated by the FlatBuffers compiler, do not modify

# namespace: fb

from __future__ import annotations

from typing import Any

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


class ValueAndUnit:
    __slots__ = ["_tab"]

    @classmethod
    def SizeOf(cls) -> int:
        return 8

    # ValueAndUnit
    def Init(self, buf: bytes, pos: int):
        self._tab = flatbuffers.table.Table(buf, pos)

    # ValueAndUnit
    def Value(self):
        return self._tab.Get(
            flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0)
        )

    # ValueAndUnit
    def Unit(self):
        return self._tab.Get(
            flatbuffers.number_types.Int8Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4)
        )


def CreateValueAndUnit(builder, value, unit):
    builder.Prep(4, 8)
    builder.Pad(3)
    builder.PrependInt8(unit)
    builder.PrependFloat32(value)
    return builder.Offset()
