Ecosyste.ms: Repos

An open API service providing repository metadata for many open source software ecosystems.

Package Usage: go: github.com/surrealdb/cork

CORK is a dynamic and static binary object serialization specification similar to GOB and MessagePack. CORK manages encoding and decoding binary data streams, for use in transmission of, or storage of data. A CORK data stream is self-describing. Each data item in the stream is preceded by a description of its type, expressed in terms of a small set of predefined types. Pointers to values are not transmitted, but the contents are flattened and transmitted. To use cork, create an Encoder and present it with a series of data items as values or addresses that can be dereferenced to values. The Encoder makes sure all type information is sent before it is needed. At the receive side, a Decoder retrieves values from the encoded stream and unpacks them into local variables. CORK has built in support for the built-in Golang types When a struct is encountered whilst encoding (and that struct does not satisfy the Corker interface) then the struct will be encoded into the stream as a map with the keys encoded as strings, and the values as the relevant type. Any struct tags describing how the struct should be encoded will be used. CORK allows applications to define application-specific types to be added to the encoding format. Each extended type must be assigned a unique byte from 0x00 upto 0xFF. Application-specific types (otherwise known as Corkers) are able to encode themselves into a binary data value, and are able to decode themselves from that same binary data value. To define a custom type, an application must ensure that the type satisfies the Corker interface, and must then register the type using the Register method. If a custom type is found in the stream when decoding, but no type with the specified unique byte is registered, then the binary data value will be decoded as a raw binary data value. The source and destination values/types need not correspond exactly. For structs, fields (identified by name) that are in the source but absent from the receiving variable will be ignored. Fields that are in the receiving variable but missing from the transmitted type or value will be ignored in the destination. If a field with the same name is present in both, their types must be compatible. Both the receiver and transmitter will do all necessary indirection and dereferencing to convert between cork encoded data and actual Go values. For instance, a cork type that is schematically, can be sent from or received into any of these Go types: It may also be received into any of these: Attempting to receive into these types will draw a decode error: Integers can be serialized using two different methods: arbritrary precision or full precision. When using arbritrary precision, integers (int, int8, int16, int32, int64) and unsinged integers (uint, uint8, uint16, uint32, uint64) are encoded with a variable-length encoding using as few bytes as possible, and are decoded into the destination variable, or an integer with the necessary capacity (when decoding into a nil interface). When using full precision, all integers (int8, int16, int32, int64) and unsinged integers (uint8, uint16, uint32, uint64) are encoded with a fixed-length encoding format, and are able to be decoded into the corresponding variable type when decoding into a nil interface. Signed integers may be received into any signed integer variable: int, int16, etc.; unsigned integers may be received into any unsigned integer variable; and floating point values may be received into any floating point variable. However, the destination variable must be able to represent the value or the decode operation will fail. Structs, arrays and slices are also supported. Structs encode and decode only exported fields. Struct tags (using the 'cork' descriptor) can specify custom key names to be used when serailizing, and can be omitted entirely, or when empty using the 'omitempty' tag keyword. Strings and arrays of bytes are supported with a special, efficient representation. When a slice is decoded, if the existing slice has capacity the slice will be extended in place; if not, a new array is allocated. Regardless, the length of the resulting slice reports the number of elements decoded. In general, if allocation is required, the decoder will allocate memory. If not, it will update the destination variables with values read from the stream. It does not initialize them first, so if the destination is a compound value such as a map, struct, or slice, the decoded values will be merged elementwise into the existing variables. Functions and channels will not be encoded into a CORK. Attempting to encode such a value at the top level will fail. A struct field of chan or func type is treated exactly like an unexported field and is ignored. The full specification can be found at http://github.com/surrealdb/cork/SPEC.md
1 version
Latest release: over 2 years ago
1 dependent package

View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/surrealdb/cork

View more repository details: https://repos.ecosyste.ms/hosts/GitHub/repositories/surrealdb%2Fcork

Dependent Repos 1

kokizzu/kokizzu-benchmark
Benchmark sources in kokizzu.blogspot.com
  • v0.0.0-20211208110447-54ccd49930c9 ser-deser/go.mod
  • v0.0.0-20211208110447-54ccd49930c9 ser-deser/go.sum

Size: 43.3 MB - Last synced: about 1 month ago - Pushed: about 1 month ago

Marijius/akirataguchi115 Fork of akirataguchi115/akirataguchi115
yahhoo -wario 1996
  • v0.0.0-20211208110447-54ccd49930c9 go.mod
  • v0.0.0-20211208110447-54ccd49930c9 go.sum

Size: 788 KB - Last synced: 3 days ago - Pushed: 10 months ago

masfahru/masfahru
🍀
  • v0.0.0-20211208110447-54ccd49930c9 go.mod

Size: 2.14 MB - Last synced: about 2 months ago - Pushed: about 2 months ago