//! Errors of the knowledge crate. /// Everything that can go wrong chunking, indexing or searching. #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] pub enum Error { /// The note is bigger than [`crate::caps::MAX_NOTE_BYTES`]. #[error("note of {len} bytes exceeds the {max} byte limit")] NoteTooLarge { /// Note size, in bytes. len: usize, /// The limit, in bytes. max: usize, }, /// Indexing the note would pass [`crate::caps::MAX_TOTAL_PASSAGES`]. #[error("the index is full ({max} passages)")] IndexFull { /// The limit, in passages. max: usize, }, /// A query has more terms than [`crate::caps::MAX_QUERY_TERMS`]. #[error("query has {count} terms, the limit is {max}")] TooManyTerms { /// Terms given. count: usize, /// The limit. max: usize, }, /// The path is empty or longer than [`crate::caps::MAX_PATH_BYTES`]. #[error("invalid note path")] InvalidPath, /// The path is in an excluded or reserved folder. #[error("path is excluded from the knowledge index: {0}")] Excluded(String), /// A serialized vocabulary is malformed or over its size limit. #[error("invalid vocabulary cache: {0}")] InvalidCache(String), /// A byte range is outside the content or reversed. #[error("range {start}..{end} is outside content of {len} bytes")] InvalidRange { /// Range start, in bytes. start: usize, /// Range end, in bytes. end: usize, /// Content length, in bytes. len: usize, }, /// A byte range starts or ends inside a `char`. #[error("range starts or ends inside a char")] NotCharBoundary, } /// Result type of the knowledge crate. pub type Result = std::result::Result;