mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
xous: definitions: add memory() call to Result
This is used to get attached Memory from a Result, if any. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
8115c2e7cf
commit
39c9ef30b7
1 changed files with 10 additions and 5 deletions
|
|
@ -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<MemoryRange> {
|
||||
match self {
|
||||
|
|
|
|||
Loading…
Reference in a new issue