Dumps blob message to the writer.
        Supports both blob and raw value.

        :param writer:
        :param elem:
        :param elem_type:
        :param params:
        :return:
764836
async def blob_dump(self, elem, elem_type, params=None):
        
        elem_is_blob = isinstance(elem, x.BlobType)
        elem_params = elem if elem_is_blob or elem_type is None else elem_type
        data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem

        if len(data) != elem_params.SIZE:
            raise ValueError('Fixed size blob has not defined size: %s, path %s' % (elem_params.SIZE, self.tracker))

        await dump_uvarint(self.iobj, len(elem))
        await self.iobj.awrite(data)
460416
async def container_val(self, elem, container_type, params=None):
        
        if hasattr(container_type, "serialize_archive"):
            raise ValueError("not supported")
        if self.writing:
            return await self._dump_container_val(
                self.iobj, elem, container_type, params
            )
        else:
            raise ValueError("Not supported")
1196565
def write_to_blobs_file(raw, address)
      begin
        File.write(@blobs_file_name, raw, address)
      rescue IOError => e
        PEROBS.log.fatal "Cannot write blobs file #{@blobs_file_name}: " +
          e.message
      end
    end
92452
def dump_to_stream(self, cnf, stream, **opts):
        
        tree = container_to_etree(cnf, **opts)
        etree_write(tree, stream)
384116
def write(self, *args, **kwargs):
        
        return self.stream.write(ending="", *args, **kwargs)
832050
async def container_val(self, elem, container_type, params=None):
        
        if hasattr(container_type, 'boost_serialize'):
            raise ValueError('not supported')

        if self.writing:
            elem_type = params[0] if params else None
            if elem_type is None:
                elem_type = container_type.ELEM_TYPE

            await self.dump_field(elem, elem_type, params[1:] if params else None)

        else:
            raise ValueError('Not supported')
470899
async def blobize(self, elem=None, elem_type=None, params=None):
        
        if self.writing:
            await self.field(elem=elem, elem_type=elem_type, params=params)
            return bytes(self.iobj.buffer)
        else:
            return await self.field(elem=elem, elem_type=elem_type, params=params)
1322668
async def dump_blob(elem, elem_type=None):
    
    elem_is_blob = isinstance(elem, x.BlobType)
    data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem
    if data is None or len(data) == 0:
        return b''
    if isinstance(data, (bytes, bytearray, list)):
        return base64.b16encode(bytes(data))
    else:
        raise ValueError('Unknown blob type')
1190451
async def dump_message(self, msg, msg_type=None):
        
        mtype = msg.__class__ if msg_type is None else msg_type
        fields = mtype.f_specs()
        for field in fields:
            await self.message_field(msg=msg, field=field)
1158293
def Serialize(self, writer):
        
        self.SerializeUnsigned(writer)
        writer.WriteByte(1)
        self.Script.Serialize(writer)
1145165
def dumps(data):  # type: (_TOMLDocument) -> str
    
    if not isinstance(data, _TOMLDocument) and isinstance(data, dict):
        data = item(data)

    return data.as_string()
583596
def Serialize(self, writer):
        
        writer.WriteVarBytes(self.Script)
        writer.WriteVarBytes(self.ParameterList)
        writer.WriteByte(self.ReturnType)
25044
def _raw_write(self, data, debug_str = None):
        
        if self.debug:
            if not debug_str:
                debug_str = ''
            hexdump = yubico_util.hexdump(data, colorize=True)[:-1] # strip LF
            self._debug("WRITE : %s %s\n" % (hexdump, debug_str))
        request_type = _USB_TYPE_CLASS | _USB_RECIP_INTERFACE | _USB_ENDPOINT_OUT
        value = _REPORT_TYPE_FEATURE << 8    # apparently required for YubiKey 1.3.2, but not 2.2.x
        sent = self._usb_handle.controlMsg(request_type,
                                          _HID_SET_REPORT,
                                          data,
                                          value = value,
                                          timeout = _USB_TIMEOUT_MS)
        if sent != _FEATURE_RPT_SIZE:
            self.debug("Failed writing %i bytes (wrote %i) to USB HID YubiKey.\n"
                       % (_FEATURE_RPT_SIZE, sent))
            raise YubiKeyUSBHIDError('Failed talking to USB HID YubiKey')
        return sent
15932
def writeBytes(self, b):
        
        self.stream.write(TYPE_STRING)

        self.serialiseBytes(b)
354539
def Serialize(self, writer):
        
        try:
            writer.WriteByte(self.Type)
            writer.WriteHashes(self.Hashes)
        except Exception as e:
            logger.error(f"COULD NOT WRITE INVENTORY HASHES ({self.Type} {self.Hashes}) {e}")
879577
async def _dump_container(self, writer, container, container_type, params=None):
        
        await self._dump_container_size(writer, len(container), container_type)

        elem_type = container_elem_type(container_type, params)

        for idx, elem in enumerate(container):
            try:
                self.tracker.push_index(idx)
                await self.dump_field(
                    writer, elem, elem_type, params[1:] if params else None
                )
                self.tracker.pop()
            except Exception as e:
                raise helpers.ArchiveException(e, tracker=self.tracker) from e
1002187
async def dump_uvarint(writer, n):
    
    buffer = _UVARINT_BUFFER
    if n == 0:
        buffer[0] = 0
        return await writer.awrite(buffer)

    negative = n < 0
    ll = -n if negative else n

    size = 0
    while ll != 0:
        ll >>= 8
        size += 1

    buffer[0] = size
    await writer.awrite(buffer)

    ll = -n if negative else n

    # TODO: endianity, rev bytes if needed
    for _ in range(size):
        buffer[0] = ll & 0xff
        await writer.awrite(buffer)
        ll >>= 8