forked from TrueCloudLab/frostfs-api-go
[#233] Implement data audit result type with basic methods
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
3039aa20c7
commit
9986a4ecd1
9 changed files with 959 additions and 0 deletions
26
v2/audit/json.go
Normal file
26
v2/audit/json.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package audit
|
||||
|
||||
import (
|
||||
audit "github.com/nspcc-dev/neofs-api-go/v2/audit/grpc"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
func (a *DataAuditResult) MarshalJSON() ([]byte, error) {
|
||||
return protojson.MarshalOptions{
|
||||
EmitUnpopulated: true,
|
||||
}.Marshal(
|
||||
DataAuditResultToGRPCMessage(a),
|
||||
)
|
||||
}
|
||||
|
||||
func (a *DataAuditResult) UnmarshalJSON(data []byte) error {
|
||||
msg := new(audit.DataAuditResult)
|
||||
|
||||
if err := protojson.Unmarshal(data, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*a = *DataAuditResultFromGRPCMessage(msg)
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue