Currently, the encoder uses a built-in buffer pool. This PR allows encoding to a user specified buffer rather than using the built-in buffer pool.
This PR wraps and uses a function implemented in PR #521 by @benluddy. Thanks Ben! :+1:
This PR adds:
cbor.MarshalToBuffer() uses codec's default options to encode to user provided buffer instead of using built-in buffer pool.
UserBufferEncMode interface extends EncMode interface with MarshalToBuffer() so user can provide buffer for encoding instead of using built-in buffer pool.
Currently, the encoder uses a built-in buffer pool. This PR allows encoding to a user specified buffer rather than using the built-in buffer pool.
This PR wraps and uses a function implemented in PR #521 by @benluddy. Thanks Ben! :+1:
This PR adds:
cbor.MarshalToBuffer()
uses codec's default options to encode to user provided buffer instead of using built-in buffer pool.UserBufferEncMode
interface extendsEncMode
interface withMarshalToBuffer()
so user can provide buffer for encoding instead of using built-in buffer pool.EncOptions.UserBufferEncMode()
returnsUserBufferEncMode
EncOptions.UserBufferEncModeWithTags()
returnsUserBufferEncMode
EncOptions.UserBufferEncModeWithSharedTags()
returnsUserBufferEncMode
This PR added a check to return error if user provided buffer
*bytes.Buffer
is nil.