//! Error types for atproto-plc operations use thiserror::Error; /// The main error type for all atproto-plc operations #[derive(Error, Debug)] pub enum PlcError { /// Invalid DID format #[error("Invalid DID format: {0}")] InvalidDidFormat(String), /// Invalid base32 encoding #[error("Invalid base32 encoding: {0}")] InvalidBase32(String), /// Invalid base64url encoding #[error("Invalid base64url encoding: {0}")] InvalidBase64Url(String), /// Signature verification failed #[error("Signature verification failed")] SignatureVerificationFailed, /// Operation exceeds the 7500 byte limit #[error("Operation exceeds 7500 byte limit: {0} bytes")] OperationTooLarge(usize), /// Invalid rotation keys #[error("Invalid rotation keys: {0}")] InvalidRotationKeys(String), /// Invalid verification methods #[error("Invalid verification methods: {0}")] InvalidVerificationMethods(String), /// Invalid service endpoint #[error("Invalid service endpoint: {0}")] InvalidService(String), /// Operation chain validation failed #[error("Operation chain validation failed: {0}")] ChainValidationFailed(String), /// DAG-CBOR encoding error #[error("DAG-CBOR encoding error: {0}")] DagCborError(String), /// DAG-CBOR decoding error #[error("DAG-CBOR decoding error: {0}")] DagCborDecodeError(String), /// Invalid did:key format #[error("Invalid did:key format: {0}")] InvalidDidKey(String), /// Unsupported key type #[error("Unsupported key type: {0}")] UnsupportedKeyType(String), /// Invalid CID format #[error("Invalid CID format: {0}")] InvalidCid(String), /// Missing required field #[error("Missing required field: {0}")] MissingField(String), /// Invalid operation type #[error("Invalid operation type: {0}")] InvalidOperationType(String), /// No valid operations in chain #[error("No valid operations in chain")] EmptyChain, /// First operation must be genesis #[error("First operation must be genesis (prev must be null)")] FirstOperationNotGenesis, /// Invalid prev field #[error("Invalid prev field: {0}")] InvalidPrev(String), /// Cryptographic error #[error("Cryptographic error: {0}")] CryptoError(String), /// JSON serialization error #[error("JSON error: {0}")] JsonError(#[from] serde_json::Error), /// Invalid also-known-as URI #[error("Invalid also-known-as URI: {0}")] InvalidAlsoKnownAs(String), /// Too many entries #[error("Too many {field}: maximum is {max}, got {actual}")] TooManyEntries { /// Name of the field with too many entries field: String, /// Maximum allowed entries max: usize, /// Actual number of entries actual: usize, }, /// Duplicate entry #[error("Duplicate {field}: {value}")] DuplicateEntry { /// Name of the field with duplicate entry field: String, /// Value of the duplicate entry value: String, }, /// Invalid timestamp #[error("Invalid timestamp: {0}")] InvalidTimestamp(String), /// Fork resolution error #[error("Fork resolution error: {0}")] ForkResolutionError(String), } /// Result type alias for atproto-plc operations pub type Result = std::result::Result;