From d112a28d382f6e6a10a2aa24190c857f70cf8984 Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Tue, 13 Aug 2024 18:50:51 +0300 Subject: [PATCH] [#104] object: Add getters for `PatchRequestBodyPatch` Signed-off-by: Airat Arifullin --- object/convert.go | 4 ++-- object/marshal.go | 8 ++++---- object/types.go | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/object/convert.go b/object/convert.go index 5c9e20a..9814b58 100644 --- a/object/convert.go +++ b/object/convert.go @@ -2352,8 +2352,8 @@ func (r *PatchRequestBodyPatch) ToGRPCMessage() grpc.Message { if r != nil { m = new(object.PatchRequest_Body_Patch) - m.SetSourceRange(r.Range.ToGRPCMessage().(*object.Range)) - m.SetChunk(r.Chunk) + m.SetSourceRange(r.GetRange().ToGRPCMessage().(*object.Range)) + m.SetChunk(r.GetChunk()) } return m diff --git a/object/marshal.go b/object/marshal.go index f337502..166b523 100644 --- a/object/marshal.go +++ b/object/marshal.go @@ -1335,8 +1335,8 @@ func (r *PatchRequestBodyPatch) StableMarshal(buf []byte) []byte { } var offset int - offset += proto.NestedStructureMarshal(patchRequestBodyPatchRangeField, buf[offset:], r.Range) - proto.BytesMarshal(patchRequestBodyPatchChunkField, buf[offset:], r.Chunk) + offset += proto.NestedStructureMarshal(patchRequestBodyPatchRangeField, buf[offset:], r.GetRange()) + proto.BytesMarshal(patchRequestBodyPatchChunkField, buf[offset:], r.GetChunk()) return buf } @@ -1347,8 +1347,8 @@ func (r *PatchRequestBodyPatch) StableSize() int { } var size int - size += proto.NestedStructureSize(patchRequestBodyPatchRangeField, r.Range) - size += proto.BytesSize(patchRequestBodyPatchChunkField, r.Chunk) + size += proto.NestedStructureSize(patchRequestBodyPatchRangeField, r.GetRange()) + size += proto.BytesSize(patchRequestBodyPatchChunkField, r.GetChunk()) return size } diff --git a/object/types.go b/object/types.go index c1a8b87..160e820 100644 --- a/object/types.go +++ b/object/types.go @@ -1615,6 +1615,22 @@ func (r *PatchResponse) SetBody(v *PatchResponseBody) { r.Body = v } +func (r *PatchRequestBodyPatch) GetChunk() []byte { + if r != nil { + return r.Chunk + } + + return nil +} + +func (r *PatchRequestBodyPatch) GetRange() *Range { + if r != nil { + return r.Range + } + + return nil +} + func (s *ECInfo) getObjectPart() {} func (s *ECInfo) getHeaderPart() {}