MCPcopy
hub / github.com/openacid/slim / Encoder

Interface Encoder

encode/encoder.go:24–40  ·  view source on GitHub ↗

A Encoder converts one element between serialized byte stream and in-memory data structure.

Source from the content-addressed store, hash-verified

22// A Encoder converts one element between serialized byte stream
23// and in-memory data structure.
24type Encoder interface {
25 // Convert into serialized byte stream.
26 Encode(interface{}) []byte
27
28 // Read byte stream and convert it back to typed data.
29 Decode([]byte) (int, interface{})
30
31 // GetSize returns the size in byte after encoding v.
32 // If v is of type this encoder can not encode, it panics.
33 GetSize(v interface{}) int
34
35 // GetEncodedSize returns size of the encoded value.
36 // Encoded element may be var-length.
37 // This function is used to determine element size without the need of
38 // encoding it.
39 GetEncodedSize([]byte) int
40}
41
42// EncoderOf returns a `Encoder` implementation for type of `e`
43func EncoderOf(e interface{}) (Encoder, error) {

Callers 19

TestTypeEncoderEncodeFunction · 0.65
TestTypeEncoderDecodeFunction · 0.65
InitEltsMethod · 0.65
encodeValuesFunction · 0.65
subTestIterFunction · 0.65
subTestScanFunction · 0.65
Example_memoryUsageFunction · 0.65
TestTypeEncoderDecodeFunction · 0.65
GetMethod · 0.65
getIthLeafMethod · 0.65
getLabelsMethod · 0.65
getInnerBMMethod · 0.65

Implementers 13

U16encode/int.go
U32encode/int.go
U64encode/int.go
I16encode/int.go
I32encode/int.go
I64encode/int.go
String16encode/encoder.go
Intencode/nativeint.go
TypeEncoderencode/type_encoder.go
Bytesencode/bytes.go
I8encode/int8.go
Dummyencode/dummy.go

Calls

no outgoing calls

Tested by

no test coverage detected