Skip to main content

ipld_car/error/
dag_pb.rs

1use crate::bounded_reader::error::BoundedReaderErr;
2
3use std::io;
4use thiserror::Error;
5
6pub type DagPbResult<T> = Result<T, DagPbErr>;
7
8#[derive(Error, Debug)]
9pub enum DagPbErr {
10	#[error("PbNode cannot be decoded because it exceeds the buffer limit")]
11	ExceedBufLimitOnDecode,
12	#[error("File too large")]
13	FileTooLarge,
14
15	#[error(transparent)]
16	Io(#[from] io::Error),
17	#[error(transparent)]
18	UnixFs(#[from] UnixFsErr),
19	#[error(transparent)]
20	BoundedReader(#[from] BoundedReaderErr),
21}
22
23#[derive(Error, Debug)]
24pub enum UnixFsErr {
25	#[error("UnixFs data is missing")]
26	MissingData,
27	#[error("Missing link name (mandatory) in Directory PbNode")]
28	MissingLinkNameInDirectory,
29	#[error("Invalid UnixFs data")]
30	InvalidData,
31	#[error("UnixFs data type is not supported: {0}")]
32	DataTypeNotSupported(i32),
33	#[error("UnixFs file with blocksizes {0} elements and {1} links")]
34	BlocksizesLenDiffLinksLen(usize, usize),
35	#[error("UnixFs symlink MUST NOT have children in `PbNode.links`")]
36	SymlinkWithChildren,
37	#[error("UnixFs symlink DOES NOT contains information")]
38	MissingSymlinkInfo,
39	#[error("UnixFs symlink's path is NOT an UFT-8")]
40	SymlinkPathUtf8,
41	#[error("UnixFs file contains data and reader")]
42	FileWithDataAndReader,
43}