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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! This module implements content, petname and other forms of acccess to
//! spheres. If you have storage and network primitives on your platform, you
//! can initialize a [SphereContext] and use it to work with and synchronize
//! spheres, as well as traverse the broader Noosphere data graph.
//!
//! In order to initialize a [SphereContext], you need a [Did] (like an ID) for
//! a Sphere, a [Storage] primitive and an [Author] (which represents whoever or
//! whatever is trying to access the Sphere inquestion).
//!
//! Once you have a [SphereContext], you can begin reading from, writing to and
//! traversing the Noosphere content graph.
//!
//! ```rust
//! # use anyhow::Result;
//! # use noosphere_core::{authority::Access, context::{SphereCursor, HasMutableSphereContext, SphereContentWrite}};
//! #
//! # #[cfg(feature = "helpers")]
//! # use noosphere_core::helpers::simulated_sphere_context;
//! #
//! # #[cfg(feature = "helpers")]
//! # #[tokio::main(flavor = "multi_thread")]
//! # async fn main() -> Result<()> {
//! # let (mut sphere_context, _) = simulated_sphere_context(Access::ReadWrite, None).await?;
//! #
//! sphere_context.write("foo", "text/plain", "bar".as_ref(), None).await?;
//! sphere_context.save(None).await?;
//! #
//! # Ok(())
//! # }
//! #
//! # #[cfg(not(feature = "helpers"))]
//! # fn main() {}
//! ```
//!
//! You can also use a [SphereContext] to access petnames in the sphere:
//!
//! ```rust
//! # use anyhow::Result;
//! # #[cfg(feature = "helpers")]
//! # use noosphere_core::{
//! # authority::Access,
//! # helpers::simulated_sphere_context,
//! # data::Did,
//! # context::{SphereCursor, HasMutableSphereContext, SpherePetnameWrite}
//! # };
//! #
//! # #[cfg(feature = "helpers")]
//! # #[tokio::main(flavor = "multi_thread")]
//! # async fn main() -> Result<()> {
//! # let (mut sphere_context, _) = simulated_sphere_context(Access::ReadWrite, None).await?;
//! #
//! sphere_context.set_petname("cdata", Some("did:key:example".into())).await?;
//! sphere_context.save(None).await?;
//! #
//! # Ok(())
//! # }
//! #
//! # #[cfg(not(feature = "helpers"))]
//! # fn main() {}
//! ```
//!
//!
use crate::;
use Storage;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;