slidge-whatsapp 0.2.7__cp313-cp313-manylinux_2_36_aarch64.whl → 0.3.0__cp313-cp313-manylinux_2_36_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of slidge-whatsapp might be problematic. Click here for more details.
- slidge_whatsapp/contact.py +15 -3
- slidge_whatsapp/event.go +144 -48
- slidge_whatsapp/gateway.go +7 -63
- slidge_whatsapp/gateway.py +2 -3
- slidge_whatsapp/generated/_whatsapp.cpython-313-aarch64-linux-gnu.h +167 -150
- slidge_whatsapp/generated/_whatsapp.cpython-313-aarch64-linux-gnu.so +0 -0
- slidge_whatsapp/generated/build.py +132 -118
- slidge_whatsapp/generated/whatsapp.c +1648 -1376
- slidge_whatsapp/generated/whatsapp.go +1198 -1087
- slidge_whatsapp/generated/whatsapp.py +1418 -1293
- slidge_whatsapp/generated/whatsapp_go.h +167 -150
- slidge_whatsapp/go.mod +18 -15
- slidge_whatsapp/go.sum +38 -26
- slidge_whatsapp/group.py +34 -30
- slidge_whatsapp/media/media.go +1 -1
- slidge_whatsapp/session.go +34 -17
- slidge_whatsapp/session.py +46 -14
- slidge_whatsapp/vendor/github.com/beeper/argo-go/LICENSE +9 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/block/blockreader.go +329 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/block/blockwriter.go +417 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/codec/decoder.go +652 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/codec/encoder.go +985 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/header/header.go +135 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/internal/util/util.go +133 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/label/label.go +384 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/label/wiremarkers.go +37 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/bitset/bitset.go +197 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/buf/buf.go +420 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/pkg/varint/varint.go +246 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/wire/wire.go +614 -0
- slidge_whatsapp/vendor/github.com/beeper/argo-go/wirecodec/decode.go +341 -0
- slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/LICENSE +21 -0
- slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/list.go +95 -0
- slidge_whatsapp/vendor/github.com/elliotchance/orderedmap/v3/orderedmap.go +187 -0
- slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz.go +1 -0
- slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz_cgo.go +3 -0
- slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/fitz_nocgo.go +4 -5
- slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_darwin.go +11 -1
- slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_linux.go +10 -0
- slidge_whatsapp/vendor/github.com/gen2brain/go-fitz/purego_windows.go +12 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/.gitignore +0 -2
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/CHANGELOG.md +30 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/COPYRIGHT.txt +6 -1
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/README.md +14 -17
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi.go +1 -1
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi2.go +7 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/LICENSE +21 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/darwin_amd64/libffi.8.dylib +0 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/darwin_arm64/libffi.8.dylib +0 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/assets/libffi/windows_amd64/libffi-8.dll +0 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/cif.go +15 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/cif_arm64.go +16 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed.go +49 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_darwin_amd64.go +10 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_darwin_arm64.go +10 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/embed_windows_amd64.go +10 -0
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/ffi.go +51 -13
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/init.go +22 -9
- slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/README.md +2 -0
- slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c +3096 -1651
- slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h +188 -128
- slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_userauth.go +13 -140
- slidge_whatsapp/vendor/github.com/mattn/go-sqlite3/sqlite3ext.h +4 -0
- slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.23.go +2 -2
- slidge_whatsapp/vendor/github.com/petermattis/goid/runtime_go1.25.go +37 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/LICENSE +19 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/argmap.go +37 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/collections.go +148 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/comment.go +31 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/decode.go +216 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/definition.go +110 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/directive.go +43 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/document.go +89 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/dumper.go +159 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/fragment.go +41 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/operation.go +32 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/path.go +72 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/selection.go +41 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/source.go +19 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/type.go +68 -0
- slidge_whatsapp/vendor/github.com/vektah/gqlparser/v2/ast/value.go +122 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exhttp/handleerrors.go +60 -26
- slidge_whatsapp/vendor/go.mau.fi/util/exhttp/networkerror.go +2 -1
- slidge_whatsapp/vendor/go.mau.fi/util/exstrings/stringutil.go +28 -0
- slidge_whatsapp/vendor/go.mau.fi/util/exsync/event.go +19 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/.pre-commit-config.yaml +3 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/decode.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate/hash.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/appstate.go +5 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/argo-wire-type-store.argo +63 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/argo.go +62 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/argo/name-to-queryids.json +306 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/armadillomessage.go +3 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +15 -18
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +5 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +4 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/errors.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +97 -25
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +22 -10
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +10 -9
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/msgsecret.go +2 -14
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/newsletter.go +83 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/notification.go +5 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/pair-code.go +2 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/presence.go +15 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.pb.go +5156 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waBotMetadata/WABotMetadata.proto +516 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.pb.go +30 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +8532 -11526
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +132 -438
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.pb.go +52 -23
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waHistorySync/WAWebProtobufsHistorySync.proto +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +225 -73
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +21 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +884 -441
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +40 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.pb.go +60 -38
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWa6/WAWebProtobufsWa6.proto +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +8 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +6 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/clientpayload.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/noop.go +3 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +25 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +3 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/call.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/events.go +8 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/jid.go +2 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/user.go +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +12 -8
- slidge_whatsapp/vendor/golang.org/x/crypto/curve25519/curve25519.go +1 -1
- slidge_whatsapp/vendor/golang.org/x/net/http2/config.go +44 -2
- slidge_whatsapp/vendor/golang.org/x/net/http2/gotrack.go +14 -3
- slidge_whatsapp/vendor/golang.org/x/net/http2/http2.go +7 -29
- slidge_whatsapp/vendor/golang.org/x/net/http2/server.go +53 -71
- slidge_whatsapp/vendor/golang.org/x/net/http2/transport.go +20 -74
- slidge_whatsapp/vendor/golang.org/x/sys/unix/affinity_linux.go +1 -3
- slidge_whatsapp/vendor/golang.org/x/sys/unix/mkerrors.sh +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_darwin.go +1 -55
- slidge_whatsapp/vendor/golang.org/x/sys/unix/syscall_solaris.go +1 -1
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux.go +47 -16
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +3 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +4 -4
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +1 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux.go +168 -12
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +17 -1
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +18 -2
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +17 -1
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +17 -1
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +18 -2
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +16 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/types_windows.go +6 -0
- slidge_whatsapp/vendor/golang.org/x/sys/windows/zsyscall_windows.go +483 -483
- slidge_whatsapp/vendor/google.golang.org/protobuf/encoding/protowire/wire.go +25 -1
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb +0 -0
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/editions.go +10 -5
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/filedesc/presence.go +33 -0
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/genid/api_gen.go +6 -0
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +68 -22
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/codec_message_opaque.go +2 -1
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/message_opaque.go +8 -37
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/impl/presence.go +0 -3
- slidge_whatsapp/vendor/google.golang.org/protobuf/internal/version/version.go +1 -1
- slidge_whatsapp/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +8 -0
- slidge_whatsapp/vendor/modules.txt +43 -23
- {slidge_whatsapp-0.2.7.dist-info → slidge_whatsapp-0.3.0.dist-info}/METADATA +5 -4
- {slidge_whatsapp-0.2.7.dist-info → slidge_whatsapp-0.3.0.dist-info}/RECORD +208 -161
- {slidge_whatsapp-0.2.7.dist-info → slidge_whatsapp-0.3.0.dist-info}/WHEEL +1 -1
- slidge_whatsapp/vendor/github.com/jupiterrider/ffi/abi_amd64.go +0 -7
- slidge_whatsapp/vendor/golang.org/x/net/http2/config_go124.go +0 -61
- slidge_whatsapp/vendor/golang.org/x/net/http2/config_pre_go124.go +0 -16
- slidge_whatsapp/vendor/golang.org/x/net/http2/timer.go +0 -20
- {slidge_whatsapp-0.2.7.dist-info → slidge_whatsapp-0.3.0.dist-info}/entry_points.txt +0 -0
- {slidge_whatsapp-0.2.7.dist-info → slidge_whatsapp-0.3.0.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
// Package block provides reader and writer types for processing Argo data blocks.
|
|
2
|
+
// These types handle different encoding strategies such as length-prefixing (with or without deduplication),
|
|
3
|
+
// fixed-size data, and unlabeled varints.
|
|
4
|
+
package block
|
|
5
|
+
|
|
6
|
+
import (
|
|
7
|
+
"fmt"
|
|
8
|
+
"io" // For io.EOF, io.ErrUnexpectedEOF
|
|
9
|
+
|
|
10
|
+
"github.com/beeper/argo-go/label"
|
|
11
|
+
"github.com/beeper/argo-go/pkg/buf"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
// FromBytesFunc is a generic function type that defines a conversion from a byte slice
|
|
15
|
+
// to a specific output type `Out`. It is used by various block readers to transform
|
|
16
|
+
// raw bytes read from a block into the desired data type.
|
|
17
|
+
// This corresponds to the `(bytes: Uint8Array) => Out` callback in the TypeScript Argo implementation.
|
|
18
|
+
type FromBytesFunc[Out any] func(bytes []byte) Out
|
|
19
|
+
|
|
20
|
+
// CommonState holds shared state for block readers, primarily the `DataBuf` from which
|
|
21
|
+
// block data is read. It also provides a default `AfterNewRead` hook.
|
|
22
|
+
// Embedding CommonState allows concrete reader types to share this buffer and default hook.
|
|
23
|
+
type CommonState struct {
|
|
24
|
+
// DataBuf is the buffer from which the actual data for this block is read.
|
|
25
|
+
// This is distinct from any "parent" buffer that might contain labels or references.
|
|
26
|
+
DataBuf buf.Read
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// AfterNewRead is a hook method called by some block readers after successfully reading
|
|
30
|
+
// and processing a new value from the block. The default implementation is a no-op.
|
|
31
|
+
// Concrete block reader types can provide their own `AfterNewRead` implementation if specific
|
|
32
|
+
// post-read actions are needed (e.g., updating internal state for deduplication).
|
|
33
|
+
func (cs *CommonState) AfterNewRead() {
|
|
34
|
+
// Default no-op, can be overridden by embedding types.
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// LabelBlockReader reads values from its `DataBuf` where each value is preceded by a
|
|
38
|
+
// length-determining label read from a separate `parentBuf`.
|
|
39
|
+
// It is used for types where each instance in the block is individually length-prefixed.
|
|
40
|
+
// `Out` is the target type of the values read.
|
|
41
|
+
type LabelBlockReader[Out any] struct {
|
|
42
|
+
CommonState // Embeds DataBuf and default AfterNewRead.
|
|
43
|
+
fromBytes FromBytesFunc[Out] // Function to convert raw bytes to Out type.
|
|
44
|
+
readNullTerminator bool // Flag indicating if a null terminator should be read after the data.
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// NewLabelBlockReader creates and returns a new LabelBlockReader.
|
|
48
|
+
// - dataBuf: The buffer from which the actual value data is read (corresponds to `this.buf` in some TS implementations).
|
|
49
|
+
// - fromBytes: A function to convert the raw bytes (read according to the label) into the target type `Out`.
|
|
50
|
+
// - readNullTerminator: If true, an extra null byte is read and discarded from `dataBuf` after reading the value's data (used for null-terminated strings).
|
|
51
|
+
func NewLabelBlockReader[Out any](dataBuf buf.Read, fromBytes FromBytesFunc[Out], readNullTerminator bool) *LabelBlockReader[Out] {
|
|
52
|
+
return &LabelBlockReader[Out]{
|
|
53
|
+
CommonState: CommonState{DataBuf: dataBuf},
|
|
54
|
+
fromBytes: fromBytes,
|
|
55
|
+
readNullTerminator: readNullTerminator,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Read decodes a single value. It first reads a label from `parentBuf` to determine the length
|
|
60
|
+
// of the data. Then, it reads that many bytes from its internal `DataBuf`, converts these bytes
|
|
61
|
+
// to the `Out` type using `fromBytes`, and optionally reads a null terminator.
|
|
62
|
+
// It returns the decoded value and an error if any step fails.
|
|
63
|
+
// This reader expects the label to indicate a length; it cannot handle backreferences, null, absent, or error labels directly.
|
|
64
|
+
func (r *LabelBlockReader[Out]) Read(parentBuf buf.Read) (Out, error) {
|
|
65
|
+
var zero Out // Zero value of Out to return on error
|
|
66
|
+
|
|
67
|
+
l, err := label.Read(parentBuf)
|
|
68
|
+
if err != nil {
|
|
69
|
+
return zero, fmt.Errorf("LabelBlockReader: failed to read label from parentBuf: %w", err)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
switch l.Kind() {
|
|
73
|
+
case label.LabelKindBackreference:
|
|
74
|
+
return zero, fmt.Errorf("programmer error: LabelBlockReader: this type must not use backreferences (label: %s)", l)
|
|
75
|
+
case label.LabelKindLength:
|
|
76
|
+
lengthVal := l.Value().Int64()
|
|
77
|
+
if lengthVal < 0 {
|
|
78
|
+
// label.IsLength() implies non-negative, so this should be an internal inconsistency.
|
|
79
|
+
return zero, fmt.Errorf("programmer error: LabelBlockReader: negative length (%d) from label %s which has KindLength", lengthVal, l)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if r.DataBuf == nil {
|
|
83
|
+
return zero, fmt.Errorf("programmer error: LabelBlockReader: DataBuf is nil")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var bytesToRead []byte
|
|
87
|
+
if lengthVal == 0 {
|
|
88
|
+
bytesToRead = []byte{} // Empty slice for zero length
|
|
89
|
+
} else {
|
|
90
|
+
bytesToRead = make([]byte, int(lengthVal)) // Allocate slice for data
|
|
91
|
+
n, readErr := r.DataBuf.Read(bytesToRead)
|
|
92
|
+
if readErr != nil && readErr != io.EOF { // Any error other than EOF is immediately problematic
|
|
93
|
+
return zero, fmt.Errorf("LabelBlockReader: DataBuf.Read failed for %d bytes: %w", lengthVal, readErr)
|
|
94
|
+
}
|
|
95
|
+
// If EOF was encountered or no error, ensure all requested bytes were actually read.
|
|
96
|
+
if n != int(lengthVal) {
|
|
97
|
+
// This indicates a short read, which is an error here.
|
|
98
|
+
return zero, fmt.Errorf("LabelBlockReader: expected to read %d bytes from DataBuf, but read %d (read error: %v)", lengthVal, n, readErr)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if r.readNullTerminator {
|
|
103
|
+
_, err := r.DataBuf.ReadByte()
|
|
104
|
+
if err != nil {
|
|
105
|
+
return zero, fmt.Errorf("LabelBlockReader: failed to read null terminator: %w", err)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
value := r.fromBytes(bytesToRead)
|
|
110
|
+
r.AfterNewRead() // Call the AfterNewRead hook (defined on CommonState by default)
|
|
111
|
+
return value, nil
|
|
112
|
+
case label.LabelKindNull:
|
|
113
|
+
return zero, fmt.Errorf("programmer error: LabelBlockReader: reader cannot handle null labels (label: %s)", l)
|
|
114
|
+
case label.LabelKindAbsent:
|
|
115
|
+
return zero, fmt.Errorf("programmer error: LabelBlockReader: reader cannot handle absent labels (label: %s)", l)
|
|
116
|
+
case label.LabelKindError:
|
|
117
|
+
return zero, fmt.Errorf("programmer error: LabelBlockReader: reader cannot handle error labels (label: %s)", l)
|
|
118
|
+
default:
|
|
119
|
+
return zero, fmt.Errorf("programmer error: LabelBlockReader: unhandled label kind %s (label: %s)", l.Kind(), l)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// DeduplicatingLabelBlockReader is similar to LabelBlockReader but adds support for deduplication.
|
|
124
|
+
// It reads values from its `DataBuf` that are preceded by a label (read from `parentBuf`).
|
|
125
|
+
// This label can either specify the length of a new value or be a backreference to a previously read value.
|
|
126
|
+
// New values are stored internally to be targets for future backreferences.
|
|
127
|
+
// `Out` is the target type of the values read.
|
|
128
|
+
type DeduplicatingLabelBlockReader[Out any] struct {
|
|
129
|
+
CommonState // Embeds DataBuf and default AfterNewRead.
|
|
130
|
+
fromBytes FromBytesFunc[Out] // Function to convert raw bytes to Out type.
|
|
131
|
+
values []Out // Stores previously seen values for backreferencing.
|
|
132
|
+
readNullTerminator bool // Flag indicating if a null terminator should be read after new data.
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// NewDeduplicatingLabelBlockReader creates and returns a new DeduplicatingLabelBlockReader.
|
|
136
|
+
// - dataBuf: The buffer for reading actual value data.
|
|
137
|
+
// - fromBytes: Function to convert raw bytes to the `Out` type.
|
|
138
|
+
// - values: An initial slice of values; typically empty, will be populated as new unique values are read.
|
|
139
|
+
// - readNullTerminator: If true, an extra null byte is read from `dataBuf` after new string data.
|
|
140
|
+
func NewDeduplicatingLabelBlockReader[Out any](dataBuf buf.Read, fromBytes FromBytesFunc[Out], readNullTerminator bool) *DeduplicatingLabelBlockReader[Out] {
|
|
141
|
+
return &DeduplicatingLabelBlockReader[Out]{
|
|
142
|
+
CommonState: CommonState{DataBuf: dataBuf},
|
|
143
|
+
fromBytes: fromBytes,
|
|
144
|
+
values: make([]Out, 0), // Initialize empty slice for values
|
|
145
|
+
readNullTerminator: readNullTerminator,
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Read decodes a single value, handling potential backreferences.
|
|
150
|
+
// It reads a label from `parentBuf`. If the label is a backreference, it returns the previously stored value.
|
|
151
|
+
// If the label indicates a length, it reads the data from `DataBuf`, converts it, stores it for future
|
|
152
|
+
// backreferences, and returns it. Optionally reads a null terminator for new string data.
|
|
153
|
+
// Returns the decoded value and an error if any step fails.
|
|
154
|
+
// This reader cannot handle null, absent, or error labels directly.
|
|
155
|
+
func (r *DeduplicatingLabelBlockReader[Out]) Read(parentBuf buf.Read) (Out, error) {
|
|
156
|
+
var zero Out
|
|
157
|
+
|
|
158
|
+
l, err := label.Read(parentBuf)
|
|
159
|
+
if err != nil {
|
|
160
|
+
return zero, fmt.Errorf("DeduplicatingLabelBlockReader: failed to read label from parentBuf: %w", err)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
switch l.Kind() {
|
|
164
|
+
case label.LabelKindBackreference:
|
|
165
|
+
offset, offsetErr := l.ToOffset() // Converts label to backreference offset
|
|
166
|
+
if offsetErr != nil {
|
|
167
|
+
// l.ToOffset() already validates if it's a proper backreference kind.
|
|
168
|
+
return zero, fmt.Errorf("DeduplicatingLabelBlockReader: invalid backreference label %s: %w", l, offsetErr)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
idx := int(offset)
|
|
172
|
+
if idx < 0 || idx >= len(r.values) {
|
|
173
|
+
return zero, fmt.Errorf("DeduplicatingLabelBlockReader: invalid backreference offset %d (label: %s), current values count: %d", offset, l, len(r.values))
|
|
174
|
+
}
|
|
175
|
+
// The TS `if (value == undefined)` check is implicitly handled by Go's slice indexing:
|
|
176
|
+
// if the index is valid, a value (possibly zero-value) exists.
|
|
177
|
+
value := r.values[idx]
|
|
178
|
+
return value, nil
|
|
179
|
+
|
|
180
|
+
case label.LabelKindLength:
|
|
181
|
+
lengthVal := l.Value().Int64()
|
|
182
|
+
if lengthVal < 0 {
|
|
183
|
+
return zero, fmt.Errorf("programmer error: DeduplicatingLabelBlockReader: negative length (%d) from label %s which has KindLength", lengthVal, l)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if r.DataBuf == nil {
|
|
187
|
+
return zero, fmt.Errorf("programmer error: DeduplicatingLabelBlockReader: DataBuf is nil")
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var bytesToRead []byte
|
|
191
|
+
if lengthVal == 0 {
|
|
192
|
+
bytesToRead = []byte{}
|
|
193
|
+
} else {
|
|
194
|
+
bytesToRead = make([]byte, int(lengthVal))
|
|
195
|
+
n, readErr := r.DataBuf.Read(bytesToRead)
|
|
196
|
+
if readErr != nil && readErr != io.EOF {
|
|
197
|
+
return zero, fmt.Errorf("DeduplicatingLabelBlockReader: DataBuf.Read failed for %d bytes: %w", lengthVal, readErr)
|
|
198
|
+
}
|
|
199
|
+
if n != int(lengthVal) {
|
|
200
|
+
return zero, fmt.Errorf("DeduplicatingLabelBlockReader: expected to read %d bytes from DataBuf, but read %d (read error: %v)", lengthVal, n, readErr)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if r.readNullTerminator {
|
|
205
|
+
nul, err := r.DataBuf.ReadByte()
|
|
206
|
+
if err != nil {
|
|
207
|
+
return zero, fmt.Errorf("DeduplicatingLabelBlockReader: failed to read null terminator: %w", err)
|
|
208
|
+
}
|
|
209
|
+
if nul != '\000' {
|
|
210
|
+
return zero, fmt.Errorf("DeduplicatingLabelBlockReader: null terminator was not null: %b", nul)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
value := r.fromBytes(bytesToRead)
|
|
215
|
+
r.values = append(r.values, value) // Store the new value for future backreferences
|
|
216
|
+
r.AfterNewRead()
|
|
217
|
+
return value, nil
|
|
218
|
+
|
|
219
|
+
case label.LabelKindNull:
|
|
220
|
+
return zero, fmt.Errorf("programmer error: DeduplicatingLabelBlockReader: reader cannot handle null labels (label: %s)", l)
|
|
221
|
+
case label.LabelKindAbsent:
|
|
222
|
+
return zero, fmt.Errorf("programmer error: DeduplicatingLabelBlockReader: reader cannot handle absent labels (label: %s)", l)
|
|
223
|
+
case label.LabelKindError:
|
|
224
|
+
return zero, fmt.Errorf("programmer error: DeduplicatingLabelBlockReader: reader cannot handle error labels (label: %s)", l)
|
|
225
|
+
default:
|
|
226
|
+
return zero, fmt.Errorf("programmer error: DeduplicatingLabelBlockReader: unhandled label kind %s (label: %s)", l.Kind(), l)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// FixedSizeBlockReader reads values of a predetermined fixed byte length from its `DataBuf`.
|
|
231
|
+
// It does not use labels from a `parentBuf` to determine length, as the length is constant.
|
|
232
|
+
// `Out` is the target type of the values read.
|
|
233
|
+
type FixedSizeBlockReader[Out any] struct {
|
|
234
|
+
CommonState // Embeds DataBuf.
|
|
235
|
+
fromBytes FromBytesFunc[Out] // Function to convert raw bytes to Out type.
|
|
236
|
+
ByteLength int // The fixed number of bytes for each value.
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// NewFixedSizeBlockReader creates and returns a new FixedSizeBlockReader.
|
|
240
|
+
// - dataBuf: The buffer from which fixed-size data chunks are read.
|
|
241
|
+
// - fromBytes: Function to convert the fixed-size byte chunks to the `Out` type.
|
|
242
|
+
// - byteLength: The exact number of bytes that constitutes one value. Must be non-negative, or it panics.
|
|
243
|
+
func NewFixedSizeBlockReader[Out any](dataBuf buf.Read, fromBytes FromBytesFunc[Out], byteLength int) *FixedSizeBlockReader[Out] {
|
|
244
|
+
if byteLength < 0 {
|
|
245
|
+
panic(fmt.Sprintf("FixedSizeBlockReader: byteLength cannot be negative, got %d", byteLength))
|
|
246
|
+
}
|
|
247
|
+
return &FixedSizeBlockReader[Out]{
|
|
248
|
+
CommonState: CommonState{DataBuf: dataBuf},
|
|
249
|
+
fromBytes: fromBytes,
|
|
250
|
+
ByteLength: byteLength,
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Read decodes a fixed-size block from r.DataBuf.
|
|
255
|
+
// parentBuf is ignored by this implementation but included in the signature to potentially
|
|
256
|
+
// match a common interface derived from the abstract BlockReader<Out>.
|
|
257
|
+
func (r *FixedSizeBlockReader[Out]) Read(parentBuf buf.Read) (Out, error) {
|
|
258
|
+
_ = parentBuf // Explicitly acknowledge and ignore parentBuf.
|
|
259
|
+
var zero Out
|
|
260
|
+
|
|
261
|
+
if r.ByteLength < 0 {
|
|
262
|
+
// This state should ideally be prevented by constructor validation.
|
|
263
|
+
return zero, fmt.Errorf("FixedSizeBlockReader: invalid ByteLength %d", r.ByteLength)
|
|
264
|
+
}
|
|
265
|
+
if r.DataBuf == nil {
|
|
266
|
+
return zero, fmt.Errorf("programmer error: FixedSizeBlockReader: DataBuf is nil")
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
var bytesToRead []byte
|
|
270
|
+
if r.ByteLength == 0 {
|
|
271
|
+
bytesToRead = []byte{}
|
|
272
|
+
} else {
|
|
273
|
+
bytesToRead = make([]byte, r.ByteLength)
|
|
274
|
+
n, readErr := r.DataBuf.Read(bytesToRead)
|
|
275
|
+
if readErr != nil && readErr != io.EOF {
|
|
276
|
+
return zero, fmt.Errorf("FixedSizeBlockReader: DataBuf.Read failed for %d bytes: %w", r.ByteLength, readErr)
|
|
277
|
+
}
|
|
278
|
+
if n != r.ByteLength {
|
|
279
|
+
return zero, fmt.Errorf("FixedSizeBlockReader: expected to read %d bytes from DataBuf, but read %d (read error: %v)", r.ByteLength, n, readErr)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// The TS comment `// aligned reads` for `new Uint8Array(bytes, bytes.byteOffset, this.byteLength)`
|
|
284
|
+
// is generally not a direct concern for Go's `make([]byte, ...)` which provides a new slice.
|
|
285
|
+
value := r.fromBytes(bytesToRead)
|
|
286
|
+
// No AfterNewRead call in the original TS for this reader.
|
|
287
|
+
return value, nil
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// UnlabeledVarIntBlockReader reads varint-encoded integers directly from its `DataBuf`.
|
|
291
|
+
// It does not use labels from a `parentBuf` as varints are self-delimiting.
|
|
292
|
+
// This reader is specifically for `int64` values after ZigZag decoding.
|
|
293
|
+
type UnlabeledVarIntBlockReader struct {
|
|
294
|
+
CommonState // Embeds DataBuf.
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// NewUnlabeledVarIntBlockReader creates and returns a new UnlabeledVarIntBlockReader.
|
|
298
|
+
// - dataBuf: The buffer from which varint-encoded data is read.
|
|
299
|
+
func NewUnlabeledVarIntBlockReader(dataBuf buf.Read) *UnlabeledVarIntBlockReader {
|
|
300
|
+
return &UnlabeledVarIntBlockReader{
|
|
301
|
+
CommonState: CommonState{DataBuf: dataBuf},
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Read decodes a single varint-encoded integer from `DataBuf` (ignoring `parentBuf`).
|
|
306
|
+
// It performs ZigZag decoding to convert the unsigned varint read from the buffer
|
|
307
|
+
// into a signed `int64`.
|
|
308
|
+
// Returns the decoded `int64` and an error if reading or decoding fails.
|
|
309
|
+
func (r *UnlabeledVarIntBlockReader) Read(parentBuf buf.Read) (int64, error) {
|
|
310
|
+
_ = parentBuf // Explicitly acknowledge and ignore parentBuf.
|
|
311
|
+
|
|
312
|
+
if r.DataBuf == nil {
|
|
313
|
+
return 0, fmt.Errorf("programmer error: UnlabeledVarIntBlockReader: DataBuf is nil")
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
l, err := label.Read(r.DataBuf) // Label (varint) read from r.DataBuf
|
|
317
|
+
if err != nil {
|
|
318
|
+
return 0, fmt.Errorf("UnlabeledVarIntBlockReader: failed to read label from DataBuf: %w", err)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// TS: `Number(Label.read(this.buf))`. This implies getting the numerical value of the label.
|
|
322
|
+
// `l.Value()` returns a *big.Int. Convert to int64.
|
|
323
|
+
// `IsInt64()` checks if the value fits in int64 without loss.
|
|
324
|
+
if !l.Value().IsInt64() {
|
|
325
|
+
return 0, fmt.Errorf("UnlabeledVarIntBlockReader: label value '%s' cannot be represented as int64", l.Value().String())
|
|
326
|
+
}
|
|
327
|
+
// No AfterNewRead call in the original TS for this reader.
|
|
328
|
+
return l.Value().Int64(), nil
|
|
329
|
+
}
|