summaryrefslogtreecommitdiff
path: root/vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-05-22 16:27:55 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-05-22 16:27:55 +0200
commitb6ff55662e0281c0d6e111f9307625ef695df2fa (patch)
tree5f7761efa0b51a7a7d56f96fce3681c8e9b66fe9 /vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go
parent[chore/woodpecker] don't make `test` depend on `lint` (#4189) (diff)
downloadgotosocial-b6ff55662e0281c0d6e111f9307625ef695df2fa.tar.xz
[chore] update dependencies (#4188)
Update dependencies: - github.com/gin-gonic/gin v1.10.0 -> v1.10.1 - github.com/gin-contrib/sessions v1.10.3 -> v1.10.4 - github.com/jackc/pgx/v5 v5.7.4 -> v5.7.5 - github.com/minio/minio-go/v7 v7.0.91 -> v7.0.92 - github.com/pquerna/otp v1.4.0 -> v1.5.0 - github.com/tdewolff/minify/v2 v2.23.5 -> v2.23.8 - github.com/yuin/goldmark v1.7.11 -> v1.7.12 - go.opentelemetry.io/otel{,/*} v1.35.0 -> v1.36.0 - modernc.org/sqlite v1.37.0 -> v1.37.1 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4188 Reviewed-by: Daenney <daenney@noreply.codeberg.org> Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go')
-rw-r--r--vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go149
1 files changed, 149 insertions, 0 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go b/vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go
new file mode 100644
index 000000000..7d3c3620b
--- /dev/null
+++ b/vendor/github.com/minio/minio-go/v7/pkg/set/msgp.go
@@ -0,0 +1,149 @@
+/*
+ * MinIO Go Library for Amazon S3 Compatible Cloud Storage
+ * Copyright 2015-2025 MinIO, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package set
+
+import "github.com/tinylib/msgp/msgp"
+
+// EncodeMsg encodes the message to the writer.
+// Values are stored as a slice of strings or nil.
+func (s StringSet) EncodeMsg(writer *msgp.Writer) error {
+ if s == nil {
+ return writer.WriteNil()
+ }
+ err := writer.WriteArrayHeader(uint32(len(s)))
+ if err != nil {
+ return err
+ }
+ sorted := s.ToByteSlices()
+ for _, k := range sorted {
+ err = writer.WriteStringFromBytes(k)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// MarshalMsg encodes the message to the bytes.
+// Values are stored as a slice of strings or nil.
+func (s StringSet) MarshalMsg(bytes []byte) ([]byte, error) {
+ if s == nil {
+ return msgp.AppendNil(bytes), nil
+ }
+ if len(s) == 0 {
+ return msgp.AppendArrayHeader(bytes, 0), nil
+ }
+ bytes = msgp.AppendArrayHeader(bytes, uint32(len(s)))
+ sorted := s.ToByteSlices()
+ for _, k := range sorted {
+ bytes = msgp.AppendStringFromBytes(bytes, k)
+ }
+ return bytes, nil
+}
+
+// DecodeMsg decodes the message from the reader.
+func (s *StringSet) DecodeMsg(reader *msgp.Reader) error {
+ if reader.IsNil() {
+ *s = nil
+ return reader.Skip()
+ }
+ sz, err := reader.ReadArrayHeader()
+ if err != nil {
+ return err
+ }
+ dst := *s
+ if dst == nil {
+ dst = make(StringSet, sz)
+ } else {
+ for k := range dst {
+ delete(dst, k)
+ }
+ }
+ for i := uint32(0); i < sz; i++ {
+ var k string
+ k, err = reader.ReadString()
+ if err != nil {
+ return err
+ }
+ dst[k] = struct{}{}
+ }
+ *s = dst
+ return nil
+}
+
+// UnmarshalMsg decodes the message from the bytes.
+func (s *StringSet) UnmarshalMsg(bytes []byte) ([]byte, error) {
+ if msgp.IsNil(bytes) {
+ *s = nil
+ return bytes[msgp.NilSize:], nil
+ }
+ // Read the array header
+ sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
+ if err != nil {
+ return nil, err
+ }
+ dst := *s
+ if dst == nil {
+ dst = make(StringSet, sz)
+ } else {
+ for k := range dst {
+ delete(dst, k)
+ }
+ }
+ for i := uint32(0); i < sz; i++ {
+ var k string
+ k, bytes, err = msgp.ReadStringBytes(bytes)
+ if err != nil {
+ return nil, err
+ }
+ dst[k] = struct{}{}
+ }
+ *s = dst
+ return bytes, nil
+}
+
+// Msgsize returns the maximum size of the message.
+func (s StringSet) Msgsize() int {
+ if s == nil {
+ return msgp.NilSize
+ }
+ if len(s) == 0 {
+ return msgp.ArrayHeaderSize
+ }
+ size := msgp.ArrayHeaderSize
+ for key := range s {
+ size += msgp.StringPrefixSize + len(key)
+ }
+ return size
+}
+
+// MarshalBinary encodes the receiver into a binary form and returns the result.
+func (s StringSet) MarshalBinary() ([]byte, error) {
+ return s.MarshalMsg(nil)
+}
+
+// AppendBinary appends the binary representation of itself to the end of b
+func (s StringSet) AppendBinary(b []byte) ([]byte, error) {
+ return s.MarshalMsg(b)
+}
+
+// UnmarshalBinary decodes the binary representation of itself from b
+func (s *StringSet) UnmarshalBinary(b []byte) error {
+ _, err := s.UnmarshalMsg(b)
+ return err
+}