Expand description

p2panda-rs

This library provides all tools required to write a client for the p2panda network. It is shipped both as a Rust crate p2panda-rs with WebAssembly bindings and a NPM package p2panda-js with TypeScript definitions running in NodeJS or any modern web browser.

Example

Creates and signs data which can be sent to a p2panda node.

// Generate new Ed25519 key pair
let key_pair = KeyPair::new();

// Add field data to "create" operation
let operation = OperationBuilder::new(&profile_schema_id)
    .fields(&[("username", "panda".into())])
    .build()?;

// Encode operation into bytes
let encoded_operation = encode_operation(&operation)?;

// Create Bamboo entry (append-only log data type) with operation as payload
let entry = EntryBuilder::new()
    .sign(&encoded_operation, &key_pair)?;

// Encode entry into bytes
let encoded_entry = encode_entry(&entry)?;

println!("{} {}", encoded_entry, encoded_operation);

Modules

Document is a replicatable data type designed to handle concurrent updates in a way where all replicas eventually resolve to the same deterministic value.

Create, sign, encode and decode Bamboo entries.

Generic structs which can be used for building a graph structure and sorting it’s nodes in a topological depth-first manner.

Hash type of p2panda using BLAKE3 algorithm wrapped in YASMF “Yet-Another-Smol-Multi-Format”.

Generates and maintains Ed25519 key pairs with the secret and public (PublicKey) counterparts.

Create, encode and decode p2panda operations.

Schemas describe the format of data used in operation fields.

Commonly used functions for serialization and deserialization of values.

Traits

Trait used by p2panda structs for human-facing functionality, like better readability.

Trait used by p2panda structs to validate data formats.