package bin

import (
	
)

// encodeBytes is same as encodeString, but for bytes.
func (,  []byte) []byte {
	 := len()
	if  <= maxSmallStringLength {
		 = append(, byte())
		 = append(, ...)
		 :=  + 1
		 = append(, make([]byte, nearestPaddedValueLength()-)...)
		return 
	}

	 = append(, firstLongStringByte, byte(), byte(>>8), byte(>>16))
	 = append(, ...)
	 :=  + 4
	 = append(, make([]byte, nearestPaddedValueLength()-)...)

	return 
}

// decodeBytes is same as decodeString, but for bytes.
//
// NB: v is slice of b.
func ( []byte) ( int,  []byte,  error) {
	if len() == 0 {
		return 0, nil, io.ErrUnexpectedEOF
	}
	if [0] == firstLongStringByte {
		if len() < 4 {
			return 0, nil, io.ErrUnexpectedEOF
		}
		 := uint32([1]) | uint32([2])<<8 | uint32([3])<<16
		if len() < (int() + 4) {
			return 0, nil, io.ErrUnexpectedEOF
		}
		return nearestPaddedValueLength(int() + 4), [4 : +4], nil
	}
	 := int([0])
	if len() < ( + 1) {
		return 0, nil, io.ErrUnexpectedEOF
	}
	if  > maxSmallStringLength {
		return 0, nil, &InvalidLengthError{
			Length: ,
			Where:  "bytes",
		}
	}
	return nearestPaddedValueLength( + 1), [1 : +1], nil
}