Skip to content

Commit 63f7a12

Browse files
committed
ndr: add marshal_response shortcut
1 parent ab7f203 commit 63f7a12

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ndr/ndr20.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ func Marshal(d Marshaler, opts ...any) ([]byte, error) {
7373
return NDR20(nil, opts...).Marshal(context.Background(), d)
7474
}
7575

76+
// MarshalResponse function marshal the operation `d` response using NDR2.0 format.
77+
func MarshalResponse(d Operation, opts ...any) ([]byte, error) {
78+
w := NDR20(nil, opts...)
79+
if err := d.MarshalNDRResponse(context.Background(), w); err != nil {
80+
return nil, err
81+
}
82+
return w.Bytes(), nil
83+
}
84+
7685
// Unmarshal function unmarshals the bytes `b` to the data `d`
7786
// using NDR2.0 format.
7887
func Unmarshal(b []byte, d Unmarshaler, opts ...any) error {

0 commit comments

Comments
 (0)