1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use std::{fmt, error::Error};
use crate::{ID, Context, ExclusivelyContextual, InContext, Atomic, AcesError, sat};
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[repr(transparent)]
pub struct NodeID(pub(crate) ID);
impl NodeID {
#[inline]
pub const fn get(self) -> ID {
self.0
}
}
impl From<ID> for NodeID {
fn from(id: ID) -> Self {
NodeID(id)
}
}
impl From<NodeID> for ID {
fn from(id: NodeID) -> Self {
id.0
}
}
impl ExclusivelyContextual for NodeID {
fn format_locked(&self, ctx: &Context) -> Result<String, Box<dyn Error>> {
let name = ctx.get_node_name(*self).ok_or(AcesError::NodeMissingForID)?;
Ok(name.to_owned())
}
}
impl Atomic for NodeID {
fn into_node_id(this: InContext<Self>) -> Option<NodeID> {
Some(*this.get_thing())
}
fn into_sat_literal(self, negated: bool) -> sat::Literal {
sat::Literal::from_atom_id(self.get(), negated)
}
}
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum Face {
Tx,
Rx,
}
impl std::ops::Not for Face {
type Output = Face;
fn not(self) -> Self::Output {
match self {
Face::Tx => Face::Rx,
Face::Rx => Face::Tx,
}
}
}
impl fmt::Display for Face {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Face::Tx => write!(f, ">"),
Face::Rx => write!(f, "<"),
}
}
}