# automatically generated by the FlatBuffers compiler, do not modify

# namespace: xbrmm

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


class IPFSFile(object):
    __slots__ = ["_tab"]

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = IPFSFile()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsIPFSFile(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)

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

    # metadata (IPFS Multihash).
    # IPFSFile
    def FileHash(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # Whether the relevant file was downloaded from Infura
    # IPFSFile
    def Downloaded(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return False

    # Number of download attempts in case of failure
    # IPFSFile
    def Retries(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
        return 0

    # Timestamp of last error to download
    # IPFSFile
    def ErroredAt(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0


def IPFSFileStart(builder):
    builder.StartObject(4)


def Start(builder):
    IPFSFileStart(builder)


def IPFSFileAddFileHash(builder, fileHash):
    builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(fileHash), 0)


def AddFileHash(builder, fileHash):
    IPFSFileAddFileHash(builder, fileHash)


def IPFSFileAddDownloaded(builder, downloaded):
    builder.PrependBoolSlot(1, downloaded, 0)


def AddDownloaded(builder, downloaded):
    IPFSFileAddDownloaded(builder, downloaded)


def IPFSFileAddRetries(builder, retries):
    builder.PrependUint32Slot(2, retries, 0)


def AddRetries(builder, retries):
    IPFSFileAddRetries(builder, retries)


def IPFSFileAddErroredAt(builder, erroredAt):
    builder.PrependUint64Slot(3, erroredAt, 0)


def AddErroredAt(builder, erroredAt):
    IPFSFileAddErroredAt(builder, erroredAt)


def IPFSFileEnd(builder):
    return builder.EndObject()


def End(builder):
    return IPFSFileEnd(builder)
