add a convenience method for creating messages

reduces the cognitive load of writing library functions
This commit is contained in:
bunnie 2021-04-02 02:44:24 +08:00
parent fe2a464dd2
commit 3c34517632

View file

@ -368,6 +368,18 @@ pub enum Message {
}
impl Message {
pub fn new_scalar(id: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> crate::Message {
Message::Scalar(crate::ScalarMessage {
id, arg1, arg2, arg3, arg4
})
}
pub fn new_blocking_scalar(id: usize, arg1: usize, arg2: usize, arg3: usize, arg4: usize) -> crate::Message {
Message::BlockingScalar(crate::ScalarMessage {
id, arg1, arg2, arg3, arg4
})
}
/// Determine whether the specified Message will block
pub fn is_blocking(&self) -> bool {
match *self {