mod capnp;
mod jeff;
#[cfg(test)]
mod test;
pub mod reader;
pub mod types;
pub use jeff::Jeff;
#[doc(hidden)]
pub use capnp::jeff_capnp;
use derive_more::derive::{Display, Error, From};
pub const SCHEMA_VERSION: semver::Version = semver::Version::new(
capnp::jeff_capnp::SCHEMA_VERSION_MAJOR as u64,
capnp::jeff_capnp::SCHEMA_VERSION_MINOR as u64,
capnp::jeff_capnp::SCHEMA_VERSION_PATCH as u64,
);
#[derive(Debug, Display, From, Error)]
#[non_exhaustive]
pub enum JeffError {
#[display("Invalid jeff file: {_0}")]
#[from]
InvalidFile(::capnp::Error),
#[display("Schema version {v} is too old. Expected {min}")]
VersionTooOld {
v: semver::Version,
min: String,
},
#[display("Schema version {v} is too new. Expected {max}")]
VersionTooNew {
v: semver::Version,
max: String,
},
#[from]
ReadError(reader::ReadError),
}
#[derive(Clone, Copy, Debug, Display, PartialEq, PartialOrd, Eq, Ord, Hash, Default)]
pub enum Direction {
#[default]
Incoming = 0,
Outgoing = 1,
}
impl Direction {
pub const BOTH: [Direction; 2] = [Direction::Incoming, Direction::Outgoing];
#[inline(always)]
pub fn reverse(self) -> Direction {
match self {
Direction::Incoming => Direction::Outgoing,
Direction::Outgoing => Direction::Incoming,
}
}
}