pub fn encode_line(value: &LinoValue) -> StringExpand description
Encode a value to the readable, single-line Links Notation format.
This is a convenience function that uses a thread-local codec instance.
The output holds no newline, so a record written with it is a line: an
append-only log stays greppable, tailable and countable by wc -l, and the
values in it can be read without decoding anything.
§Arguments
value- The value to encode
§Returns
A string in readable Links Notation format, containing no newline
§Example
use lino_objects_codec::{decode_line, encode_line, LinoValue};
let record = LinoValue::object([
("bytes", LinoValue::Int(2827)),
("complete", LinoValue::Bool(true)),
("phase", LinoValue::String("stream_end".to_string())),
]);
let line = encode_line(&record);
assert_eq!(line, r#"(o: (bytes 2827) (complete true) (phase "stream_end"))"#);
assert_eq!(decode_line(&line).unwrap(), record);