PrettyPrintValue returns the string representation of all contiguous decodable values in the provided byte slice, separated by a provided separator. The directions each value is encoded may be provided. If valDirs is nil, all values are decoded and printed with the default direction (ascending).
(buf *redact.StringBuilder, valDirs []Direction, b []byte, sep string)
| 2100 | // The directions each value is encoded may be provided. If valDirs is nil, |
| 2101 | // all values are decoded and printed with the default direction (ascending). |
| 2102 | func PrettyPrintValue(buf *redact.StringBuilder, valDirs []Direction, b []byte, sep string) { |
| 2103 | safeSep := redact.SafeString(sep) |
| 2104 | allDecoded := prettyPrintValueImpl(buf, valDirs, b, safeSep) |
| 2105 | if allDecoded { |
| 2106 | return |
| 2107 | } |
| 2108 | // If we failed to decoded everything above, assume the key was the result of a |
| 2109 | // `PrefixEnd()`. Attempt to undo PrefixEnd & retry the process, otherwise return |
| 2110 | // what we were able to decode. |
| 2111 | if undoPrefixEnd, ok := UndoPrefixEnd(b); ok { |
| 2112 | // When we UndoPrefixEnd, we may have lost a tail of 0xFFs. Try to add |
| 2113 | // enough of them to get something decoded. This is best-effort, we have to stop |
| 2114 | // somewhere. |
| 2115 | cap := 20 |
| 2116 | if len(valDirs) > len(b) { |
| 2117 | cap = len(valDirs) - len(b) |
| 2118 | } |
| 2119 | for i := 0; i < cap; i++ { |
| 2120 | if allDecoded := prettyPrintValueImpl(buf, valDirs, undoPrefixEnd, safeSep); allDecoded { |
| 2121 | buf.Reset() |
| 2122 | buf.Print(sep + "PrefixEnd") |
| 2123 | return |
| 2124 | } |
| 2125 | undoPrefixEnd = append(undoPrefixEnd, 0xFF) |
| 2126 | } |
| 2127 | } |
| 2128 | } |
| 2129 | |
| 2130 | // PrettyPrintValuesWithTypes returns a slice containing each contiguous decodable value |
| 2131 | // in the provided byte slice along with a slice containing the type of each value. |
nothing calls this directly
no test coverage detected
searching dependent graphs…