(typ, et, kt Type, buf []byte)
| 2048 | type BinaryEncoding struct{} |
| 2049 | |
| 2050 | func (b BinaryEncoding) EncodeEmpty(typ, et, kt Type, buf []byte) ([]byte, error) { |
| 2051 | switch typ { |
| 2052 | case BOOL: |
| 2053 | rt.GuardSlice(&buf, 1) |
| 2054 | b.EncodeBool(buf[len(buf):len(buf)+1], false) |
| 2055 | buf = buf[:len(buf)+1] |
| 2056 | case DOUBLE: |
| 2057 | rt.GuardSlice(&buf, 8) |
| 2058 | b.EncodeDouble(buf[len(buf):len(buf)+8], 0) |
| 2059 | buf = buf[:len(buf)+8] |
| 2060 | case I08: |
| 2061 | rt.GuardSlice(&buf, 1) |
| 2062 | b.EncodeByte(buf[len(buf):len(buf)+1], 0) |
| 2063 | buf = buf[:len(buf)+1] |
| 2064 | case I16: |
| 2065 | rt.GuardSlice(&buf, 2) |
| 2066 | b.EncodeInt16(buf[len(buf):len(buf)+2], 0) |
| 2067 | buf = buf[:len(buf)+2] |
| 2068 | case I32: |
| 2069 | rt.GuardSlice(&buf, 4) |
| 2070 | b.EncodeInt32(buf[len(buf):len(buf)+4], 0) |
| 2071 | buf = buf[:len(buf)+4] |
| 2072 | case I64: |
| 2073 | rt.GuardSlice(&buf, 8) |
| 2074 | b.EncodeInt64(buf[len(buf):len(buf)+8], 0) |
| 2075 | buf = buf[:len(buf)+8] |
| 2076 | case STRING: |
| 2077 | rt.GuardSlice(&buf, 4) |
| 2078 | b.EncodeString(buf[len(buf):len(buf)+4], "") |
| 2079 | buf = buf[:len(buf)+4] |
| 2080 | case STRUCT: |
| 2081 | rt.GuardSlice(&buf, 1) |
| 2082 | buf = append(buf, 0) |
| 2083 | case MAP: |
| 2084 | rt.GuardSlice(&buf, 6) |
| 2085 | buf = append(buf, byte(kt)) |
| 2086 | buf = append(buf, byte(et)) |
| 2087 | b.EncodeInt32(buf[len(buf):len(buf)+4], 0) |
| 2088 | buf = buf[:len(buf)+4] |
| 2089 | case LIST, SET: |
| 2090 | rt.GuardSlice(&buf, 5) |
| 2091 | buf = append(buf, byte(et)) |
| 2092 | b.EncodeInt32(buf[len(buf):len(buf)+4], 0) |
| 2093 | buf = buf[:len(buf)+4] |
| 2094 | default: |
| 2095 | return nil, errUnsupportedType |
| 2096 | } |
| 2097 | return buf, nil |
| 2098 | } |
| 2099 | |
| 2100 | // EncodeBool encodes a bool value. |
| 2101 | func (BinaryEncoding) EncodeBool(b []byte, v bool) { |
no test coverage detected