slidge-whatsapp 0.2.6__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 +152 -50
- slidge_whatsapp/gateway.go +7 -63
- slidge_whatsapp/gateway.py +2 -3
- slidge_whatsapp/generated/_whatsapp.cpython-313-aarch64-linux-gnu.h +180 -163
- slidge_whatsapp/generated/_whatsapp.cpython-313-aarch64-linux-gnu.so +0 -0
- slidge_whatsapp/generated/build.py +145 -131
- slidge_whatsapp/generated/whatsapp.c +1669 -1397
- slidge_whatsapp/generated/whatsapp.go +1209 -1098
- slidge_whatsapp/generated/whatsapp.py +1175 -1050
- slidge_whatsapp/generated/whatsapp_go.h +180 -163
- slidge_whatsapp/go.mod +18 -15
- slidge_whatsapp/go.sum +38 -32
- slidge_whatsapp/group.py +34 -30
- slidge_whatsapp/media/media.go +6 -2
- 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/json.go +1 -6
- slidge_whatsapp/vendor/go.mau.fi/util/exhttp/networkerror.go +2 -1
- slidge_whatsapp/vendor/go.mau.fi/util/exstrings/stringutil.go +104 -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 +40 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/binary/encoder.go +1 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/call.go +2 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/client.go +79 -45
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/connectionevents.go +13 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download-to-file.go +19 -12
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/download.go +26 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/errors.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/group.go +99 -27
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/internals.go +54 -26
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/keepalive.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/message.go +208 -57
- 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 +17 -8
- 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/extra.go +7 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.pb.go +983 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/InstamadilloAddMessage.proto +85 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloAddMessage/extra.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.pb.go +197 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeActionLog/InstamadilloCoreTypeActionLog.proto +13 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.pb.go +279 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeAdminMessage/InstamadilloCoreTypeAdminMessage.proto +21 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.pb.go +137 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeCollection/InstamadilloCoreTypeCollection.proto +10 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.pb.go +313 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeLink/InstamadilloCoreTypeLink.proto +27 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.pb.go +1299 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeMedia/InstamadilloCoreTypeMedia.proto +112 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.pb.go +514 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloCoreTypeText/InstamadilloCoreTypeText.proto +47 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.pb.go +123 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/InstamadilloDeleteMessage.proto +7 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloDeleteMessage/extra.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.pb.go +720 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/InstamadilloSupplementMessage.proto +59 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloSupplementMessage/extra.go +3 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.pb.go +365 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloTransportPayload/InstamadilloTransportPayload.proto +33 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.pb.go +1238 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/instamadilloXmaContentRef/InstamadilloXmaContentRef.proto +105 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.pb.go +16 -4
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waArmadilloXMA/WAArmadilloXMA.proto +3 -0
- 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 +46 -10
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waCompanionReg/WACompanionReg.proto +4 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.pb.go +8975 -11209
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waE2E/WAWebProtobufsE2E.proto +193 -421
- 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/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.pb.go +198 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waLidMigrationSyncPayload/WAWebProtobufLidMigrationSyncPayload.proto +14 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waMsgTransport/extra.go +7 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.pb.go +952 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waStatusAttributions/WAStatusAttributions.proto +88 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.pb.go +1143 -463
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waSyncAction/WASyncAction.proto +60 -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/proto/waWeb/WAWebProtobufsWeb.pb.go +11 -3
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/proto/waWeb/WAWebProtobufsWeb.proto +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/receipt.go +20 -7
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingfields.json +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/reportingtoken.go +176 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/retry.go +10 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/send.go +38 -21
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/sendfb.go +1 -0
- 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/container.go +9 -6
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/store.go +25 -5
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/00-latest-schema.sql +4 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/sqlstore/upgrades/10-chat-db-lid-migration-ts.sql +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/store/store.go +5 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/call.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/events/events.go +13 -2
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/jid.go +2 -1
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/message.go +1 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/types/user.go +2 -0
- slidge_whatsapp/vendor/go.mau.fi/whatsmeow/user.go +14 -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/frame.go +8 -8
- 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 +57 -23
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0.dist-info}/METADATA +5 -4
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0.dist-info}/RECORD +254 -174
- {slidge_whatsapp-0.2.6.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.6.dist-info → slidge_whatsapp-0.3.0.dist-info}/entry_points.txt +0 -0
- {slidge_whatsapp-0.2.6.dist-info → slidge_whatsapp-0.3.0.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
// Package block provides BlockWriter and DeduplicatingBlockWriter types for
|
|
2
|
+
// preparing Argo data blocks. These writers manage the conversion of values
|
|
3
|
+
// to their byte representations and the generation of corresponding labels,
|
|
4
|
+
// which are essential for the Argo binary format.
|
|
5
|
+
package block
|
|
6
|
+
|
|
7
|
+
import (
|
|
8
|
+
"fmt"
|
|
9
|
+
"math/big"
|
|
10
|
+
"reflect" // For robust nil checking in DeduplicatingBlockWriter
|
|
11
|
+
|
|
12
|
+
"github.com/beeper/argo-go/label"
|
|
13
|
+
"github.com/beeper/argo-go/pkg/buf"
|
|
14
|
+
"github.com/elliotchance/orderedmap/v3" // Added for deterministic maps
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
// MakeLabelFunc defines a function signature for creating a Label for a given input value
|
|
18
|
+
// and its byte representation. It returns a pointer to a label, or nil if no
|
|
19
|
+
// label should be generated. It can also return an error if label creation fails.
|
|
20
|
+
type MakeLabelFunc[In any] func(value In, data []byte) (l *label.Label, err error)
|
|
21
|
+
|
|
22
|
+
// ValueToBytesFunc defines a function signature for converting an input value to its byte representation.
|
|
23
|
+
// It returns the byte data or an error if the conversion fails.
|
|
24
|
+
type ValueToBytesFunc[In any] func(value In) (data []byte, err error)
|
|
25
|
+
|
|
26
|
+
// BlockWriter is responsible for converting input values of type `In` into their byte
|
|
27
|
+
// representations and generating corresponding labels using provided functions.
|
|
28
|
+
// It accumulates the byte representations internally. The actual writing of labels
|
|
29
|
+
// and byte data to output streams is typically handled by the caller.
|
|
30
|
+
type BlockWriter[In any] struct {
|
|
31
|
+
makeLabelFunc MakeLabelFunc[In]
|
|
32
|
+
valueToBytesFunc ValueToBytesFunc[In]
|
|
33
|
+
valuesAsBytes [][]byte // valuesAsBytes stores the byte representations of all values processed by the Write method.
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// NewBlockWriter creates and returns a new BlockWriter configured with the
|
|
37
|
+
// provided makeLabel and valueToBytes functions.
|
|
38
|
+
// If either function is nil, the Write method will subsequently fail.
|
|
39
|
+
func NewBlockWriter[In any](
|
|
40
|
+
makeLabel MakeLabelFunc[In],
|
|
41
|
+
valueToBytes ValueToBytesFunc[In],
|
|
42
|
+
) *BlockWriter[In] {
|
|
43
|
+
// Note: Write methods will check for nil makeLabelFunc or valueToBytesFunc.
|
|
44
|
+
return &BlockWriter[In]{
|
|
45
|
+
makeLabelFunc: makeLabel,
|
|
46
|
+
valueToBytesFunc: valueToBytes,
|
|
47
|
+
valuesAsBytes: make([][]byte, 0),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// NewLengthOfBytesBlockWriter creates a BlockWriter that generates labels
|
|
52
|
+
// representing the length (in bytes) of each value's binary representation.
|
|
53
|
+
func NewLengthOfBytesBlockWriter[In any](valueToBytes ValueToBytesFunc[In]) *BlockWriter[In] {
|
|
54
|
+
makeLabel := func(v In, data []byte) (*label.Label, error) {
|
|
55
|
+
l := label.NewFromInt64(int64(len(data)))
|
|
56
|
+
return &l, nil
|
|
57
|
+
}
|
|
58
|
+
return NewBlockWriter(makeLabel, valueToBytes)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// NewNoLabelBlockWriter creates a BlockWriter that does not generate any labels.
|
|
62
|
+
// Its makeLabelFunc will always return (nil, nil).
|
|
63
|
+
func NewNoLabelBlockWriter[In comparable](valueToBytes ValueToBytesFunc[In]) *BlockWriter[In] {
|
|
64
|
+
makeLabel := func(v In, data []byte) (*label.Label, error) {
|
|
65
|
+
return nil, nil
|
|
66
|
+
}
|
|
67
|
+
return NewBlockWriter(makeLabel, valueToBytes)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// AfterNewWrite is a hook method called by Write after a new value's byte
|
|
71
|
+
// representation has been successfully generated and stored.
|
|
72
|
+
// Its default implementation is a no-op.
|
|
73
|
+
func (bw *BlockWriter[In]) AfterNewWrite() {
|
|
74
|
+
// Default no-op
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Write converts the given value `v` to its byte representation using valueToBytesFunc,
|
|
78
|
+
// stores these bytes internally, and then generates a label using makeLabelFunc.
|
|
79
|
+
// It returns the generated label (or nil if no label is to be generated) and any
|
|
80
|
+
// error encountered during the process. This method calls AfterNewWrite after
|
|
81
|
+
// successfully storing the bytes.
|
|
82
|
+
func (bw *BlockWriter[In]) Write(v In) (*label.Label, error) {
|
|
83
|
+
if bw.valueToBytesFunc == nil {
|
|
84
|
+
return nil, fmt.Errorf("BlockWriter.Write: valueToBytesFunc is nil")
|
|
85
|
+
}
|
|
86
|
+
bytes, err := bw.valueToBytesFunc(v)
|
|
87
|
+
if err != nil {
|
|
88
|
+
return nil, fmt.Errorf("BlockWriter.Write: valueToBytesFunc failed: %w", err)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
bw.valuesAsBytes = append(bw.valuesAsBytes, bytes)
|
|
92
|
+
bw.AfterNewWrite() // Call hook after new bytes are stored.
|
|
93
|
+
|
|
94
|
+
if bw.makeLabelFunc == nil {
|
|
95
|
+
return nil, fmt.Errorf("BlockWriter.Write: makeLabelFunc is nil")
|
|
96
|
+
}
|
|
97
|
+
l, err := bw.makeLabelFunc(v, bytes)
|
|
98
|
+
if err != nil {
|
|
99
|
+
return nil, fmt.Errorf("BlockWriter.Write: makeLabelFunc failed: %w", err)
|
|
100
|
+
}
|
|
101
|
+
return l, nil
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// WriteLastToBuf writes the byte representation of the most recently processed value
|
|
105
|
+
// to the provided buf.Write buffer. This method is primarily intended for scenarios
|
|
106
|
+
// like "noBlocks" mode where values are written directly. It does not remove the value
|
|
107
|
+
// from its internal store. For block construction, AllValuesAsBytes is typically used.
|
|
108
|
+
func (bw *BlockWriter[In]) WriteLastToBuf(buf buf.Write) error {
|
|
109
|
+
if len(bw.valuesAsBytes) == 0 {
|
|
110
|
+
return fmt.Errorf("BlockWriter.WriteLastToBuf: called on empty BlockWriter")
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
lastValueIndex := len(bw.valuesAsBytes) - 1
|
|
114
|
+
lastValueBytes := bw.valuesAsBytes[lastValueIndex]
|
|
115
|
+
// The value is not popped from bw.valuesAsBytes, to support modes like InlineEverything.
|
|
116
|
+
|
|
117
|
+
// buf.Write(nil) is typically a no-op or writes 0 bytes.
|
|
118
|
+
_, err := buf.Write(lastValueBytes)
|
|
119
|
+
if err != nil {
|
|
120
|
+
// Note: The original value remains in valuesAsBytes even if this write fails.
|
|
121
|
+
// This behavior is simpler than attempting to revert internal state on write failure.
|
|
122
|
+
return fmt.Errorf("BlockWriter.WriteLastToBuf: buf.Write failed: %w", err)
|
|
123
|
+
}
|
|
124
|
+
return nil
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// AllValuesAsBytes returns a new slice containing all byte arrays accumulated by the BlockWriter.
|
|
128
|
+
// This is typically used when constructing a final value block from all processed items.
|
|
129
|
+
// The returned slice is a copy of the slice header, but the underlying byte arrays are shared.
|
|
130
|
+
func (bw *BlockWriter[In]) AllValuesAsBytes() [][]byte {
|
|
131
|
+
vals := make([][]byte, len(bw.valuesAsBytes))
|
|
132
|
+
copy(vals, bw.valuesAsBytes)
|
|
133
|
+
return vals
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// DeduplicatingBlockWriter embeds BlockWriter and extends its functionality to support
|
|
137
|
+
// value deduplication. When a value is processed, if it has been seen before, a
|
|
138
|
+
// backreference label is returned. For new values, a unique ID is assigned (and used
|
|
139
|
+
// for future backreferences), and then a label is generated using its labelForNew function.
|
|
140
|
+
// The input type `In` must be comparable to be used as a key for tracking seen values.
|
|
141
|
+
type DeduplicatingBlockWriter[In comparable] struct {
|
|
142
|
+
// Embeds BlockWriter. The embedded `makeLabelFunc` is not used by DeduplicatingBlockWriter's `Write` method.
|
|
143
|
+
// `valueToBytesFunc`, `valuesAsBytes`, and `AfterNewWrite` are inherited and used.
|
|
144
|
+
BlockWriter[In]
|
|
145
|
+
|
|
146
|
+
seen *orderedmap.OrderedMap[In, label.Label] // Stores seen values and their assigned backreference labels.
|
|
147
|
+
lastIDValue *big.Int // Stores the numeric value of the last assigned backreference ID.
|
|
148
|
+
labelForNew MakeLabelFunc[In] // Function to generate labels for new, non-backreferenced items.
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// NewDeduplicatingBlockWriter creates and returns a new DeduplicatingBlockWriter.
|
|
152
|
+
// It requires a `labelForNew` function (to generate labels for unique items) and
|
|
153
|
+
// a `valueToBytes` function (to convert values to bytes).
|
|
154
|
+
// Backreference IDs are initialized based on label.LowestReservedValue.
|
|
155
|
+
// If either function is nil, the Write method will subsequently fail.
|
|
156
|
+
func NewDeduplicatingBlockWriter[In comparable](
|
|
157
|
+
labelForNew MakeLabelFunc[In],
|
|
158
|
+
valueToBytes ValueToBytesFunc[In],
|
|
159
|
+
) *DeduplicatingBlockWriter[In] {
|
|
160
|
+
// Note: Write methods will check for nil labelForNew or valueToBytesFunc.
|
|
161
|
+
initialIDVal := new(big.Int).Set(label.LowestReservedValue.Value())
|
|
162
|
+
|
|
163
|
+
return &DeduplicatingBlockWriter[In]{
|
|
164
|
+
BlockWriter: BlockWriter[In]{
|
|
165
|
+
valueToBytesFunc: valueToBytes,
|
|
166
|
+
valuesAsBytes: make([][]byte, 0),
|
|
167
|
+
// The embedded makeLabelFunc is not used by DeduplicatingBlockWriter's Write method;
|
|
168
|
+
// it could be set to nil, as DeduplicatingBlockWriter uses its own labelForNew.
|
|
169
|
+
makeLabelFunc: nil,
|
|
170
|
+
},
|
|
171
|
+
seen: orderedmap.NewOrderedMap[In, label.Label](),
|
|
172
|
+
lastIDValue: initialIDVal,
|
|
173
|
+
labelForNew: labelForNew,
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// NewLengthOfBytesDeduplicatingBlockWriter creates a DeduplicatingBlockWriter
|
|
178
|
+
// where labels for new (non-duplicate) values are generated based on the length
|
|
179
|
+
// of their byte representation.
|
|
180
|
+
func NewLengthOfBytesDeduplicatingBlockWriter[In comparable](
|
|
181
|
+
valueToBytes ValueToBytesFunc[In],
|
|
182
|
+
) *DeduplicatingBlockWriter[In] {
|
|
183
|
+
labelForNew := func(v In, data []byte) (*label.Label, error) {
|
|
184
|
+
l := label.NewFromInt64(int64(len(data)))
|
|
185
|
+
return &l, nil
|
|
186
|
+
}
|
|
187
|
+
return NewDeduplicatingBlockWriter[In](labelForNew, valueToBytes)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// nextID generates and returns the next sequential backreference ID.
|
|
191
|
+
// IDs are generated by decrementing from label.LowestReservedValue.
|
|
192
|
+
func (dbw *DeduplicatingBlockWriter[In]) nextID() label.Label {
|
|
193
|
+
one := big.NewInt(1)
|
|
194
|
+
dbw.lastIDValue.Sub(dbw.lastIDValue, one)
|
|
195
|
+
idCopy := new(big.Int).Set(dbw.lastIDValue) // Use a copy for the new Label.
|
|
196
|
+
return label.New(idCopy)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// labelForValue determines the appropriate label for a given value `v` *before* its byte conversion.
|
|
200
|
+
// It handles three cases:
|
|
201
|
+
// 1. If `v` is nil (checked robustly using reflection), it returns label.NullMarker.
|
|
202
|
+
// 2. If `v` has been seen before, it returns the stored backreference label.
|
|
203
|
+
// 3. If `v` is new and not nil, it assigns a new backreference ID, stores it with `v` in the seen map,
|
|
204
|
+
// and returns (nil, nil) to signal that the main Write method should proceed with byte conversion
|
|
205
|
+
// and new-item label generation via `labelForNew`.
|
|
206
|
+
func (dbw *DeduplicatingBlockWriter[In]) labelForValue(v In) (*label.Label, error) {
|
|
207
|
+
// Check if 'v' is a nil pointer or nil interface using reflection for robustness.
|
|
208
|
+
valOfV := reflect.ValueOf(v)
|
|
209
|
+
isConsideredNil := false
|
|
210
|
+
switch valOfV.Kind() {
|
|
211
|
+
case reflect.Ptr, reflect.Interface, reflect.Map, reflect.Slice, reflect.Chan, reflect.Func:
|
|
212
|
+
isConsideredNil = valOfV.IsNil()
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if isConsideredNil {
|
|
216
|
+
lm := label.NullMarker // label.NullMarker is a value, return its address.
|
|
217
|
+
return &lm, nil
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Check if the non-nil value has been seen before.
|
|
221
|
+
if savedLabel, found := dbw.seen.Get(v); found {
|
|
222
|
+
return &savedLabel, nil // Return pointer to the copy of the stored label from Get.
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Value is new and not nil. Assign a new ID and store it.
|
|
226
|
+
newID := dbw.nextID()
|
|
227
|
+
dbw.seen.Set(v, newID)
|
|
228
|
+
return nil, nil // Indicates it's new; Write method will continue processing.
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Write processes the value `v` for the DeduplicatingBlockWriter.
|
|
232
|
+
// It first calls `labelForValue` to check if `v` is nil or a duplicate.
|
|
233
|
+
// - If `labelForValue` returns a non-nil label (NullMarker or backreference), Write returns that label immediately.
|
|
234
|
+
// - If `labelForValue` returns `(nil, nil)` (indicating `v` is new, non-nil, and has been assigned a new
|
|
235
|
+
// backreference ID in the `seen` map), Write then converts `v` to bytes, stores the bytes (appending to
|
|
236
|
+
// the embedded BlockWriter's `valuesAsBytes`), calls `AfterNewWrite`, and finally generates a label for this
|
|
237
|
+
// new item using `dbw.labelForNew`.
|
|
238
|
+
//
|
|
239
|
+
// This method effectively overrides the Write method of the embedded BlockWriter.
|
|
240
|
+
func (dbw *DeduplicatingBlockWriter[In]) Write(v In) (*label.Label, error) {
|
|
241
|
+
// Determine if 'v' is nil, a backreference, or new.
|
|
242
|
+
// labelForValue handles nil check, seen map lookup, and registers new items in seen map.
|
|
243
|
+
existingLabel, err := dbw.labelForValue(v)
|
|
244
|
+
if err != nil {
|
|
245
|
+
// This error typically indicates an internal issue within labelForValue.
|
|
246
|
+
return nil, fmt.Errorf("DeduplicatingBlockWriter.Write: labelForValue failed: %w", err)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if existingLabel != nil {
|
|
250
|
+
// If existingLabel is not nil, it's either Label.NullMarker or a backreference.
|
|
251
|
+
return existingLabel, nil
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// If existingLabel is nil, 'v' is a new, non-nil value.
|
|
255
|
+
// It has already been added to dbw.seen with a new ID by labelForValue.
|
|
256
|
+
// Now, convert to bytes, store them, and generate the "new item" label.
|
|
257
|
+
if dbw.valueToBytesFunc == nil {
|
|
258
|
+
return nil, fmt.Errorf("DeduplicatingBlockWriter.Write: valueToBytesFunc is nil (from embedded BlockWriter)")
|
|
259
|
+
}
|
|
260
|
+
bytes, err := dbw.valueToBytesFunc(v)
|
|
261
|
+
if err != nil {
|
|
262
|
+
// If conversion to bytes fails, the ID was already assigned in `seen`.
|
|
263
|
+
// This order (ID assignment before byte conversion) is consistent with the reference
|
|
264
|
+
// implementation and is maintained here.
|
|
265
|
+
return nil, fmt.Errorf("DeduplicatingBlockWriter.Write: valueToBytesFunc failed: %w", err)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Use the inherited valuesAsBytes and AfterNewWrite
|
|
269
|
+
dbw.valuesAsBytes = append(dbw.valuesAsBytes, bytes)
|
|
270
|
+
dbw.AfterNewWrite() // Calls the AfterNewWrite method of the embedded BlockWriter.
|
|
271
|
+
|
|
272
|
+
if dbw.labelForNew == nil {
|
|
273
|
+
return nil, fmt.Errorf("DeduplicatingBlockWriter.Write: labelForNew is nil")
|
|
274
|
+
}
|
|
275
|
+
finalLabel, err := dbw.labelForNew(v, bytes)
|
|
276
|
+
if err != nil {
|
|
277
|
+
return nil, fmt.Errorf("DeduplicatingBlockWriter.Write: labelForNew failed: %w", err)
|
|
278
|
+
}
|
|
279
|
+
// If `labelForNew` returns `(nil, nil)`, that's the equivalent of returning no label for the new item.
|
|
280
|
+
return finalLabel, nil
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// ToDeduplicating on a DeduplicatingBlockWriter returns the receiver `dbw` itself,
|
|
284
|
+
// as it's already a deduplicating writer.
|
|
285
|
+
func (dbw *DeduplicatingBlockWriter[In]) ToDeduplicating() *DeduplicatingBlockWriter[In] {
|
|
286
|
+
return dbw
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// ToDeduplicatingWriter is a package-level utility function that converts a given
|
|
290
|
+
// BlockWriter[In] to a DeduplicatingBlockWriter[In]. The type parameter `In` for
|
|
291
|
+
// the input BlockWriter must be `comparable`.
|
|
292
|
+
// It initializes the new DeduplicatingBlockWriter using the `makeLabelFunc` (as `labelForNew`)
|
|
293
|
+
// and `valueToBytesFunc` from the original BlockWriter.
|
|
294
|
+
func ToDeduplicatingWriter[In comparable](
|
|
295
|
+
bw *BlockWriter[In], // The input BlockWriter's type parameter must be comparable.
|
|
296
|
+
) *DeduplicatingBlockWriter[In] {
|
|
297
|
+
// This conversion is type-safe because the Go compiler ensures that 'In'
|
|
298
|
+
// for 'bw' satisfies 'comparable' at the call site of this function.
|
|
299
|
+
// Thus, 'In' can be used for DeduplicatingBlockWriter's type parameter.
|
|
300
|
+
return NewDeduplicatingBlockWriter[In](
|
|
301
|
+
bw.makeLabelFunc, // Use original BlockWriter's makeLabel as labelForNew.
|
|
302
|
+
bw.valueToBytesFunc,
|
|
303
|
+
)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// AnyBlockWriter defines an interface for block writers that accept `interface{}` (any) values.
|
|
307
|
+
// This allows for type-erased handling of block writing operations, useful in contexts
|
|
308
|
+
// where the specific type of values being written is not known at compile time or varies.
|
|
309
|
+
// Implementations typically wrap a generic BlockWriter[T] or DeduplicatingBlockWriter[T]
|
|
310
|
+
// and perform a type assertion before delegating to the underlying writer.
|
|
311
|
+
type AnyBlockWriter interface {
|
|
312
|
+
// Write processes a value `v` of any type. It attempts to assert `v` to the
|
|
313
|
+
// concrete type expected by the underlying block writer. If successful, it delegates
|
|
314
|
+
// to the underlying writer's Write method. It returns the generated label and any error.
|
|
315
|
+
Write(v interface{}) (*label.Label, error)
|
|
316
|
+
// AllValuesAsBytes returns all accumulated byte arrays from the underlying writer.
|
|
317
|
+
AllValuesAsBytes() [][]byte
|
|
318
|
+
// WriteLastToBuf writes the byte representation of the most recently processed value
|
|
319
|
+
// to the provided buffer, by delegating to the underlying writer.
|
|
320
|
+
WriteLastToBuf(buf buf.Write) error
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// --- Non-Deduplicating Adapter ---
|
|
324
|
+
|
|
325
|
+
// nonDeduplicatingAdapter adapts a generic BlockWriter[T] to the AnyBlockWriter interface.
|
|
326
|
+
// The type parameter T can be any type. This adapter allows a type-specific BlockWriter
|
|
327
|
+
// to be used in contexts requiring an AnyBlockWriter.
|
|
328
|
+
type nonDeduplicatingAdapter[T any] struct {
|
|
329
|
+
coreWriter *BlockWriter[T]
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Write attempts to assert the input `v` to type T and then calls the underlying coreWriter.Write.
|
|
333
|
+
// If the type assertion fails, it returns a type mismatch error.
|
|
334
|
+
func (a *nonDeduplicatingAdapter[T]) Write(v interface{}) (*label.Label, error) {
|
|
335
|
+
val, ok := v.(T)
|
|
336
|
+
if !ok {
|
|
337
|
+
// This error occurs if T is a concrete type and v is not assignable to it (e.g., T is string, v is int).
|
|
338
|
+
// If T is interface{}, this assertion will always succeed.
|
|
339
|
+
return nil, fmt.Errorf("type mismatch for block writer: value of type %T cannot be asserted to the writer's target type. Value: %v", v, v)
|
|
340
|
+
}
|
|
341
|
+
return a.coreWriter.Write(val)
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// AllValuesAsBytes delegates to the underlying coreWriter.
|
|
345
|
+
func (a *nonDeduplicatingAdapter[T]) AllValuesAsBytes() [][]byte {
|
|
346
|
+
return a.coreWriter.AllValuesAsBytes()
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// WriteLastToBuf delegates to the underlying coreWriter.
|
|
350
|
+
func (a *nonDeduplicatingAdapter[T]) WriteLastToBuf(buf buf.Write) error {
|
|
351
|
+
return a.coreWriter.WriteLastToBuf(buf)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// NewAnyBlockWriter creates an AnyBlockWriter by wrapping a given generic BlockWriter[T].
|
|
355
|
+
// This allows the specifically typed BlockWriter to be used through the type-erased AnyBlockWriter interface.
|
|
356
|
+
func NewAnyBlockWriter[T any](bw *BlockWriter[T]) AnyBlockWriter {
|
|
357
|
+
return &nonDeduplicatingAdapter[T]{coreWriter: bw}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// --- Deduplicating Adapter ---
|
|
361
|
+
|
|
362
|
+
// deduplicatingAdapter adapts a generic DeduplicatingBlockWriter[T] to the AnyBlockWriter interface.
|
|
363
|
+
// The type parameter T must be comparable for the underlying DeduplicatingBlockWriter.
|
|
364
|
+
// This adapter allows a type-specific, comparable DeduplicatingBlockWriter to be used as an AnyBlockWriter.
|
|
365
|
+
type deduplicatingAdapter[T comparable] struct {
|
|
366
|
+
coreWriter *DeduplicatingBlockWriter[T]
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Write attempts to assert the input `v` to type T (which must be comparable) and then
|
|
370
|
+
// calls the underlying coreWriter.Write. If the type assertion fails, it returns a type mismatch error.
|
|
371
|
+
func (a *deduplicatingAdapter[T]) Write(v interface{}) (*label.Label, error) {
|
|
372
|
+
val, ok := v.(T)
|
|
373
|
+
if !ok {
|
|
374
|
+
var zeroT T // Used to get a string representation of type T for the error message.
|
|
375
|
+
return nil, fmt.Errorf("type mismatch for deduplicating block writer: expected %T, got %T for value %v", zeroT, v, v)
|
|
376
|
+
}
|
|
377
|
+
return a.coreWriter.Write(val)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// AllValuesAsBytes delegates to the underlying coreWriter.
|
|
381
|
+
func (a *deduplicatingAdapter[T]) AllValuesAsBytes() [][]byte {
|
|
382
|
+
return a.coreWriter.AllValuesAsBytes()
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// WriteLastToBuf delegates to the underlying coreWriter.
|
|
386
|
+
func (a *deduplicatingAdapter[T]) WriteLastToBuf(buf buf.Write) error {
|
|
387
|
+
return a.coreWriter.WriteLastToBuf(buf)
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// NewAnyDeduplicatingBlockWriter creates an AnyBlockWriter by wrapping a given generic DeduplicatingBlockWriter[T].
|
|
391
|
+
// The type T must be comparable. This allows the specifically typed DeduplicatingBlockWriter
|
|
392
|
+
// to be used through the type-erased AnyBlockWriter interface.
|
|
393
|
+
func NewAnyDeduplicatingBlockWriter[T comparable](dbw *DeduplicatingBlockWriter[T]) AnyBlockWriter {
|
|
394
|
+
return &deduplicatingAdapter[T]{coreWriter: dbw}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// --- Specialized Constructors returning AnyBlockWriter ---
|
|
398
|
+
|
|
399
|
+
// NewAnyNoLabelBlockWriter creates a BlockWriter specifically for `interface{}` values (T is interface{})
|
|
400
|
+
// that generates no labels, and then wraps it as an AnyBlockWriter.
|
|
401
|
+
// This is a convenience constructor for a common use case.
|
|
402
|
+
func NewAnyNoLabelBlockWriter(valueToBytes ValueToBytesFunc[interface{}]) AnyBlockWriter {
|
|
403
|
+
// The underlying BlockWriter is instantiated with T as interface{}.
|
|
404
|
+
bw := NewNoLabelBlockWriter[interface{}](valueToBytes)
|
|
405
|
+
// This is then wrapped by the nonDeduplicatingAdapter, which also expects T as interface{}.
|
|
406
|
+
return NewAnyBlockWriter[interface{}](bw)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// NewAnyLengthOfBytesBlockWriter creates a BlockWriter specifically for `interface{}` values (T is interface{})
|
|
410
|
+
// that generates labels based on byte length, and then wraps it as an AnyBlockWriter.
|
|
411
|
+
// This is a convenience constructor for another common use case.
|
|
412
|
+
func NewAnyLengthOfBytesBlockWriter(valueToBytes ValueToBytesFunc[interface{}]) AnyBlockWriter {
|
|
413
|
+
// The underlying BlockWriter is instantiated with T as interface{}.
|
|
414
|
+
bw := NewLengthOfBytesBlockWriter[interface{}](valueToBytes)
|
|
415
|
+
// This is then wrapped by the nonDeduplicatingAdapter, which also expects T as interface{}.
|
|
416
|
+
return NewAnyBlockWriter[interface{}](bw)
|
|
417
|
+
}
|