jsonld_core/lib.rs
1//! Core types shared by the JSON-LD processing algorithms.
2//!
3//! This crate defines the data model the algorithm crates operate on — the
4//! processed [`Context`], the [`Object`] tree an expanded document is made
5//! of, [`ExpandedDocument`] and [`FlattenedDocument`], and the [`Loader`]
6//! trait used to dereference remote contexts — together with the conversions
7//! to RDF ([`rdf`]) and the pretty-printer ([`mod@print`]).
8//!
9//! Identifiers are generic over the vocabulary that interns them: `T` is an
10//! IRI handle and `B` a blank node identifier handle, defaulting to owned
11//! [`iri_rs::IriBuf`] and [`rdfx::BlankIdBuf`] values.
12//!
13//! Most users should depend on the `jsonld` umbrella crate rather than on
14//! this one directly; it re-exports everything here alongside the algorithms.
15// On docs.rs, label every feature-gated item with the feature that unlocks it.
16// `doc(auto_cfg)` is still nightly-gated, and `docsrs` is set by docs.rs itself
17// (see `rustdoc-args` in Cargo.toml), so stable builds are unaffected.
18#![cfg_attr(docsrs, feature(doc_cfg))]
19#![cfg_attr(docsrs, doc(auto_cfg))]
20pub use jsonld_syntax::{Direction, LenientLangTag, LenientLangTagBuf, Nullable};
21
22mod container;
23pub mod context;
24mod deserialization;
25mod document;
26pub mod flattening;
27mod hash;
28/// Node identifiers, valid or not.
29pub mod id;
30mod indexed;
31mod lang_string;
32/// Document loaders.
33pub mod loader;
34mod mode;
35pub mod object;
36/// Pretty-printing of JSON-LD documents.
37pub mod print;
38/// RDF quads of an expanded document.
39pub mod quad;
40pub mod rdf;
41mod serialization;
42pub use serialization::SerializationError;
43mod term;
44mod ty;
45pub mod utils;
46/// Warnings raised by the algorithms.
47pub mod warning;
48
49pub use container::{Container, ContainerKind};
50pub use context::{Context, ContextRef};
51pub use document::*;
52pub use flattening::Flatten;
53pub use hash::{DefaultBuildHasher, HashMap, HashSet, IndexMap, IndexSet};
54pub use id::*;
55pub use indexed::*;
56pub use lang_string::*;
57pub use loader::*;
58pub use mode::*;
59pub use object::{IndexedNode, IndexedObject, Node, NodeParts, Nodes, Object, Objects, TryFromJson, Value};
60pub use print::Print;
61pub use quad::LdQuads;
62pub use rdf::RdfQuads;
63pub use term::*;
64pub use ty::*;
65
66/// Vocabulary, loader and warning handler an algorithm runs against.
67pub struct Environment<'a, N, L, W> {
68 /// Vocabulary interning IRIs and blank node identifiers.
69 pub vocabulary: &'a mut N,
70 /// Loader used to dereference remote documents and contexts.
71 pub loader: &'a L,
72 /// Handler collecting the warnings raised along the way.
73 pub warnings: &'a mut W,
74}