pub struct Journal { /* private fields */ }Expand description
Journals are the primary way that application developers interact with the synchronic web.
Conceptually, a Journal is a service that interacts with users and other Journals (nodes) to persist synchronic web state. Behind the schemes, it is responsible for two capabilities:
-
Persistence: managing bytes on the global hash graph
-
Evaluation: executing code in the global Scheme environment
Records are the primary way that developers interface with Journals. A Record is a mapping between a constant identifier and mutable state. Both identifiers and state are represented as fixed-size Words that the outputs of a cryptographic hash function. When a new record is created, the Journal returns a record secret that is the second hash preimage of the identifier. This is intended to be used so that applications can bootstrap records into increasingly sophisticated notions of identity.
Implementations§
Source§impl Journal
impl Journal
Sourcepub fn evaluate(&self, query: &str) -> String
pub fn evaluate(&self, query: &str) -> String
Evaluate a Scheme expression within a Record
§Examples
use journal_sdk::JOURNAL;
// Simple expression
let output = JOURNAL.evaluate("(+ 1 2)");
assert!(output == "3");
// Complex expression
let output = JOURNAL.evaluate(
"(begin (define (add2 x) (+ x 2)) (add2 1))",
);
assert!(output == "3");pub fn evaluate_json(&self, query: Value) -> Value
Sourcepub fn scheme_to_json(&self, query: &str) -> Value
pub fn scheme_to_json(&self, query: &str) -> Value
Convert a Scheme expression into its JSON representation without evaluation.
§Examples
use journal_sdk::JOURNAL;
use serde_json::json;
let output = JOURNAL.scheme_to_json("(+ 1 2)");
assert_eq!(output, json!(["+", 1, 2]));Sourcepub fn json_to_scheme(&self, query: Value) -> String
pub fn json_to_scheme(&self, query: Value) -> String
Convert a JSON expression into its Scheme representation without evaluation.
§Examples
use journal_sdk::JOURNAL;
use serde_json::json;
let output = JOURNAL.json_to_scheme(json!(["+", 1, 2]));
assert_eq!(output, "(+ 1 2)");