1mod capnp;
5mod jeff;
6
7#[cfg(test)]
8mod test;
9
10pub mod reader;
11pub mod types;
12pub use jeff::Jeff;
13
14#[doc(hidden)]
19pub use capnp::jeff_capnp;
20
21use derive_more::derive::{Display, Error, From};
22
23pub const SCHEMA_VERSION: semver::Version = semver::Version::new(
25 capnp::jeff_capnp::SCHEMA_VERSION_MAJOR as u64,
26 capnp::jeff_capnp::SCHEMA_VERSION_MINOR as u64,
27 capnp::jeff_capnp::SCHEMA_VERSION_PATCH as u64,
28);
29
30#[derive(Debug, Display, From, Error)]
32#[non_exhaustive]
33pub enum JeffError {
34 #[display("Invalid jeff file: {_0}")]
36 #[from]
37 InvalidFile(::capnp::Error),
38 #[display("Schema version {v} is too old. Expected {min}")]
40 VersionTooOld {
41 v: semver::Version,
43 min: String,
45 },
46 #[display("Schema version {v} is too new. Expected {max}")]
48 VersionTooNew {
49 v: semver::Version,
51 max: String,
53 },
54 #[from]
56 ReadError(reader::ReadError),
57}
58
59#[derive(Clone, Copy, Debug, Display, PartialEq, PartialOrd, Eq, Ord, Hash, Default)]
61pub enum Direction {
62 #[default]
64 Incoming = 0,
65 Outgoing = 1,
67}
68
69impl Direction {
70 pub const BOTH: [Direction; 2] = [Direction::Incoming, Direction::Outgoing];
72
73 #[inline(always)]
75 pub fn reverse(self) -> Direction {
76 match self {
77 Direction::Incoming => Direction::Outgoing,
78 Direction::Outgoing => Direction::Incoming,
79 }
80 }
81}