diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-04-29 01:10:15 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-04-29 01:10:15 +0200 |
| commit | 4f00224dd2908dc21c5412eba9167c63a217bf33 (patch) | |
| tree | 848e9e64ea4cbe41bc2f22f11b83ea8e782818ce /core/encoding/cbor | |
| parent | 8c47d42394a1d1ee62f928925142a3b201e8160a (diff) | |
Add cbor.unmarshal_from_bytes taking a []byte
Diffstat (limited to 'core/encoding/cbor')
| -rw-r--r-- | core/encoding/cbor/unmarshal.odin | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/encoding/cbor/unmarshal.odin b/core/encoding/cbor/unmarshal.odin index c39255d9d..f752c5275 100644 --- a/core/encoding/cbor/unmarshal.odin +++ b/core/encoding/cbor/unmarshal.odin @@ -29,6 +29,7 @@ an input. unmarshal :: proc { unmarshal_from_reader, unmarshal_from_string, + unmarshal_from_bytes, } unmarshal_from_reader :: proc(r: io.Reader, ptr: ^$T, flags := Decoder_Flags{}, allocator := context.allocator, temp_allocator := context.temp_allocator, loc := #caller_location) -> (err: Unmarshal_Error) { @@ -51,6 +52,11 @@ unmarshal_from_string :: proc(s: string, ptr: ^$T, flags := Decoder_Flags{}, all return } +// Unmarshals from a slice of bytes, see docs on the proc group `Unmarshal` for more info. +unmarshal_from_bytes :: proc(bytes: []byte, ptr: ^$T, flags := Decoder_Flags{}, allocator := context.allocator, temp_allocator := context.temp_allocator, loc := #caller_location) -> (err: Unmarshal_Error) { + return unmarshal_from_string(string(bytes), ptr, flags, allocator, temp_allocator, loc) +} + unmarshal_from_decoder :: proc(d: Decoder, ptr: ^$T, allocator := context.allocator, temp_allocator := context.temp_allocator, loc := #caller_location) -> (err: Unmarshal_Error) { d := d |