Streaming Tree ARchive format
at rust-impl 46 lines 1.1 kB view raw
1use cid::Cid; 2use std::io; 3use thiserror::Error; 4 5#[derive(Debug)] 6pub enum VerificationKind { 7 Node, 8 Record { key: Vec<u8> }, 9} 10 11#[derive(Error, Debug)] 12pub enum StarError { 13 #[error("IO error: {0}")] 14 Io(#[from] io::Error), 15 #[error("CBOR error: {0}")] 16 Cbor(String), 17 #[error("CID error: {0}")] 18 Cid(#[from] cid::Error), 19 #[error("Multihash error: {0}")] 20 Multihash(#[from] cid::multihash::Error), 21 #[error("Invalid STAR header")] 22 InvalidHeader, 23 #[error("Unexpected EOF")] 24 UnexpectedEof, 25 26 #[error("Verification failed for {kind:?}: expected {expected}, got {computed}")] 27 VerificationFailed { 28 kind: VerificationKind, 29 expected: Box<Cid>, 30 computed: Box<Cid>, 31 }, 32 33 #[error("Invalid state: {0}")] 34 InvalidState(String), 35 36 #[error("Invalid structure: {0}")] 37 InvalidStructure(String), 38 39 #[error("Height mismatch: found {found}, expected {expected}")] 40 HeightMismatch { found: u32, expected: u32 }, 41 42 #[error("Trailing data")] 43 TrailingData, 44} 45 46pub type Result<T> = std::result::Result<T, StarError>;