[#233] Implement data audit result type with basic methods

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-21 10:52:34 +03:00
parent 3039aa20c7
commit 9986a4ecd1
9 changed files with 959 additions and 0 deletions

26
v2/audit/json.go Normal file
View 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
}