pub struct Shard<L: ShardLogic> { /* private fields */ }Expand description
A shard: unit of ownership, scheduling, rendering, id allocation and audio routing.
Implementations§
Source§impl<L: ShardLogic> Shard<L>
impl<L: ShardLogic> Shard<L>
Sourcepub fn new(id: ShardId, logic: L) -> Shard<L>
pub fn new(id: ShardId, logic: L) -> Shard<L>
A shard with an allocator of its own.
Correct for a runtime that will only ever hold one shard. As soon as a
connection can move, every shard must share one allocator: see
Shard::with_ids and SharedIds.
Sourcepub fn with_ids(id: ShardId, logic: L, ids: SharedIds) -> Shard<L>
pub fn with_ids(id: ShardId, logic: L, ids: SharedIds) -> Shard<L>
A shard drawing its identifiers from a runtime-wide allocator.
Sourcepub fn route_effects(&mut self, effects: Effects)
pub fn route_effects(&mut self, effects: Effects)
Wire this shard’s effects to a runtime.
Kept out of the constructors on purpose: a shard is complete without one, and only the code that owns several shards can honour a move between two of them.
pub fn id(&self) -> ShardId
pub fn version(&self) -> u64
pub fn view(&self) -> &ShardView
pub fn connection( &self, connection: ConnectionId, ) -> Option<&AttachedConnection>
Sourcepub fn connections(&self) -> impl Iterator<Item = &AttachedConnection>
pub fn connections(&self) -> impl Iterator<Item = &AttachedConnection>
The attached connections, in id order.
Sourcepub fn logic_mut(&mut self) -> &mut L
pub fn logic_mut(&mut self) -> &mut L
The flavor’s own state.
The shard owns the logic outright, so this is how a composition binary or a test reaches the business model it handed over. A flavor driven by its own channel does not need it.
Sourcepub fn routing(&self) -> Receiver<Arc<AudioRouting>>
pub fn routing(&self) -> Receiver<Arc<AudioRouting>>
A reader of the audio routing table, for the voice plane.
Sourcepub fn handle(&mut self, command: ShardCommand)
pub fn handle(&mut self, command: ShardCommand)
Apply a command. Never renders: the caller reconciles afterwards.
Sourcepub fn reconcile(&mut self) -> ReconcileReport
pub fn reconcile(&mut self) -> ReconcileReport
Render, plan, journal, publish routing, and push to every connection.