diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-02-12 20:17:24 +0100 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-03-04 17:26:19 +0100 |
| commit | 04bd3cc525e5ef366043ace552bd0f3aa7cdd4b8 (patch) | |
| tree | 4bc5b6c0f71908a4e672d05503660c0742acd424 /core/encoding | |
| parent | 9fc8587e2c2bff33a063531ef9045d48dc4a587e (diff) | |
encoding/cbor: rename `diagnose` to `to_diagnostic_format` to be clearer
Diffstat (limited to 'core/encoding')
| -rw-r--r-- | core/encoding/cbor/cbor.odin | 24 | ||||
| -rw-r--r-- | core/encoding/cbor/doc.odin | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/core/encoding/cbor/cbor.odin b/core/encoding/cbor/cbor.odin index f879a11aa..defae4163 100644 --- a/core/encoding/cbor/cbor.odin +++ b/core/encoding/cbor/cbor.odin @@ -307,23 +307,23 @@ destroy :: proc(val: Value, allocator := context.allocator) { } /* -diagnose either writes or returns a human-readable representation of the value, -optionally formatted, defined as the diagnostic format in section 8 of RFC 8949. +to_diagnostic_format either writes or returns a human-readable representation of the value, +optionally formatted, defined as the diagnostic format in [[RFC 8949 Section 8;https://www.rfc-editor.org/rfc/rfc8949.html#name-diagnostic-notation]]. Incidentally, if the CBOR does not contain any of the additional types defined on top of JSON this will also be valid JSON. */ -diagnose :: proc { - diagnostic_string, - diagnose_to_writer, +to_diagnostic_format :: proc { + to_diagnostic_format_string, + to_diagnostic_format_writer, } // Turns the given CBOR value into a human-readable string. // See docs on the proc group `diagnose` for more info. -diagnostic_string :: proc(val: Value, padding := 0, allocator := context.allocator) -> (string, mem.Allocator_Error) #optional_allocator_error { +to_diagnostic_format_string :: proc(val: Value, padding := 0, allocator := context.allocator) -> (string, mem.Allocator_Error) #optional_allocator_error { b := strings.builder_make(allocator) w := strings.to_stream(&b) - err := diagnose_to_writer(w, val, padding) + err := to_diagnostic_format_writer(w, val, padding) if err == .EOF { // The string builder stream only returns .EOF, and only if it can't write (out of memory). return "", .Out_Of_Memory @@ -335,7 +335,7 @@ diagnostic_string :: proc(val: Value, padding := 0, allocator := context.allocat // Writes the given CBOR value into the writer as human-readable text. // See docs on the proc group `diagnose` for more info. -diagnose_to_writer :: proc(w: io.Writer, val: Value, padding := 0) -> io.Error { +to_diagnostic_format_writer :: proc(w: io.Writer, val: Value, padding := 0) -> io.Error { @(require_results) indent :: proc(padding: int) -> int { padding := padding @@ -421,7 +421,7 @@ diagnose_to_writer :: proc(w: io.Writer, val: Value, padding := 0) -> io.Error { newline(w, padding) or_return for entry, i in v { - diagnose(w, entry, padding) or_return + to_diagnostic_format(w, entry, padding) or_return if i != len(v)-1 { comma(w, padding) or_return newline(w, padding) or_return @@ -444,9 +444,9 @@ diagnose_to_writer :: proc(w: io.Writer, val: Value, padding := 0) -> io.Error { newline(w, padding) or_return for entry, i in v { - diagnose(w, entry.key, padding) or_return + to_diagnostic_format(w, entry.key, padding) or_return io.write_string(w, ": ") or_return - diagnose(w, entry.value, padding) or_return + to_diagnostic_format(w, entry.value, padding) or_return if i != len(v)-1 { comma(w, padding) or_return newline(w, padding) or_return @@ -460,7 +460,7 @@ diagnose_to_writer :: proc(w: io.Writer, val: Value, padding := 0) -> io.Error { case ^Tag: io.write_u64(w, v.number) or_return io.write_string(w, "(") or_return - diagnose(w, v.value, padding) or_return + to_diagnostic_format(w, v.value, padding) or_return io.write_string(w, ")") or_return case Simple: io.write_string(w, "simple(") or_return diff --git a/core/encoding/cbor/doc.odin b/core/encoding/cbor/doc.odin index ee8ba23a0..77eac51cb 100644 --- a/core/encoding/cbor/doc.odin +++ b/core/encoding/cbor/doc.odin @@ -117,8 +117,8 @@ Example: assert(derr == nil) defer cbor.destroy(decoded) - // Turn the CBOR into a human readable representation. - diagnosis, eerr := cbor.diagnose(decoded) + // Turn the CBOR into a human readable representation defined as the diagnostic format in [[RFC 8949 Section 8;https://www.rfc-editor.org/rfc/rfc8949.html#name-diagnostic-notation]]. + diagnosis, eerr := cbor.to_diagnostic_format(decoded) assert(eerr == nil) defer delete(diagnosis) |