Crate noosphere

source ·
Expand description

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.

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?;

Modules§

  • This module defines a C FFI for Noosphere, suitable for cross-language embedding on many different targets
  • Key management is a critical part of working with the Noosphere protocol. This module offers various backing storage mechanisms for key storage, including both insecure and secure options.
  • Platform-specific types and bindings Platforms will vary in capabilities for things like block storage and secure key management. This module lays out the concrete strategies we will use on a per-platform basis.
  • Constructs that describe high-level operations related to spheres, such as creation, joining and recovery.
  • Intermediate constructs to normalize how storage is initialized

Structs§

  • A NoosphereContext holds configuration necessary to initialize and store Noosphere data. It also keeps a running list of active SphereContext instances to avoid the expensive action of repeatedly opening and closing a handle to backing storage for spheres that are being accessed regularly.
  • Configuration needed in order to initialize a NoosphereContext. This configuration is intended to be flexible enough to adapt to both target platform and use case of the implementing application.
  • Fields describing configuration of Noosphere’s storage layer.

Enums§

  • An enum describing the possible network configurations that are able to be used by the Noosphere implementation
  • This enum exists so that we can incrementally layer on support for secure key storage over time. Each member represents a set of environmental qualities, with the most basic represnting an environment with no trusted hardware key storage.
  • An enum describing different storage stragies that may be interesting depending on the environment and implementation of Noosphere

Type Aliases§