A MsgId newtype

This more strongly types the ubiquitous message id type by no longer
making it an integer.  It keeps the actual ID opaque.  Only for the
generic job API the number keeps being used.  Some locations also need
to create it from an integer and call MsgId::new().
This commit is contained in:
Floris Bruynooghe
2019-10-20 23:47:48 +02:00
committed by holger krekel
parent c6adbe939d
commit c8d296ea0e
18 changed files with 806 additions and 465 deletions

View File

@@ -32,6 +32,8 @@ pub enum Error {
FromUtf8(std::string::FromUtf8Error),
#[fail(display = "{}", _0)]
BlobError(#[cause] crate::blob::BlobError),
#[fail(display = "Invalid Message ID.")]
InvalidMsgId,
}
pub type Result<T> = std::result::Result<T, Error>;
@@ -102,6 +104,12 @@ impl From<crate::blob::BlobError> for Error {
}
}
impl From<crate::message::InvalidMsgId> for Error {
fn from(_err: crate::message::InvalidMsgId) -> Error {
Error::InvalidMsgId
}
}
#[macro_export]
macro_rules! bail {
($e:expr) => {