From a1b16a74cbba96272d93890e0b54b1be15e71487 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Wed, 19 May 2021 14:14:21 +0800 Subject: [PATCH] xous: definitions: add default constructors for Message Enable creating new_lend() and new_scalar() messages. Signed-off-by: Sean Cross --- xous-rs/src/definitions.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/xous-rs/src/definitions.rs b/xous-rs/src/definitions.rs index a6022162d..ca66a55f1 100644 --- a/xous-rs/src/definitions.rs +++ b/xous-rs/src/definitions.rs @@ -408,6 +408,34 @@ impl Message { }) } + pub fn new_lend( + id: usize, + buf: MemoryRange, + offset: Option, + valid: Option, + ) -> crate::Message { + Message::Borrow(crate::MemoryMessage { + id, + buf, + offset, + valid, + }) + } + + pub fn new_lend_mut( + id: usize, + buf: MemoryRange, + offset: Option, + valid: Option, + ) -> crate::Message { + Message::MutableBorrow(crate::MemoryMessage { + id, + buf, + offset, + valid, + }) + } + /// Determine whether the specified Message will block pub fn is_blocking(&self) -> bool { match *self {