dusk_safe/
error.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4//
5// Copyright (c) DUSK NETWORK. All rights reserved.
6
7/// Defines all possible error variants for the SAFE library.
8#[derive(Debug, Clone, Copy, PartialEq)]
9pub enum Error {
10    /// This error occurs when the expected IO-pattern sequence wasn't followed
11    /// during the usage of the sponge algorithm.
12    IOPatternViolation,
13
14    /// This error occurs when the provided IO-pattern is not valid.
15    /// This means that one of the following is not met:
16    /// - It doesn't start with a call to squeeze
17    /// - It doesn't end with a call to absorb
18    /// - Every call to absorb or squeeze has a length between 0 < len < 2^31
19    InvalidIOPattern,
20
21    /// This error occurs when the input elements provided to the
22    /// [`Sponge::absorb`] are less than the amount that should be absorbed.
23    TooFewInputElements,
24
25    /// This error indicates a failure during the encryption process.
26    EncryptionFailed,
27
28    /// This error indicates a failure during the decryption process.
29    DecryptionFailed,
30}