Snapshot returns the current accumulated buffer without mutating state. Useful for diagnostics — pull the partial JSON into a log field without disturbing the streaming pipeline.
()
| 115 | // state. Useful for diagnostics — pull the partial JSON into a log |
| 116 | // field without disturbing the streaming pipeline. |
| 117 | func (r *PartialInputReader) Snapshot() string { |
| 118 | r.mu.Lock() |
| 119 | defer r.mu.Unlock() |
| 120 | return r.buf.String() |
| 121 | } |
| 122 | |
| 123 | // tryEmitLocked attempts to parse the buffer and emit any new |
| 124 | // top-level string fields. Must be called with r.mu held. |