noosphere_sphere/lib.rs
1//! This crate implements content, petname and other forms of acccess to
2//! spheres. If you have storage and network primitives on your platform, you
3//! can initialize a [SphereContext] and use it to work with and synchronize
4//! spheres, as well as traverse the broader Noosphere data graph.
5//!
6//! In order to initialize a [SphereContext], you need a [Did] (like an ID) for
7//! a Sphere, a [Storage] primitive and an [Author] (which represents whoever or
8//! whatever is trying to access the Sphere inquestion).
9//!
10//! Once you have a [SphereContext], you can begin reading from, writing to and
11//! traversing the Noosphere content graph.
12//!
13//! ```rust
14//! # use anyhow::Result;
15//! # #[cfg(feature = "helpers")]
16//! # use noosphere_sphere::helpers::{simulated_sphere_context,SimulationAccess};
17//! #
18//! # use noosphere_sphere::{SphereCursor, HasMutableSphereContext, SphereContentWrite};
19//! #
20//! # #[cfg(feature = "helpers")]
21//! # #[tokio::main(flavor = "multi_thread")]
22//! # async fn main() -> Result<()> {
23//! # let (mut sphere_context, _) = simulated_sphere_context(SimulationAccess::ReadWrite, None).await?;
24//! #
25//! sphere_context.write("foo", "text/plain", "bar".as_ref(), None).await?;
26//! sphere_context.save(None).await?;
27//! #
28//! # Ok(())
29//! # }
30//! #
31//! # #[cfg(not(feature = "helpers"))]
32//! # fn main() {}
33//! ```
34//!
35//! You can also use a [SphereContext] to access petnames in the sphere:
36//!
37//! ```rust
38//! # use anyhow::Result;
39//! # #[cfg(feature = "helpers")]
40//! # use noosphere_sphere::helpers::{simulated_sphere_context,SimulationAccess};
41//! # use noosphere_core::data::Did;
42//! #
43//! # use noosphere_sphere::{SphereCursor, HasMutableSphereContext, SpherePetnameWrite};
44//! #
45//! # #[cfg(feature = "helpers")]
46//! # #[tokio::main(flavor = "multi_thread")]
47//! # async fn main() -> Result<()> {
48//! # let (mut sphere_context, _) = simulated_sphere_context(SimulationAccess::ReadWrite, None).await?;
49//! #
50//! sphere_context.set_petname("cdata", Some("did:key:example".into())).await?;
51//! sphere_context.save(None).await?;
52//! #
53//! # Ok(())
54//! # }
55//! #
56//! # #[cfg(not(feature = "helpers"))]
57//! # fn main() {}
58//! ```
59//!
60
61#![warn(missing_docs)]
62
63#[macro_use]
64extern crate tracing;
65
66#[cfg(doc)]
67use noosphere_core::data::Did;
68
69#[cfg(doc)]
70use noosphere_core::authority::Author;
71
72#[cfg(doc)]
73use noosphere_storage::Storage;
74
75mod authority;
76mod content;
77mod context;
78mod cursor;
79mod has;
80mod replication;
81mod walker;
82
83#[cfg(any(doctest, test, feature = "helpers"))]
84pub mod helpers;
85
86mod internal;
87pub mod metadata;
88mod petname;
89mod sync;
90
91pub use authority::*;
92pub use content::*;
93pub use context::*;
94pub use cursor::*;
95pub use has::*;
96pub use metadata::*;
97pub use petname::*;
98pub use replication::*;
99pub use sync::*;
100pub use walker::*;