diff --git a/xous-rs/src/definitions.rs b/xous-rs/src/definitions.rs index f780aec06..51acb8d0d 100644 --- a/xous-rs/src/definitions.rs +++ b/xous-rs/src/definitions.rs @@ -306,6 +306,15 @@ impl Message { } } + pub fn memory(&self) -> Option<&MemoryRange> { + match self { + Message::MutableBorrow(mem) | Message::Borrow(mem) | Message::Move(mem) => { + Some(&mem.buf) + } + Message::BlockingScalar(_) | Message::Scalar(_) => None, + } + } + pub fn message_type(&self) -> usize { match *self { Message::MutableBorrow(_) => 1, @@ -369,10 +378,7 @@ impl MemoryRange { addr != 0, "tried to construct a memory range with a null pointer" ); - assert!( - size != 0, - "tried to construct a zero-length memory range" - ); + assert!(size != 0, "tried to construct a zero-length memory range"); Ok(MemoryRange { addr: MemoryAddress::new(addr).ok_or(Error::BadAddress)?, size: MemorySize::new(size).ok_or(Error::BadAddress)?, @@ -580,7 +586,6 @@ impl Result { } } - /// If the Result has memory attached to it, return the memory pub fn memory(&self) -> Option { match self {