1use std::{fmt, ops::Range};
4
5use crate::VarNo;
6
7#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
9pub struct OutOfMemory;
10
11impl fmt::Display for OutOfMemory {
12 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13 f.write_str("decision diagram operation ran out of memory")
14 }
15}
16impl std::error::Error for OutOfMemory {}
17
18impl From<OutOfMemory> for std::io::Error {
19 fn from(_: OutOfMemory) -> Self {
20 std::io::ErrorKind::OutOfMemory.into()
21 }
22}
23
24#[derive(Clone, PartialEq, Eq, Hash, Debug)]
26pub struct DuplicateVarName {
27 pub name: String,
29 pub present_var: VarNo,
31 pub added_vars: Range<VarNo>,
34}
35
36impl fmt::Display for DuplicateVarName {
37 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38 write!(
39 f,
40 "the variable name '{}' is already in use for variable number {}",
41 self.name, self.present_var
42 )
43 }
44}