Shard

Struct Shard 

Source
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>

Source

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.

Source

pub fn with_ids(id: ShardId, logic: L, ids: SharedIds) -> Shard<L>

A shard drawing its identifiers from a runtime-wide allocator.

Source

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.

Source

pub fn id(&self) -> ShardId

Source

pub fn version(&self) -> u64

Source

pub fn view(&self) -> &ShardView

Source

pub fn connection( &self, connection: ConnectionId, ) -> Option<&AttachedConnection>

Source

pub fn connections(&self) -> impl Iterator<Item = &AttachedConnection>

The attached connections, in id order.

Source

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.

Source

pub fn routing(&self) -> Receiver<Arc<AudioRouting>>

A reader of the audio routing table, for the voice plane.

Source

pub fn handle(&mut self, command: ShardCommand)

Apply a command. Never renders: the caller reconciles afterwards.

Source

pub fn reconcile(&mut self) -> ReconcileReport

Render, plan, journal, publish routing, and push to every connection.

Auto Trait Implementations§

§

impl<L> Freeze for Shard<L>
where L: Freeze,

§

impl<L> !RefUnwindSafe for Shard<L>

§

impl<L> Send for Shard<L>

§

impl<L> Sync for Shard<L>
where L: Sync,

§

impl<L> Unpin for Shard<L>
where L: Unpin,

§

impl<L> !UnwindSafe for Shard<L>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.