converter

package
v0.4.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package converter provides the converter for converting model to Protobuf, bytes and vice versa.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPackRequired is returned when an empty pack is passed.
	ErrPackRequired = errors.New("pack required")

	// ErrCheckpointRequired is returned when a pack with an empty checkpoint is
	// passed.
	ErrCheckpointRequired = errors.New("checkpoint required")

	// ErrUnsupportedOperation is returned when the given operation is not
	// supported yet.
	ErrUnsupportedOperation = errors.New("unsupported operation")

	// ErrUnsupportedElement is returned when the given element is not
	// supported yet.
	ErrUnsupportedElement = errors.New("unsupported element")

	// ErrUnsupportedEventType is returned when the given event type is not
	// supported yet.
	ErrUnsupportedEventType = errors.New("unsupported event type")

	// ErrUnsupportedValueType is returned when the given value type is not
	// supported yet.
	ErrUnsupportedValueType = errors.New("unsupported value type")

	// ErrUnsupportedCounterType is returned when the given counter type is not
	// supported yet.
	ErrUnsupportedCounterType = errors.New("unsupported counter type")
)

Functions

func ArrayToBytes added in v0.4.9

func ArrayToBytes(array *crdt.Array) ([]byte, error)

ArrayToBytes converts the given array to byte array.

func BytesToArray added in v0.4.9

func BytesToArray(snapshot []byte) (*crdt.Array, error)

BytesToArray creates a Array from the given byte array.

func BytesToObject

func BytesToObject(snapshot []byte) (*crdt.Object, error)

BytesToObject creates an Object from the given byte array.

func BytesToSnapshot added in v0.4.5

func BytesToSnapshot(snapshot []byte) (*crdt.Object, *innerpresence.Map, error)

BytesToSnapshot creates a Snapshot from the given byte array.

func BytesToTree added in v0.4.0

func BytesToTree(snapshot []byte) (*crdt.Tree, error)

BytesToTree creates a Tree from the given byte array.

func FromChangePack

func FromChangePack(pbPack *api.ChangePack) (*change.Pack, error)

FromChangePack converts the given Protobuf formats to model format.

func FromChanges added in v0.2.3

func FromChanges(pbChanges []*api.Change) ([]*change.Change, error)

FromChanges converts the given Protobuf formats to model format.

func FromDocumentID added in v0.3.3

func FromDocumentID(pbID string) (types.ID, error)

FromDocumentID converts the given Protobuf formats to model format.

func FromDocumentSummaries added in v0.2.13

func FromDocumentSummaries(pbSummaries []*api.DocumentSummary) []*types.DocumentSummary

FromDocumentSummaries converts the given Protobuf formats to model format.

func FromDocumentSummary added in v0.2.13

func FromDocumentSummary(pbSummary *api.DocumentSummary) *types.DocumentSummary

FromDocumentSummary converts the given Protobuf formats to model format.

func FromEventType

func FromEventType(pbDocEventType api.DocEventType) (types.DocEventType, error)

FromEventType converts the given Protobuf formats to model format.

func FromOperations

func FromOperations(pbOps []*api.Operation) ([]operations.Operation, error)

FromOperations converts the given Protobuf formats to model format.

func FromPresenceChange added in v0.4.5

func FromPresenceChange(pbPresenceChange *api.PresenceChange) *innerpresence.PresenceChange

FromPresenceChange converts the given Protobuf formats to model format.

func FromProject added in v0.2.4

func FromProject(pbProject *api.Project) *types.Project

FromProject converts the given Protobuf formats to model format.

func FromProjects added in v0.2.4

func FromProjects(pbProjects []*api.Project) []*types.Project

FromProjects converts the given Protobuf formats to model format.

func FromTreeNodes added in v0.4.0

func FromTreeNodes(pbNodes []*api.TreeNode) (*crdt.TreeNode, error)

FromTreeNodes converts protobuf tree nodes to crdt.TreeNode. The last node in the slice is the root node, because the slice is in post-order.

func FromTreeNodesWhenEdit added in v0.4.5

func FromTreeNodesWhenEdit(pbNodes []*api.TreeNodes) ([]*crdt.TreeNode, error)

FromTreeNodesWhenEdit converts protobuf tree nodes to array of crdt.TreeNode. in each element in array, the last node in slice is the root node, because the slice is in post-order.

func FromUpdatableProjectFields added in v0.2.8

func FromUpdatableProjectFields(pbProjectFields *api.UpdatableProjectFields) (*types.UpdatableProjectFields, error)

FromUpdatableProjectFields converts the given Protobuf formats to model format.

func FromUser added in v0.2.14

func FromUser(pbUser *api.User) *types.User

FromUser converts the given Protobuf formats to model format.

func ObjectToBytes

func ObjectToBytes(obj *crdt.Object) ([]byte, error)

ObjectToBytes converts the given object to byte array.

func SnapshotToBytes added in v0.4.5

func SnapshotToBytes(obj *crdt.Object, presences map[string]innerpresence.Presence) ([]byte, error)

SnapshotToBytes converts the given document to byte array.

func ToChangeID added in v0.1.10

func ToChangeID(id change.ID) *api.ChangeID

ToChangeID converts the given model format to Protobuf format.

func ToChangePack

func ToChangePack(pack *change.Pack) (*api.ChangePack, error)

ToChangePack converts the given model format to Protobuf format.

func ToChanges added in v0.2.3

func ToChanges(changes []*change.Change) ([]*api.Change, error)

ToChanges converts the given model format to Protobuf format.

func ToCheckpoint added in v0.1.10

func ToCheckpoint(cp change.Checkpoint) *api.Checkpoint

ToCheckpoint converts the given model format to Protobuf format.

func ToDocEventType added in v0.1.6

func ToDocEventType(eventType types.DocEventType) (api.DocEventType, error)

ToDocEventType converts the given model format to Protobuf format.

func ToDocumentSummaries added in v0.2.4

func ToDocumentSummaries(summaries []*types.DocumentSummary) []*api.DocumentSummary

ToDocumentSummaries converts the given model to Protobuf.

func ToDocumentSummary added in v0.2.4

func ToDocumentSummary(summary *types.DocumentSummary) *api.DocumentSummary

ToDocumentSummary converts the given model to Protobuf format.

func ToOperations

func ToOperations(ops []operations.Operation) ([]*api.Operation, error)

ToOperations converts the given model format to Protobuf format.

func ToPresence added in v0.4.5

func ToPresence(p innerpresence.Presence) *api.Presence

ToPresence converts the given model to Protobuf format.

func ToPresenceChange added in v0.4.5

func ToPresenceChange(p *innerpresence.PresenceChange) *api.PresenceChange

ToPresenceChange converts the given model to Protobuf format.

func ToPresences added in v0.4.5

func ToPresences(presences map[string]innerpresence.Presence) map[string]*api.Presence

ToPresences converts the given model to Protobuf format.

func ToProject added in v0.2.4

func ToProject(project *types.Project) *api.Project

ToProject converts the given model to Protobuf.

func ToProjects added in v0.2.4

func ToProjects(projects []*types.Project) []*api.Project

ToProjects converts the given model to Protobuf.

func ToTimeTicket added in v0.1.10

func ToTimeTicket(ticket *time.Ticket) *api.TimeTicket

ToTimeTicket converts the given model format to Protobuf format.

func ToTreeNodes added in v0.4.0

func ToTreeNodes(treeNode *crdt.TreeNode) []*api.TreeNode

ToTreeNodes converts a TreeNode to a slice of TreeNodes in post-order traversal.

func ToTreeNodesWhenEdit added in v0.4.5

func ToTreeNodesWhenEdit(treeNodes []*crdt.TreeNode) []*api.TreeNodes

ToTreeNodesWhenEdit converts a TreeNodes to a slice of two-dimensional array of TreeNodes in post-order traversal.

func ToUpdatableProjectFields added in v0.2.8

func ToUpdatableProjectFields(fields *types.UpdatableProjectFields) (*api.UpdatableProjectFields, error)

ToUpdatableProjectFields converts the given model format to Protobuf format.

func ToUser added in v0.2.14

func ToUser(user *types.User) *api.User

ToUser converts the given model format to Protobuf format.

func TreeToBytes added in v0.4.0

func TreeToBytes(tree *crdt.Tree) ([]byte, error)

TreeToBytes converts the given tree to byte array.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL