1mod attestation;
4mod detached_timestamp;
5mod digest;
6pub mod opcode;
7mod timestamp;
8
9pub use attestation::{
10 Attestation, AttestationTag, BitcoinAttestation, EASAttestation, EASTimestamped,
11 PendingAttestation, RawAttestation,
12};
13pub use detached_timestamp::DetachedTimestamp;
14pub use digest::DigestHeader;
15pub use timestamp::{Step, Timestamp, builder::TimestampBuilder};
16
17#[derive(Debug)]
19pub struct FinalizationError;
20
21impl core::fmt::Display for FinalizationError {
22 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
23 write!(f, "failed to finalize timestamp due to conflicting inputs")
24 }
25}
26
27impl std::error::Error for FinalizationError {}
28
29pub trait MayHaveInput {
31 fn input(&self) -> Option<&[u8]>;
33}
34
35trait ToInput {
36 fn to_input(&self) -> Option<&[u8]>;
37}
38impl<T: MayHaveInput> ToInput for T {
39 fn to_input(&self) -> Option<&[u8]> {
40 self.input()
41 }
42}
43impl ToInput for [u8] {
44 fn to_input(&self) -> Option<&[u8]> {
45 Some(self)
46 }
47}
48impl ToInput for Vec<u8> {
49 fn to_input(&self) -> Option<&[u8]> {
50 Some(self)
51 }
52}
53
54#[allow(private_bounds)]
56pub trait ConsistentWith<T: ToInput + ?Sized>: MayHaveInput {
57 fn is_consistent_with(&self, other: &T) -> bool {
61 self.input()
62 .zip(other.to_input())
63 .is_none_or(|(a, b)| a == b)
64 }
65
66 fn is_consistent_with_strict(&self, other: &T) -> bool {
70 self.input() == other.to_input()
71 }
72}
73
74impl<T: MayHaveInput, U: ToInput + ?Sized> ConsistentWith<U> for T {}