MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Serialize

Method Serialize

core/extensions/serialization.go:28–43  ·  view source on GitHub ↗

Serialize returns the Extension as a byte slice. If the Extension is invalid (invalid ExtName), then this returns a nil slice.

(ctx context.Context)

Source from the content-addressed store, hash-verified

26// Serialize returns the Extension as a byte slice. If the Extension is invalid (invalid ExtName), then this returns a
27// nil slice.
28func (ext Extension) Serialize(ctx context.Context) ([]byte, error) {
29 if !ext.ExtName.IsValid() {
30 return nil, nil
31 }
32
33 // Initialize the writer
34 writer := utils.NewWriter(256)
35 writer.VariableUint(0) // Version
36 // Write the extension data
37 writer.Id(ext.ExtName.AsId())
38 writer.Id(ext.Namespace.AsId())
39 writer.Bool(ext.Relocatable)
40 writer.String(string(ext.LibIdentifier))
41 // Returns the data
42 return writer.Data(), nil
43}
44
45// DeserializeExtension returns the Extension that was serialized in the byte slice. Returns an empty Extension (has an
46// invalid ID) if data is nil or empty.

Callers 1

HashOfMethod · 0.95

Calls 8

VariableUintMethod · 0.95
IdMethod · 0.95
BoolMethod · 0.95
StringMethod · 0.95
DataMethod · 0.95
NewWriterFunction · 0.92
IsValidMethod · 0.45
AsIdMethod · 0.45

Tested by

no test coverage detected