From 63f7a1278ec2476fac33fa55f1e04ecd81a20fd5 Mon Sep 17 00:00:00 2001 From: oiweiwei Date: Fri, 14 Feb 2025 16:55:52 +0100 Subject: [PATCH] ndr: add marshal_response shortcut --- ndr/ndr20.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ndr/ndr20.go b/ndr/ndr20.go index 89c70a30..5b15924d 100644 --- a/ndr/ndr20.go +++ b/ndr/ndr20.go @@ -73,6 +73,15 @@ func Marshal(d Marshaler, opts ...any) ([]byte, error) { return NDR20(nil, opts...).Marshal(context.Background(), d) } +// MarshalResponse function marshal the operation `d` response using NDR2.0 format. +func MarshalResponse(d Operation, opts ...any) ([]byte, error) { + w := NDR20(nil, opts...) + if err := d.MarshalNDRResponse(context.Background(), w); err != nil { + return nil, err + } + return w.Bytes(), nil +} + // Unmarshal function unmarshals the bytes `b` to the data `d` // using NDR2.0 format. func Unmarshal(b []byte, d Unmarshaler, opts ...any) error {