git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/object/range.go (about)

     1  package object
     2  
     3  import (
     4  	"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
     5  )
     6  
     7  // Range represents v2-compatible object payload range.
     8  type Range object.Range
     9  
    10  // NewRangeFromV2 wraps v2 Range message to Range.
    11  //
    12  // Nil object.Range converts to nil.
    13  func NewRangeFromV2(rV2 *object.Range) *Range {
    14  	return (*Range)(rV2)
    15  }
    16  
    17  // NewRange creates and initializes blank Range.
    18  //
    19  // Defaults:
    20  //   - offset: 0;
    21  //   - length: 0.
    22  func NewRange() *Range {
    23  	return NewRangeFromV2(new(object.Range))
    24  }
    25  
    26  // ToV2 converts Range to v2 Range message.
    27  //
    28  // Nil Range converts to nil.
    29  func (r *Range) ToV2() *object.Range {
    30  	return (*object.Range)(r)
    31  }
    32  
    33  // GetLength returns payload range size.
    34  func (r *Range) GetLength() uint64 {
    35  	return (*object.Range)(r).GetLength()
    36  }
    37  
    38  // SetLength sets payload range size.
    39  func (r *Range) SetLength(v uint64) {
    40  	(*object.Range)(r).SetLength(v)
    41  }
    42  
    43  // GetOffset sets payload range offset from start.
    44  func (r *Range) GetOffset() uint64 {
    45  	return (*object.Range)(r).GetOffset()
    46  }
    47  
    48  // SetOffset gets payload range offset from start.
    49  func (r *Range) SetOffset(v uint64) {
    50  	(*object.Range)(r).SetOffset(v)
    51  }