diff --git a/src/runtime2/inbox.rs b/src/runtime2/inbox.rs index 91db3a3711b6eecb1bfb71020328bbc54fad2f25..26983cc5a008de576fe4860a3c1e1b0fbf189777 100644 --- a/src/runtime2/inbox.rs +++ b/src/runtime2/inbox.rs @@ -127,6 +127,19 @@ pub(crate) enum Message { Control(ControlMessage), } +impl Message { + /// If the message is sent through a particular channel, then this function + /// returns the port through which the message was sent. + pub(crate) fn source_port(&self) -> Option { + // Currently only data messages have a source port + if let Message::Data(message) = self { + return Some(message.data_header.sending_port); + } else { + return None; + } + } +} + /// The public inbox of a connector. The thread running the connector that owns /// this inbox may retrieved from it. Non-owning threads may only put new /// messages inside of it.