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
//! This crate is a high-level entrypoint for embedders of the Noosphere
//! protocol. Embedders may use [NoosphereContext] to initialize a singleton
//! that enables manaing spheres, including creating new ones and joining
//! existing ones.
//!
//! ```rust,no_run
//! # use noosphere::{
//! # NoosphereStorage, NoosphereStoragePath, NoosphereStorageConfig, NoosphereSecurity, NoosphereNetwork,
//! # NoosphereContextConfiguration, NoosphereContext, sphere::SphereReceipt
//! # };
//! # use noosphere_core::{
//! # context::{
//! # HasMutableSphereContext, SphereContentWrite, SphereSync
//! # },
//! # data::ContentType
//! # };
//! # use url::Url;
//! # use anyhow::Result;
//! #
//! # #[tokio::main]
//! # pub async fn main() -> Result<()> {
//! let noosphere = NoosphereContext::new(NoosphereContextConfiguration {
//! storage: NoosphereStorage {
//! path: NoosphereStoragePath::Scoped("/path/to/block/storage".into()),
//! config: NoosphereStorageConfig::default(),
//! },
//! security: NoosphereSecurity::Insecure {
//! path: "/path/to/key/storage".into(),
//! },
//! network: NoosphereNetwork::Http {
//! gateway_api: Some(Url::parse("http://example.com")?),
//! ipfs_gateway_url: None,
//! },
//! })?;
//!
//! noosphere.create_key("my-key").await?;
//!
//! let SphereReceipt { identity, mnemonic } = noosphere.create_sphere("my-key").await?;
//!
//! // identity is the sphere's DID
//! // mnemonic is a recovery phrase that must be stored securely by the user
//!
//! let mut sphere_channel = noosphere.get_sphere_channel(&identity).await?;
//! let sphere = sphere_channel.mutable();
//!
//! // Write something to the sphere's content space
//! sphere.write("foo", &ContentType::Text, "bar".as_bytes(), None).await?;
//! sphere.save(None).await?;
//! // Sync the sphere with the network via a Noosphere gateway
//! sphere.sync().await?;
//! # Ok(())
//! # }
//! ```
extern crate tracing;
pub use crate*;