Skip to main content

decode_line

Function decode_line 

Source
pub fn decode_line(notation: &str) -> Result<LinoValue, CodecError>
Expand description

Decode one line of readable Links Notation back into a value.

This is a convenience function that uses a thread-local codec instance. It is the exact inverse of encode_line; input spanning more than one line is an error rather than a silently merged value.

§Arguments

  • notation - One line in readable Links Notation format

§Returns

The reconstructed value, or an error

§Example

use lino_objects_codec::{decode_line, LinoValue};

let decoded = decode_line("(o: (id 1) (tags (\"a\" \"b\")))").unwrap();
assert_eq!(
    decoded,
    LinoValue::object([
        ("id", LinoValue::Int(1)),
        (
            "tags",
            LinoValue::array([
                LinoValue::String("a".to_string()),
                LinoValue::String("b".to_string()),
            ])
        ),
    ])
);