strand-id-encoding · crate
Source declarations, signatures and documentation for crate.
Source: sigil/weave/libs/strand-id-encoding/src/lib.rs. SHA-256: de81cdb769390b0fafb60e4f1679d9d20cc6c20a23fde7c699cd111caa238e70.
This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.
::StrandIdError
Error types for strand ID encoding/decoding operations
#[derive(Debug, Error)]
pub enum StrandIdError {
#[error("Invalid key length: expected 32 bytes, got {0}")]
InvalidKeyLength(usize),
#[error("Invalid z-base32 encoding: {0}")]
InvalidZBase32(String),
#[error("Invalid hex encoding: {0}")]
InvalidHex(String),
#[error("Invalid identity format: {0}")]
InvalidIdentity(String),
#[error("Unsupported identity scheme: {0}")]
UnsupportedIdentityScheme(String),
#[error("Invalid format")]
InvalidFormat,
#[error("Invalid entity type: {0}")]
InvalidEntityType(String),
}Source line: 36.
::StrandId
A wrapper around a 32-byte key to allow for trait implementations.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct StrandId(pub [u8; 32]);Source line: 61.
::StrandIdentity
A wrapper around a String to represent a Strand identity.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StrandIdentity(pub String);Source line: 71.
::EntityType
Entity types for identity encoding
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EntityType {
/// Strand entity
Strand,
/// Agent entity
Agent,
/// Human entity
Human,
/// Tool entity
Tool,
/// Organization entity
Org,
}Source line: 81.
::EntityType::as_str
Convert entity type to string for identity
pub fn as_str(&self) -> &'static str;Source line: 96.
::encode
Encode a 32-byte key to z-base32
pub fn encode(key: &[u8; 32]) -> String;Source line: 134.
::encode_hex
Encode a 32-byte key to hexadecimal
pub fn encode_hex(key: &[u8; 32]) -> String;Source line: 139.
::encode_identity
Encode a key as an identity string
Creates an identity string in the format: {scheme}:{entity_type}:{encoded_key}
where encoded_key is the z-base32 encoded representation of the key.
pub fn encode_identity(key: &[u8; 32], entity_type: EntityType, scheme: &str) -> String;Source line: 147.
::decode
Decode from z-base32
pub fn decode(encoded: &str) -> Result<[u8; 32], StrandIdError>;Source line: 153.
::decode_hex
Decode from hexadecimal
pub fn decode_hex(encoded: &str) -> Result<[u8; 32], StrandIdError>;Source line: 158.
::decode_identity
Decode from identity string
Parses identity strings in the format: {scheme}:{entity_type}:{encoded_key}
and returns the decoded 32-byte key.
pub fn decode_identity(identity_str: &str) -> Result<[u8; 32], StrandIdError>;Source line: 178.
compat
Compatibility module for TypeScript interface parity
pub mod compat;Source line: 276.
compat::normalize
Normalize any valid input format to z-base32
pub fn normalize(input: &str) -> Result<String, StrandIdError>;Source line: 280.
compat::is_valid
Check if input is a valid strand ID in any supported format
pub fn is_valid(input: &str) -> bool;Source line: 286.
compat::decode_any
Decode from any supported format
pub fn decode_any(input: &str) -> Result<[u8; 32], StrandIdError>;Source line: 291.