From 3c34517632da5c0358dda3331626701c396f729f Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 2 Apr 2021 02:44:24 +0800 Subject: [PATCH] add a convenience method for creating messages reduces the cognitive load of writing library functions --- xous-rs/src/definitions.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xous-rs/src/definitions.rs b/xous-rs/src/definitions.rs index 5e3378f4b..b6f53448c 100644 --- a/xous-rs/src/definitions.rs +++ b/xous-rs/src/definitions.rs @@ -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 {