use crate::types::DataAddress;
use crate::types::PublicKey;
use serde::{Deserialize, Serialize};
use std::result;
use thiserror::Error;
use xor_name::{Prefix, XorName};
pub type Result<T, E = Error> = result::Result<T, E>;
#[derive(Error, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
#[non_exhaustive]
#[allow(clippy::large_enum_variant)]
pub enum Error {
#[error("Access denied for PublicKey: {0}")]
AccessDenied(PublicKey),
#[error("Requested chunk not found: {0:?}")]
ChunkNotFound(XorName),
#[error("Requested data not found: {0:?}")]
DataNotFound(DataAddress),
#[error("Failed to write file")]
FailedToWriteFile,
#[error("Failed to store chunk. Insufficient space found at section {0:?} adults")]
InsufficientAdults(Prefix),
#[error("Data provided already exists")]
DataExists,
#[error("Requested entry not found")]
NoSuchEntry,
#[error("Key does not exist")]
NoSuchKey,
#[error("Invalid owner key: {0}")]
InvalidOwner(PublicKey),
#[error("Invalid operation: {0}")]
InvalidOperation(String),
#[error("Operation id could not be derived.")]
NoOperationId,
#[error("Failed to delete requested data")]
FailedToDelete,
#[error(
"Could not generation operation id for chunk retrieval. Error was not 'DataNotFound'."
)]
InvalidQueryResponseErrorForOperationId,
#[error("Destination is either outdated or wrong")]
WrongDestination,
}