MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / one_line

Function one_line

atomic-cli/src/logging/file_format.rs:54–60  ·  view source on GitHub ↗

Newlines and carriage returns inside an event become `\n` and `\r`, so every event is exactly one line: text from Git, such as a tag annotation, cannot forge log lines, and a line is appended with a single write.

(text: &str)

Source from the content-addressed store, hash-verified

52/// every event is exactly one line: text from Git, such as a tag annotation,
53/// cannot forge log lines, and a line is appended with a single write.
54fn one_line(text: &str) -> Cow<'_, str> {
55 if text.contains(['\n', '\r']) {
56 Cow::Owned(text.replace('\n', "\\n").replace('\r', "\\r"))
57 } else {
58 Cow::Borrowed(text)
59 }
60}
61
62#[cfg(test)]
63mod tests {

Callers

nothing calls this directly

Calls 2

containsMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected