# 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 GetRootAsIPFSFile(cls, buf, offset):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = IPFSFile()
        x.Init(buf, n + offset)
        return x

    # 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 IPFSFileAddFileHash(builder, fileHash): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(fileHash), 0)
def IPFSFileAddDownloaded(builder, downloaded): builder.PrependBoolSlot(1, downloaded, 0)
def IPFSFileAddRetries(builder, retries): builder.PrependUint32Slot(2, retries, 0)
def IPFSFileAddErroredAt(builder, erroredAt): builder.PrependUint64Slot(3, erroredAt, 0)
def IPFSFileEnd(builder): return builder.EndObject()
