mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-20 05:20:28 +00:00
Add cbor.unmarshal_from_bytes taking a []byte
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user