Weave documentation
Rust referencestrand-errors

strand-errors · crate

Source declarations, signatures and documentation for crate.

Source: sigil/weave/libs/strand-errors/src/lib.rs. SHA-256: 55c2030c6ef9ca6f2b563374eab9f7b949d291a79e73882b89e67f9ea9bc7cda.

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.

::StorageError

Storage-related errors

#[derive(Debug, Error)]
pub enum StorageError {
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    #[error("Block not found: index {0}")]
    BlockNotFound(u64),

    #[error("Corrupted block at index {index}: {reason}")]
    CorruptedBlock { index: u64, reason: String },

    #[error("Storage backend unavailable: {0}")]
    BackendUnavailable(String),

    #[error("Insufficient space: need {required} bytes, have {available}")]
    InsufficientSpace { required: u64, available: u64 },

    #[error("Invalid storage path: {0}")]
    InvalidPath(String),
}

Source line: 27.

::CryptoError

Cryptographic operation errors

#[derive(Debug, Error)]
pub enum CryptoError {
    #[error("Invalid signature")]
    InvalidSignature,

    #[error("Invalid public key: {0}")]
    InvalidPublicKey(String),

    #[error("Invalid secret key")]
    InvalidSecretKey,

    #[error("Key derivation failed: {0}")]
    KeyDerivationFailed(String),

    #[error("Encryption failed: {0}")]
    EncryptionFailed(String),

    #[error("Decryption failed: {0}")]
    DecryptionFailed(String),

    #[error("Invalid key length: expected {expected}, got {actual}")]
    InvalidKeyLength { expected: usize, actual: usize },
}

Source line: 49.

::ProtocolError

Protocol-level errors

#[derive(Debug, Error)]
pub enum ProtocolError {
    #[error("Version mismatch: local {local}, remote {remote}")]
    VersionMismatch { local: u32, remote: u32 },

    #[error("Invalid message type: {0}")]
    InvalidMessageType(u8),

    #[error("Protocol timeout after {0} seconds")]
    Timeout(u64),

    #[error("Invalid state transition: from {from} to {to}")]
    InvalidStateTransition { from: String, to: String },

    #[error("Handshake failed: {0}")]
    HandshakeFailed(String),

    #[error("Channel closed unexpectedly")]
    ChannelClosed,

    #[error("Message too large: {size} bytes (max: {max})")]
    MessageTooLarge { size: usize, max: usize },
}

Source line: 74.

::OwnershipError

Ownership and permission errors (identity-system agnostic)

#[derive(Debug, Error)]
pub enum OwnershipError {
    #[error("Invalid agent identity: {0}")]
    InvalidAgentIdentity(String),

    #[error("Invalid organization identity: {0}")]
    InvalidOrganizationIdentity(String),

    #[error("Agent {agent_identity} not authorized for action: {action}")]
    AgentNotAuthorized {
        agent_identity: String,
        action: String,
    },

    #[error("Agent {agent_identity} not part of organization {org_identity}")]
    AgentNotInOrganization {
        agent_identity: String,
        org_identity: String,
    },

    #[error("Writer mismatch: expected {expected}, got {actual}")]
    WriterMismatch { expected: String, actual: String },

    #[error("Organization verification failed: {0}")]
    OrganizationVerificationFailed(String),

    #[error("Multi-signatory consensus failed: {obtained}/{required} signatures")]
    MultiSignatoryConsensusFailed { obtained: usize, required: usize },

    #[error("Governance approval required for: {action}")]
    GovernanceApprovalRequired { action: String },

    #[error("Permission denied: {identity} cannot perform {permission}")]
    PermissionDenied {
        identity: String,
        permission: String,
    },

    #[error("Identity resolution failed: {0}")]
    IdentityResolutionFailed(String),

    #[error("Invalid signature for identity: {identity}")]
    InvalidSignatureForIdentity { identity: String },
}

Source line: 99.

::ReplicationError

Replication and synchronization errors

#[derive(Debug, Error)]
pub enum ReplicationError {
    #[error("Sync failed: {0}")]
    SyncFailed(String),

    #[error("Fork detected at index {0}")]
    ForkDetected(u64),

    #[error("Invalid proof: {0}")]
    InvalidProof(String),

    #[error("Peer disconnected during replication")]
    PeerDisconnected,

    #[error("Bandwidth limit exceeded: {used}/{limit} bytes")]
    BandwidthExceeded { used: u64, limit: u64 },
}

Source line: 145.

::ValidationError

Data validation errors

#[derive(Debug, Error)]
pub enum ValidationError {
    #[error("Invalid block size: {0} bytes")]
    InvalidBlockSize(usize),

    #[error("Invalid tree state: {0}")]
    InvalidTreeState(String),

    #[error("Checksum mismatch")]
    ChecksumMismatch,

    #[error("Invalid index: {0}")]
    InvalidIndex(u64),

    #[error("Schema validation failed: {0}")]
    SchemaValidation(String),
}

Source line: 164.

::StrandError

Master error type that encompasses all error categories

#[derive(Debug, Error)]
pub enum StrandError {
    #[error(transparent)]
    Storage(#[from] StorageError),

    #[error(transparent)]
    Crypto(#[from] CryptoError),

    #[error(transparent)]
    Protocol(#[from] ProtocolError),

    #[error(transparent)]
    Ownership(#[from] OwnershipError),

    #[error(transparent)]
    Replication(#[from] ReplicationError),

    #[error(transparent)]
    Validation(#[from] ValidationError),

    #[error("Internal error: {0}")]
    Internal(String),

    #[error("Not implemented: {0}")]
    NotImplemented(String),
}

Source line: 183.

::Result

Convenience type alias for Results using StrandError

pub type Result<T> = std::result::Result<T, StrandError>;

Source line: 210.

::ErrorContext

Provides additional context for errors

pub trait ErrorContext<T> {
    /// Add a simple string context to the error
    fn context(self, msg: &str) -> Result<T>;

    /// Add context using a closure (for expensive formatting)
    fn with_context<F>(self, f: F) -> Result<T>
    where
        F: FnOnce() -> String;
}

Source line: 213.

::ErrorCode

Error codes for external APIs

#[repr(u32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ErrorCode {
    // Storage errors (1000-1999)
    StorageIo = 1001,
    BlockNotFound = 1002,
    CorruptedBlock = 1003,

    // Crypto errors (2000-2999)
    InvalidSignature = 2001,
    InvalidKey = 2002,

    // Protocol errors (3000-3999)
    VersionMismatch = 3001,
    Timeout = 3002,

    // Ownership errors (4000-4999)
    PermissionDenied = 4001,
    InvalidDid = 4002,

    // Replication errors (5000-5999)
    SyncFailed = 5001,
    ForkDetected = 5002,

    // Validation errors (6000-6999)
    ValidationFailed = 6001,
    ChecksumMismatch = 6002,

    // General errors
    InternalError = 9001,
    NotImplemented = 9002,
}

Source line: 240.

::ToIoErrorKind

Extension to map errors to io::ErrorKind when appropriate

pub trait ToIoErrorKind {
    /// Returns a corresponding io::ErrorKind when a meaningful mapping exists
    fn to_io_error_kind(&self) -> Option<io::ErrorKind>;
}

Source line: 314.

::SerializedError

#[cfg(feature = "serde")]
#[derive(Debug, Serialize, Deserialize)]
pub struct SerializedError {
pub code: ErrorCode,
pub message: String,
pub details: Option<serde_json::Value>
}

Source line: 451.

::StrandError::error_name

Get JavaScript-compatible error name

pub fn error_name(&self) -> &'static str;

Source line: 471.

On this page