MCPcopy Create free account
hub / github.com/0xsequence/czip / WriteNBytesRaw

Method WriteNBytesRaw

compressor/encode.go:329–349  ·  view source on GitHub ↗

Encodes N bytes, without any optimizations

(bytes []byte)

Source from the content-addressed store, hash-verified

327
328// Encodes N bytes, without any optimizations
329func (buf *Buffer) WriteNBytesRaw(bytes []byte) (EncodeType, error) {
330 if !buf.Allows(FLAG_READ_N_BYTES) {
331 return Stateless, fmt.Errorf("n bytes encoding is not allowed")
332 }
333
334 buf.commitUint(FLAG_READ_N_BYTES)
335 buf.end(bytes, Stateless)
336
337 t, err := buf.WriteWord(uintToBytes(uint64(len(bytes))), false)
338 if err != nil {
339 return Stateless, err
340 }
341
342 buf.commitBytes(bytes)
343
344 // end this last write without creating a flag pointer
345 // this is a data blob, not a flag
346 buf.end([]byte{}, t)
347
348 return t, nil
349}
350
351func (buf *Buffer) Encode4Bytes(bytes []byte) []byte {
352 // If Bytes4Indexes has this value, then we can just use the index

Callers 1

WriteBytesOptimizedMethod · 0.95

Calls 6

AllowsMethod · 0.95
commitUintMethod · 0.95
endMethod · 0.95
WriteWordMethod · 0.95
commitBytesMethod · 0.95
uintToBytesFunction · 0.85

Tested by

no test coverage detected