1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! [`RdfEventsStore`]: crate::oxistore::manager::RdfEventsStore
//! [`run_query`]: crate::oxistore::manager::RdfEventsStore::run_query
//! [`Client`]: nostr_sdk::Client
//!
//! *nostralink* is a Rust crate that allows you to transform [nostr](https://nostr.how)
//! events to linked data and save them to an [RDF](https://www.w3.org/RDF) triple store.
//! It also offers APIs to write events as linked data (using JSON-LD) and make queries.
//!
//! # RDF events store
//!
//! In order to activate nostralink for a nostr [`Client`] , open an [`RdfEventsStore`]
//! and set it as the client's [database](https://crates.io/crates/nostr-database).
//! Incoming events will automatically be converted to RDF triples and saved to the store.
//!
//! ```rust
//! use nostralink::prelude::*;
//! use std::path::PathBuf;
//!
//! #[tokio::main]
//! async fn main() {
//! let keys = Keys::generate();
//! let store = RdfEventsStore::open(PathBuf::from("store")).expect("Cannot open store");
//! let client = Client::builder().database(store).signer(keys).build();
//! }
//! ```
//!
//! # Querying
//!
//! Use [`run_query`] to run a SparQL query. There is a built-in
//! [collection](https://codeberg.org/nostralink/nostralink/src/branch/master/sparql)
//! of SparQL queries. Use [`crate::querydb::nrq_get`] to retrieve a query by its name.
//!
//! ```
//! use nostralink::prelude::*;
//! use std::path::PathBuf;
//!
//! fn main() -> Result<(), RdfStoreError> {
//! let store = RdfEventsStore::open(PathBuf::from("store")).expect("Cannot open store");
//! let result_set = store
//! .run_query(&nrq_get("user_metadata")?, [], None)?;
//!
//! for row in &result_set.rows {
//! if let Some(cell) = row.get("metadata_name") {
//! println!("name: {}", cell.to_string());
//! }
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! - [paz (nostr client written with nostralink)](https://codeberg.org/nostralink/paz)
//! - [Book](https://nostralink.codeberg.page)
gen!