Encode the contents of this update record without including a record header.

        Returns:
            bytearary: The encoded contents.
10344
def encode_contents(self):
        

        header = struct.pack("<LL", self.offset, len(self.raw_data))
        return bytearray(header) + self.raw_data
348801
def to_bytes(val):
    
    if val is NoResponse:
        return val
    val = val.replace('\\r', '\r').replace('\\n', '\n')
    return val.encode()
1195536
def encode(self, value):
        
        if self.decode_responses and isinstance(value, bytes):
            value = value.decode(self.encoding)
        elif not self.decode_responses and isinstance(value, str):
            value = value.encode(self.encoding)
        return value
1172185
def to_bytes(self):
        '''
        
        '''
        # Verify that properties make sense
        self.sanitize()

        # Start with the type
        bitstream = BitArray('uint:4=%d' % self.message_type)

        # Add padding
        bitstream += self._reserved1

        # Add the record count
        bitstream += BitArray('uint:8=%d' % len(self.records))

        # Add the nonce
        bitstream += BitArray(bytes=self.nonce)

        # Add the records
        for record in self.records:
            bitstream += record.to_bitstream()

        return bitstream.bytes
1043398
def to_bytes(self):
        '''
        
        '''
        # Verify that the properties make sense
        self.sanitize()

        # Write the next header type
        bitstream = BitStream('uint:8=%d' % self.next_header)

        # Add the reserved bits
        bitstream += BitStream(8)

        # Add the fragment offset
        bitstream += BitStream('uint:13=%d' % self.fragment_offset)

        # Add the reserved bits
        bitstream += BitStream(2)

        # Add the flags
        bitstream += BitStream('bool=%d' % self.more_fragments)

        # Add the identification
        bitstream += BitStream('uint:32=%d' % self.identification)

        return bitstream.bytes + bytes(self.payload)
542666
def update_contents(self, stream, seek=0, size=None, chunk_size=None,
                        progress_callback=None, **kwargs):
        
        self.checksum = None
        return self.storage(**kwargs).update(
            stream, seek=seek, size=size, chunk_size=chunk_size,
            progress_callback=progress_callback
        )
782438
def data_from_bytes(self, byte_representation):
        
        text = byte_representation.decode(self.encoding)
        return self.data_from_string(text)
474711
public byte[] encode() {
		char type = getAttributeType();
		byte binValue[] = new byte[HEADER_LENGTH + getDataLength()];

		// Type
		binValue[0] = (byte) (type >> 8);
		binValue[1] = (byte) (type & 0x00FF);

		// Length
		binValue[2] = (byte) (getDataLength() >> 8);
		binValue[3] = (byte) (getDataLength() & 0x00FF);

		return binValue;
	}
1000362
def encode (self):
    """"""
    byte = self.default

    for bit, name, value0, value1, default in SeqCmdAttrs.Table:
      if name in self.attrs:
        value = self.attrs[name]
        byte  = setBit(byte, bit, value == value1)

    return struct.pack('B', byte)
968939
public static byte[] recordToByteArray(GenericRecord record) throws IOException {
    try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
      Encoder encoder = EncoderFactory.get().directBinaryEncoder(out, null);
      DatumWriter<GenericRecord> writer = new GenericDatumWriter<>(record.getSchema());
      writer.write(record, encoder);
      byte[] byteArray = out.toByteArray();
      return byteArray;
    }
  }
722212
def encode_json(self, serializable):
        
        return json.dumps(serializable.serialize(), cls=self.encoder)
735312
def encode(self):
        """"""

        reading = self.visible_readings[0]
        data = struct.pack("<BBHLLLL", 0, 0, reading.stream, self.origin,
                           self.sent_timestamp, reading.raw_time, reading.value)

        return bytearray(data)
1122045
def encode(self):
        
        result = bytearray()
        result.append(self.id)
        result.append(self.dataLength)
        result.extend(self.data)
        return result
192764
async def serialize_archive(self, ar, version=None):
        
        # Transaction prefix serialization first.
        await ar.message(self, TransactionPrefix)

        if self.version == 1:
            await ar.tag('signatures')
            await ar.begin_array()
            await ar.prepare_container(len(self.vin), eref(self, 'signatures'), elem_type=SignatureArray)
            signatures_not_expected = len(self.signatures) == 0
            if not signatures_not_expected and len(self.vin) != len(self.signatures):
                raise ValueError('Signature size mismatch')

            for i in range(len(self.vin)):
                sig_size = get_signature_size(self.vin[i])
                if signatures_not_expected:
                    if 0 == sig_size:
                        continue
                    else:
                        raise ValueError('Unexpected sig')

                await ar.prepare_container(sig_size, eref(self.signatures, i), elem_type=SignatureArray)
                if sig_size != len(self.signatures[i]):
                    raise ValueError('Unexpected sig size')

                for j in range(sig_size):
                    await ar.field(eref(self.signatures[i], j), Signature)

        else:
            await ar.tag('rct_signatures')
            if len(self.vin) == 0:
                return

            await ar.begin_object()
            await ar.prepare_message(eref(self, 'rct_signatures'), RctSig)
            await self.rct_signatures.serialize_rctsig_base(ar, len(self.vin), len(self.vout))
            await ar.end_object()

            if self.rct_signatures.type != RctType.Null:
                mixin_size = len(self.vin[0].key_offsets) - 1 if len(self.vin) > 0 and isinstance(self.vin[0], TxinToKey) else 0
                await ar.tag('rctsig_prunable')
                await ar.begin_object()
                await ar.prepare_message(eref(self.rct_signatures, 'p'), RctSigPrunable)
                await self.rct_signatures.p.serialize_rctsig_prunable(ar, self.rct_signatures.type,
                                                                      len(self.vin), len(self.vout),
                                                                      mixin_size)
                await ar.end_object()
        return self
696110
def encode(self, V, P, X, CC, seqNum, M, PT, SSRC, payload):
        """"""
        timestamp = int(time())
        header = bytearray(HEADER_SIZE)
        # Fill the header bytearray with RTP header fields
        # ...
        header[0] = header[0] | V << 6; 
        header[0] = header[0] | P << 5; 
        header[0] = header[0] | X << 4; 
        header[0] = header[0] | CC; 
        header[1] = header[1] | M << 7; 
        header[1] = header[1] | PT; 
        header[2] = (seqNum >> 8) & 0xFF; 
        header[3] = seqNum & 0xFF; 
        header[4] = (timestamp >> 24) & 0xFF; 
        header[5] = (timestamp >> 16) & 0xFF;
        header[6] = (timestamp >> 8) & 0xFF;
        header[7] = timestamp & 0xFF;
        header[8] = (SSRC >> 24) & 0xFF; 
        header[9] = (SSRC >> 16) & 0xFF;
        header[10] = (SSRC >> 8) & 0xFF;
        header[11] = SSRC & 0xFF

        self.header = header
        
        # Get the payload
        # ...
        self.payload = payload
158541
def of_bytes(self, py_bytes):
        
        m = self.hash_algo()
        m.update(py_bytes)
        return self.digest(m)
255946
def to_bytes()
      packer = Packer.new()

      full_flags = ((@qr     << 15) & 0x8000) |
                   ((@opcode << 11) & 0x7800) |
                   ((@flags  <<  7) & 0x0780) |
                   ((@rcode  <<  0) & 0x000F)

      packer.pack('nnnnnn',
        @trn_id,             # trn_id
        full_flags,          # qr, opcode, flags, rcode
        @questions.length(), # qdcount
        @answers.length(),   # ancount
        0,                   # nscount (we don't handle)
        0,                   # arcount (we don't handle)
      )

      questions.each do |q|
        q.pack(packer)
      end

      answers.each do |a|
        a.pack(packer)
      end

      return packer.get()
    end