forked from TrueCloudLab/frostfs-api-go
[#302] pkg/checksum: Convert nil Checksum
to nil message
Document that `Checksum.ToV2` method return `nil` when called on `nil`. Document that `NewChecksumFromV2` function return `nil` when called on `nil`. Write corresponding unit tests. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
245271bb65
commit
35b6629e1c
2 changed files with 21 additions and 0 deletions
|
@ -28,6 +28,8 @@ const (
|
|||
)
|
||||
|
||||
// NewChecksumFromV2 wraps v2 Checksum message to Checksum.
|
||||
//
|
||||
// Nil refs.Checksum converts to nil.
|
||||
func NewChecksumFromV2(cV2 *refs.Checksum) *Checksum {
|
||||
return (*Checksum)(cV2)
|
||||
}
|
||||
|
@ -72,6 +74,9 @@ func (c *Checksum) SetTillichZemor(v [64]byte) {
|
|||
checksum.SetSum(v[:])
|
||||
}
|
||||
|
||||
// ToV2 converts Checksum to v2 Checksum message.
|
||||
//
|
||||
// Nil Checksum converts to nil.
|
||||
func (c *Checksum) ToV2() *refs.Checksum {
|
||||
return (*refs.Checksum)(c)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue