crdt

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Generated by the generator, DO NOT modify manually

Index

Constants

View Source
const (
	RecordNone uint64 = iota
	RecordInsert
	RecordDelete
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

type Doc[V any] struct {
	Producer uint64
	Clock    uint64
	Start    *Item[V]
}

func (*Doc[V]) Delete

func (d *Doc[V]) Delete(iid *IDType) bool

func (*Doc[V]) Insert

func (d *Doc[V]) Insert(iid *IDType, origin *IDType, rightOrigin *IDType, content V) bool

func (*Doc[V]) ItemAt

func (d *Doc[V]) ItemAt(offset int) *Item[V]

func (*Doc[V]) LocalDelete

func (d *Doc[V]) LocalDelete(offset int) *Item[V]

func (*Doc[V]) LocalInsert

func (d *Doc[V]) LocalInsert(offset int, content V) *Item[V]

type IDType

type IDType struct {
	//+field:natural
	Producer uint64 `tlv:"0xa1"`
	//+field:natural
	Clock uint64 `tlv:"0xa3"`
}

func ParseIDType

func ParseIDType(reader enc.ParseReader, ignoreCritical bool) (*IDType, error)

func (*IDType) Bytes

func (value *IDType) Bytes() []byte

func (*IDType) Encode

func (value *IDType) Encode() enc.Wire

func (*IDType) Equal

func (l *IDType) Equal(r *IDType) bool

Equal returns if two ids are equal

type IDTypeEncoder

type IDTypeEncoder struct {
	// contains filtered or unexported fields
}

func (*IDTypeEncoder) Encode

func (encoder *IDTypeEncoder) Encode(value *IDType) enc.Wire

func (*IDTypeEncoder) EncodeInto

func (encoder *IDTypeEncoder) EncodeInto(value *IDType, buf []byte)

func (*IDTypeEncoder) Init

func (encoder *IDTypeEncoder) Init(value *IDType)

type IDTypeParsingContext

type IDTypeParsingContext struct {
}

func (*IDTypeParsingContext) Init

func (context *IDTypeParsingContext) Init()

func (*IDTypeParsingContext) Parse

func (context *IDTypeParsingContext) Parse(reader enc.ParseReader, ignoreCritical bool) (*IDType, error)

type Item

type Item[V any] struct {
	ID          IDType
	Parent      *Doc[V]
	Left        *Item[V]
	Right       *Item[V]
	Origin      *IDType
	RightOrigin *IDType
	Content     V
	Deleted     bool
}

func (*Item[V]) Delete

func (i *Item[V]) Delete()

func (*Item[V]) InsertInto

func (i *Item[V]) InsertInto(d *Doc[V])

InsertInto inserts new item i (with Origin==Left and RightOrigin==Right) into d

func (*Item[V]) Next

func (i *Item[V]) Next() *Item[V]

Next returns next non-deleted item after i

func (*Item[V]) Prev

func (i *Item[V]) Prev() *Item[V]

Prev returns previous non-deleted item before i

type Record

type Record struct {
	//+field:natural
	RecordType uint64 `tlv:"0xa5"`
	//+field:struct:IDType
	ID *IDType `tlv:"0xa7"`
	//+field:struct:IDType
	Origin *IDType `tlv:"0xa9"`
	//+field:struct:IDType
	RightOrigin *IDType `tlv:"0xaa"`
	//+field:string
	Content string `tlv:"0xac"`
}

func ParseRecord

func ParseRecord(reader enc.ParseReader, ignoreCritical bool) (*Record, error)

func (*Record) Bytes

func (value *Record) Bytes() []byte

func (*Record) Encode

func (value *Record) Encode() enc.Wire

type RecordEncoder

type RecordEncoder struct {
	ID_encoder          IDTypeEncoder
	Origin_encoder      IDTypeEncoder
	RightOrigin_encoder IDTypeEncoder
	// contains filtered or unexported fields
}

func (*RecordEncoder) Encode

func (encoder *RecordEncoder) Encode(value *Record) enc.Wire

func (*RecordEncoder) EncodeInto

func (encoder *RecordEncoder) EncodeInto(value *Record, buf []byte)

func (*RecordEncoder) Init

func (encoder *RecordEncoder) Init(value *Record)

type RecordParsingContext

type RecordParsingContext struct {
	ID_context          IDTypeParsingContext
	Origin_context      IDTypeParsingContext
	RightOrigin_context IDTypeParsingContext
}

func (*RecordParsingContext) Init

func (context *RecordParsingContext) Init()

func (*RecordParsingContext) Parse

func (context *RecordParsingContext) Parse(reader enc.ParseReader, ignoreCritical bool) (*Record, error)

type TextDoc

type TextDoc struct {
	// contains filtered or unexported fields
}

func NewTextDoc

func NewTextDoc(producer uint64) *TextDoc

func (*TextDoc) Delete

func (td *TextDoc) Delete(offset int) *Record

func (*TextDoc) GetText

func (td *TextDoc) GetText() string

func (*TextDoc) HandleRecord

func (td *TextDoc) HandleRecord(record *Record)

func (*TextDoc) Insert

func (td *TextDoc) Insert(offset int, content string) *Record

Jump to

Keyboard shortcuts

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