sn_client/chunks/
error.rsuse self_encryption::MIN_ENCRYPTABLE_BYTES;
use sn_protocol::PrettyPrintRecordKey;
use std::io;
use thiserror::Error;
use xor_name::XorName;
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug, Error)]
pub enum Error {
    #[error("Failed to get find payment for record: {0:?}")]
    NoPaymentForRecord(PrettyPrintRecordKey<'static>),
    #[error("Failed to get chunk permit")]
    CouldNotGetChunkPermit,
    #[error(transparent)]
    SelfEncryption(#[from] self_encryption::Error),
    #[error(transparent)]
    Io(#[from] io::Error),
    #[error(transparent)]
    Serialisation(#[from] rmp_serde::encode::Error),
    #[error(transparent)]
    Deserialisation(#[from] rmp_serde::decode::Error),
    #[error("Cannot store empty file.")]
    EmptyFileProvided,
    #[error("File is too small to be encrypted, it is less than {MIN_ENCRYPTABLE_BYTES} bytes")]
    FileTooSmall,
    #[error(
        "The provided bytes ({size}) is too large to store as a `SmallFile` which maximum can be \
        {maximum}. Store as a LargeFile instead."
    )]
    TooLargeAsSmallFile {
        size: usize,
        maximum: usize,
    },
    #[error("Not all chunks were retrieved, expected {expected}, retrieved {retrieved}, missing {missing_chunks:?}.")]
    NotEnoughChunksRetrieved {
        expected: usize,
        retrieved: usize,
        missing_chunks: Vec<XorName>,
    },
    #[error("Chunk could not be retrieved from the network: {0:?}")]
    ChunkMissing(XorName),
    #[error("Not all data was chunked, expected {expected}, but we have {chunked}.)")]
    NotAllDataWasChunked {
        expected: usize,
        chunked: usize,
    },
}