[][src]Crate atomic_lib

atomic_lib helps you to get, store, serialize, parse and validate Atomic Data.

The Store contains most of the logic that you need.

Getting started

// Import the `Storelike` trait to get access to most functions
use atomic_lib::Storelike;
// Start with initializing our store
let store = atomic_lib::Store::init();
// Load the default Atomic Data Atoms
store.populate().unwrap();
// Let's parse this AD3 string. It looks awkward because of the escaped quotes.
let string = r#"["_:test","https://atomicdata.dev/properties/description","Test"]"#;
// The parser returns a Vector of Atoms
let atoms = atomic_lib::parse::parse_ad3(&string).unwrap();
// Add the Atoms to the Store
store.add_atoms(atoms).unwrap();
// Get our resource...
let my_resource = store.get_resource("_:test").unwrap();
// Get our value by filtering on our property...
let my_value = my_resource
    .get("https://atomicdata.dev/properties/description")
    .unwrap();
assert!(my_value.to_string() == "Test");
// We can also use the shortname of description
let my_value_from_shortname = my_resource.get_shortname("description").unwrap();
assert!(my_value_from_shortname.to_string() == "Test");
// We can find any Atoms matching some value using Triple Pattern Fragments:
let found_atoms = store.tpf(None, None, Some("Test")).unwrap();
assert!(found_atoms.len() == 1);

Re-exports

pub use atoms::Atom;
pub use atoms::RichAtom;
pub use commit::Commit;
pub use delta::DeltaLine;
pub use resources::Resource;
pub use resources::ResourceString;
pub use store::Store;
pub use storelike::Storelike;
pub use values::Value;

Modules

agents

Logic for Agents - which are like Users

atoms

The smallest units of data, consiting of a Subject, a Property and a Value

client

Functions for interacting with an Atomic Server

collections

Collections are dynamic resources that refer to multiple resources. They are constructed using a TPF query

commit

Describe changes / mutations to data

datatype

Datatypes constrain values of Atoms

delta

Describe changes / mutations to data Deprecated in favor or Commit

errors

The Error type that you can expect when using this library

mapping

Because writing full URLs is error prone and time consuming, we map URLs to shortnames. These are often user-specific. This section provides tools to store, share and resolve these Mappings.

mutations
parse

Parsing / deserialization / decoding

resources

A resource is a set of Atoms that share a URL

serialize

Serialization / formatting / encoding (JSON, RDF, N-Triples, AD3)

store

In-memory store of Atomic data. This provides many methods for finding, changing, serializing and parsing Atomic Data. Currently, it can only persist its data as .ad3 (Atomic Data Triples) to disk. A more robust persistent storage option will be used later, such as: https://github.com/TheNeikos/rustbreak

store_native
storelike

Trait for all stores to use

urls

Contains some of the most important Atomic Data URLs.

validate
values

A value is the part of an Atom that contains the actual information.