pub struct ChannelStore { /* private fields */ }Expand description
Heterogeneous typed channel map.
Stores type-erased Channel values indexed by TypeId.
Uses a two-level lookup: TypeId → ChannelId (usize) → Channel.
§Example
use pe_core::channel::{LastValue, Appender};
use pe_core::channel_store::ChannelStore;
let mut store = ChannelStore::new();
store.insert::<LastValue<String>>(LastValue::new("hello".into()));
store.insert::<Appender<i32>>(Appender::new());
let val = store.get::<LastValue<String>>().unwrap();
assert_eq!(val.get(), "hello");Implementations§
Source§impl ChannelStore
impl ChannelStore
Sourcepub fn insert<T: Channel + 'static>(&mut self, channel: T)
pub fn insert<T: Channel + 'static>(&mut self, channel: T)
Insert a channel by its concrete type. Overwrites any existing channel of the same type.
Sourcepub fn get<T: Channel + 'static>(&self) -> Option<&T>
pub fn get<T: Channel + 'static>(&self) -> Option<&T>
Get an immutable reference to a channel by its concrete type.
Sourcepub fn get_mut<T: Channel + 'static>(&mut self) -> Option<&mut T>
pub fn get_mut<T: Channel + 'static>(&mut self) -> Option<&mut T>
Get a mutable reference to a channel by its concrete type.
Sourcepub fn get_by_id(&self, id: ChannelId) -> Option<&dyn Channel>
pub fn get_by_id(&self, id: ChannelId) -> Option<&dyn Channel>
Get a channel by ChannelId (fast path, no hashing).
Sourcepub fn get_by_id_mut(&mut self, id: ChannelId) -> Option<&mut dyn Channel>
pub fn get_by_id_mut(&mut self, id: ChannelId) -> Option<&mut dyn Channel>
Get a mutable channel by ChannelId (fast path, no hashing).
Sourcepub fn id_of<T: 'static>(&self) -> Option<ChannelId>
pub fn id_of<T: 'static>(&self) -> Option<ChannelId>
Look up the ChannelId for a type. Use this once, then use
get_by_id for repeated fast access.
Sourcepub fn clear_ephemeral(&mut self)
pub fn clear_ephemeral(&mut self)
Clear all ephemeral and topic channels (called between supersteps).
§REVIEW(002): Selective clearing via is_ephemeral()
Only calls clear() on channels that opt in via is_ephemeral() == true.
Previously called clear() on ALL channels, relying on persistent channels
having no-op impls. The new approach is explicit and won’t break if a future
Channel type has a meaningful clear() that shouldn’t run between supersteps.
Sourcepub fn snapshot(&self) -> ChannelStore
pub fn snapshot(&self) -> ChannelStore
Create a snapshot (deep clone) for snapshot isolation during parallel execution.
Each channel is cloned via clone_box().