18 stable releases

new 1.12.0 Sep 26, 2021
1.11.4 Sep 20, 2021
1.11.1 Aug 29, 2021
1.10.0 Jul 14, 2021
1.7.2 May 27, 2021

#82 in Database interfaces

Download history 97/week @ 2021-06-07 3/week @ 2021-06-14 28/week @ 2021-06-21 1/week @ 2021-06-28 20/week @ 2021-07-05 19/week @ 2021-07-12 16/week @ 2021-07-19 15/week @ 2021-07-26 35/week @ 2021-08-02 18/week @ 2021-08-09 68/week @ 2021-08-16 14/week @ 2021-08-23 34/week @ 2021-08-30 1/week @ 2021-09-06 44/week @ 2021-09-13 50/week @ 2021-09-20

107 downloads per month

Apache-2.0

305KB
3K SLoC

Stencila Schema for Rust

Build Status Crates.io Docs

This crate provides Rust bindings for the Stencila Schema. It is primarily aimed at Rust developers wanting to programmatically generate or modify documents, particularly executable documents. For example, it is used in the Stencila Rust library.

Install

cargo add stencila_schema

Use

This package exports a struct for each type of document node in the Stencila Schema e.g. Article, Paragraph, CodeChunk.

Note that all node properties e.g. familyNames are made snake case e.g. family_names for consistency with Rust conventions.

let article = Article {
    title: Some(ArticleTitle::String("The article title".into())),
    authors: Some(vec![ArticleAuthors::Person({
        Person {
            given_names: Some(vec!["Jane".into()]),
            family_names: Some(vec!["Jones".into()]),
            ..Default::default()
        }
    })]),
    content: Some(vec![BlockContent::Paragraph(Paragraph {
        content: vec![
            InlineContent::String("A paragraph with a ".into()),
            InlineContent::CodeExpression(CodeExpression {
                programming_language: Some("r".into()),
                text: "2^2".into(),
                ..Default::default()
            }),
        ],
        ..Default::default()
    })]),
    ..Default::default()
};

Develop

Get started by cloning this repository and using cargo to run the tests,

git clone git@github.com:stencila/schema
cd schema/rust
cargo test

Of course, you need to have Rust installed. If you want to re-generate src/types.rs, you'll also need to have Node.js installed (to generate the Rust code from the schema's YAML files).

Dependencies

~2.4–3.5MB
~63K SLoC