[#94] object: Generate protobufs for Patch method

* Generate protobufs for patch method;
* Create marshalers, unmarshalers, converters for gererated types;
* Add unit-tests.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-07-24 17:40:47 +03:00 committed by Evgenii Stratonikov
parent 3dfa2f4fd6
commit 9b90d139c5
9 changed files with 1341 additions and 245 deletions

View file

@ -132,6 +132,16 @@ const (
putSingleReqObjectField = 1
putSingleReqCopiesNumberField = 2
patchRequestBodyPatchRangeField = 1
patchRequestBodyPatchChunkField = 2
patchRequestBodyAddrField = 1
patchRequestBodyNewAttrsField = 2
patchRequestBodyReplaceAttrField = 3
patchRequestBodyPatchField = 4
patchResponseBodyObjectIDField = 1
)
func (h *ShortHeader) StableMarshal(buf []byte) []byte {
@ -1314,3 +1324,105 @@ func (r *PutSingleResponseBody) StableSize() int {
func (r *PutSingleResponseBody) Unmarshal(data []byte) error {
return message.Unmarshal(r, data, new(object.PutSingleResponse_Body))
}
func (r *PatchRequestBodyPatch) StableMarshal(buf []byte) []byte {
if r == nil {
return []byte{}
}
if buf == nil {
buf = make([]byte, r.StableSize())
}
var offset int
offset += proto.NestedStructureMarshal(patchRequestBodyPatchRangeField, buf[offset:], r.Range)
offset += proto.BytesMarshal(patchRequestBodyPatchChunkField, buf[offset:], r.Chunk)
return buf
}
func (r *PatchRequestBodyPatch) StableSize() int {
if r == nil {
return 0
}
var size int
size += proto.NestedStructureSize(patchRequestBodyPatchRangeField, r.Range)
size += proto.BytesSize(patchRequestBodyPatchChunkField, r.Chunk)
return size
}
func (r *PatchRequestBodyPatch) Unmarshal(data []byte) error {
return message.Unmarshal(r, data, new(object.PatchRequest_Body_Patch))
}
func (r *PatchRequestBody) StableMarshal(buf []byte) []byte {
if r == nil {
return []byte{}
}
if buf == nil {
buf = make([]byte, r.StableSize())
}
var offset int
offset += proto.NestedStructureMarshal(patchRequestBodyAddrField, buf[offset:], r.Address)
for i := range r.NewAttributes {
offset += proto.NestedStructureMarshal(patchRequestBodyNewAttrsField, buf[offset:], &r.NewAttributes[i])
}
offset += proto.BoolMarshal(patchRequestBodyReplaceAttrField, buf[offset:], r.ReplaceAttributes)
offset += proto.NestedStructureMarshal(patchRequestBodyPatchField, buf[offset:], r.Patch)
return buf
}
func (r *PatchRequestBody) StableSize() int {
if r == nil {
return 0
}
var size int
size += proto.NestedStructureSize(patchRequestBodyAddrField, r.Address)
for i := range r.NewAttributes {
size += proto.NestedStructureSize(patchRequestBodyNewAttrsField, &r.NewAttributes[i])
}
size += proto.BoolSize(patchRequestBodyReplaceAttrField, r.ReplaceAttributes)
size += proto.NestedStructureSize(patchRequestBodyPatchField, r.Patch)
return size
}
func (r *PatchRequestBody) Unmarshal(data []byte) error {
return message.Unmarshal(r, data, new(object.PatchRequest_Body))
}
func (r *PatchResponseBody) StableSize() int {
if r == nil {
return 0
}
var size int
size += proto.NestedStructureSize(patchResponseBodyObjectIDField, r.ObjectID)
return size
}
func (r *PatchResponseBody) StableMarshal(buf []byte) []byte {
if r == nil {
return []byte{}
}
if buf == nil {
buf = make([]byte, r.StableSize())
}
var offset int
offset += proto.NestedStructureMarshal(patchResponseBodyObjectIDField, buf[offset:], r.ObjectID)
return buf
}
func (r *PatchResponseBody) Unmarshal(data []byte) error {
return message.Unmarshal(r, data, new(object.PatchResponse_Body))
}