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
73
74
//! # Helia JSON
//!
//! JSON support for Helia, providing simple JSON serialization and storage
//! for structured data compatible with IPFS JSON specification.
//!
//! ## Example
//!
//! ```rust
//! use helia::create_helia;
//! use helia_json::{Json, JsonInterface};
//! use serde::{Deserialize, Serialize};
//! use std::collections::HashMap;
//! use std::sync::Arc;
//!
//! #[derive(Serialize, Deserialize, PartialEq, Debug)]
//! struct MyData {
//! hello: String,
//! numbers: Vec<i32>,
//! }
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let helia = create_helia(None).await?;
//! let json = Json::new(Arc::new(helia));
//!
//! let data = MyData {
//! hello: "world".to_string(),
//! numbers: vec![1, 2, 3],
//! };
//!
//! // Add JSON data
//! let cid = json.add(&data, None).await?;
//!
//! // Retrieve JSON data
//! let retrieved: MyData = json.get(&cid, None).await?;
//! assert_eq!(data, retrieved);
//!
//! Ok(())
//! }
//! ```
use Arc;
use ;
pub use *;
pub use *;
/// Options for adding JSON data
/// Options for getting JSON data
/// Create a JSON instance for use with Helia