carta-readers 0.0.3

Input-format readers: parse a source format's text into the document model.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! JSON interchange reader: a thin [`Reader`] adapter over the AST's own serde codec.

use carta_ast::Document;
use carta_core::{Reader, ReaderOptions, Result};

/// Parses an interchange JSON document into the document model.
#[derive(Debug, Default, Clone, Copy)]
pub struct JsonReader;

impl Reader for JsonReader {
    fn read(&self, input: &str, _options: &ReaderOptions) -> Result<Document> {
        Ok(carta_ast::from_json(input.as_bytes())?)
    }
}