foundationdb/directory/
error.rs

1// Copyright 2018 foundationdb-rs developers, https://github.com/Clikengo/foundationdb-rs/graphs/contributors
2// Copyright 2013-2018 Apple, Inc and the FoundationDB project authors.
3//
4// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
5// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
6// http://opensource.org/licenses/MIT>, at your option. This file may not be
7// copied, modified, or distributed except according to those terms.
8
9//! Errors that can be thrown by Directory.
10
11use crate::error;
12use crate::tuple::hca::HcaError;
13use crate::tuple::PackError;
14use std::io;
15
16/// The enumeration holding all possible errors from a Directory.
17#[derive(Debug)]
18pub enum DirectoryError {
19    /// cannot modify the root directory
20    CannotModifyRootDirectory,
21    /// prefix is already used
22    DirectoryPrefixInUse,
23    /// Directory does not exists
24    DirectoryDoesNotExists,
25    /// missing path.
26    NoPathProvided,
27    /// tried to create an already existing path.
28    DirAlreadyExists,
29    /// missing directory.
30    PathDoesNotExists,
31    /// Parent does not exists
32    ParentDirDoesNotExists,
33    /// the layer is incompatible.
34    IncompatibleLayer,
35    /// the destination directory cannot be a subdirectory of the source directory.
36    BadDestinationDirectory,
37    /// Bad directory version.
38    Version(String),
39    /// cannot specify a prefix unless manual prefixes are enabled
40    PrefixNotAllowed,
41    /// cannot specify a prefix in a partition.
42    CannotPrefixInPartition,
43    /// the root directory cannot be moved
44    CannotMoveRootDirectory,
45    CannotMoveBetweenPartition,
46    /// the destination directory cannot be a subdirectory of the source directory
47    CannotMoveBetweenSubdirectory,
48    /// Prefix is not empty
49    PrefixNotEmpty,
50    /// Thrown when the subpath cannot be computed due to length errors
51    CannotCreateSubpath,
52    /// cannot open subspace in the root of a directory partition
53    CannotOpenDirectoryPartition,
54    /// cannot get key for the root of a directory partition
55    CannotGetKeyDirectoryPartition,
56    /// cannot pack for the root of a directory partition
57    CannotPackDirectoryPartition,
58    /// cannot unpack keys using the root of a directory partition
59    CannotUnpackDirectoryPartition,
60    /// cannot get range for the root of a directory partition
61    CannotRangeDirectoryPartition,
62    IoError(io::Error),
63    FdbError(error::FdbError),
64    HcaError(HcaError),
65    PackError(PackError),
66    Other(String),
67}
68
69impl From<error::FdbError> for DirectoryError {
70    fn from(err: error::FdbError) -> Self {
71        DirectoryError::FdbError(err)
72    }
73}
74
75impl From<HcaError> for DirectoryError {
76    fn from(err: HcaError) -> Self {
77        DirectoryError::HcaError(err)
78    }
79}
80
81impl From<PackError> for DirectoryError {
82    fn from(err: PackError) -> Self {
83        DirectoryError::PackError(err)
84    }
85}