Drain all complete newline-terminated lines out of buf, decoding each
as UTF-8 and dropping the trailing \n. Any partial trailing line stays
in buf so the caller can append more bytes and try again.
Drain all complete SSE events out of buf, returning the payload of
each data: field. The [DONE] sentinel and non-data: fields are
filtered out. Each returned String is exactly one event’s data
(multi-line data: fields are joined with \n, per the SSE spec).
Write bytes to path atomically: temp file in the same directory →
sync_all → rename over the destination. The rename is atomic on the same
filesystem (and replaces an existing target on both Unix and Windows).