mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
xous: messages: add set_id() to set Message ID
Allow setting a message's ID by adding a `set_id(&mut self, ...)` function. This can be used when regifting a message. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
ddd7c6715a
commit
04e91b8c44
1 changed files with 13 additions and 5 deletions
|
|
@ -9,7 +9,7 @@ pub use sender::Sender as MessageSender;
|
||||||
pub mod id;
|
pub mod id;
|
||||||
pub use id::Id as MessageId;
|
pub use id::Id as MessageId;
|
||||||
|
|
||||||
use super::{MemoryRange, MemoryAddress, MemorySize};
|
use super::{MemoryAddress, MemoryRange, MemorySize};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
|
@ -246,10 +246,18 @@ impl Message {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the ID of this message
|
/// Return the ID of this message
|
||||||
pub fn id(&self) -> usize {
|
pub fn id(&self) -> MessageId {
|
||||||
match &self {
|
match self {
|
||||||
&Message::MutableBorrow(mem) | &Message::Borrow(mem) | &Message::Move(mem) => mem.id,
|
Message::MutableBorrow(mem) | Message::Borrow(mem) | Message::Move(mem) => mem.id,
|
||||||
&Message::Scalar(s) | &Message::BlockingScalar(s) => s.id,
|
Message::Scalar(s) | Message::BlockingScalar(s) => s.id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the ID or opcode of this message
|
||||||
|
pub fn set_id(&mut self, id: MessageId) {
|
||||||
|
match self {
|
||||||
|
Message::MutableBorrow(mem) | Message::Borrow(mem) | Message::Move(mem) => mem.id = id,
|
||||||
|
Message::Scalar(s) | Message::BlockingScalar(s) => s.id = id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue