boolean_function/
boolean_function_error.rs1use thiserror::Error;
4
5#[derive(Error, Debug, PartialEq, Clone)]
7pub enum BooleanFunctionError {
8 #[error("Hex truth table length must be a power of 2")]
10 WrongStringHexTruthTableLength,
11 #[error("Error parsing string hex number")]
13 StringHexParseError,
14 #[error("Too big variable count, must be <= {0}")]
17 TooBigVariableCount(usize),
18 #[error("Unexpected error, this shouldn't happen. Please report this issue to the crate maintainer.")]
20 UnexpectedError,
21 #[error("Too big derivative direction, must be <= {0}")]
23 TooBigDerivativeDirection(u32),
24 #[error("Invalid number of Walsh values {0}, should be 2^n, n >= 2")]
26 InvalidWalshValuesCount(usize),
27 #[error("Truth table is too big for variables count")]
29 TooBigTruthTableForVarCount,
30 #[error("This Boolean function is already balanced")]
32 AlreadyBalanced,
33 #[error("Error parsing ANF string, should be in the form \"x0*x2*x3 + x2*x3 + x1 + 1\"")]
35 ErrorParsingAnfString,
36 #[error("There are {0} variables in this ANF form, x{1} factor shouldn't appear")]
38 AnfFormNVariableTooBigFactor(usize, usize),
39}
40
41pub(crate) const XOR_DIFFERENT_VAR_COUNT_PANIC_MSG: &'static str =
42 "XOR operation requires the same number of variables in both functions";
43
44pub(crate) const AND_DIFFERENT_VAR_COUNT_PANIC_MSG: &'static str =
45 "AND operation requires the same number of variables in both functions";
46
47#[cfg(not(feature = "unsafe_disable_safety_checks"))]
48pub(crate) const TRUTH_TABLE_TOO_BIG_VAR_COUNT_PANIC_MSG: &'static str =
49 "Truth table is too big for variables count";
50#[cfg(not(feature = "unsafe_disable_safety_checks"))]
51pub(crate) const POLYNOMIAL_ANF_TOO_BIG_VAR_COUNT_PANIC_MSG: &'static str =
52 "Polynomial ANF is too big for variables count";