ShardBuilder

Struct ShardBuilder 

Source
pub struct ShardBuilder<'a> { /* private fields */ }
Expand description

The uniform constructor handed to crate::shard::ShardLogic::render.

Every method that can fail records the refusal and carries on rather than returning a Result the flavor would have to thread through its whole render. The refusal is not lost: ShardBuilder::finish returns it and the render is discarded whole. Handles returned after a refusal are meaningless, which is harmless precisely because nothing built on them will be published.

Implementations§

Source§

impl<'a> ShardBuilder<'a>

Source

pub fn new( ids: &'a SharedIds, shard: ShardId, connections: &'a [ConnectionId], ) -> ShardBuilder<'a>

Source

pub fn connections(&self) -> &[ConnectionId]

The connections attached to this shard, for overlay loops.

Source

pub fn root(&mut self, name: &str) -> ChannelRef

The root of this shard’s tree: what every observer sees.

Source

pub fn channel( &mut self, parent: ChannelRef, key: ChannelKey, name: &str, narrow: Narrow, ) -> ChannelRef

A child channel. narrow can only extend the parent’s scope.

Source

pub fn user( &mut self, channel: ChannelRef, who: Occupant, name: &str, narrow: Narrow, ) -> UserRef

A user in a channel. narrow can only extend the channel’s scope.

Source

pub fn channel_position(&mut self, channel: ChannelRef, position: i32)

Source

pub fn channel_can_enter(&mut self, channel: ChannelRef, yes: bool)

Source

pub fn channel_can_text(&mut self, channel: ChannelRef, yes: bool)

Whether text may be addressed to this channel.

Declaring it false greys the client’s chat box out for that channel instead of letting the user type into something that answers PermissionDenied, and the shard refuses a message aimed there anyway.

Link two channels, symmetrically.

The only structural check in the model, because a link is the one relation that does not follow the parent hierarchy: a link pointing at a channel the viewer may not see has no meaning.

Source

pub fn user_flags(&mut self, user: UserRef, flags: UserFlags)

Source

pub fn private( &mut self, connection: ConnectionId, build: impl FnOnce(&mut PrivateBuilder<'_>), )

Elements visible to this connection only.

Source

pub fn audio_domain(&mut self, domain: DomainId, members: &[ConnectionId])

A symmetric group: everyone in the domain hears everyone else.

Source

pub fn audio_listen(&mut self, listener: ConnectionId, domain: DomainId)

A one-way exception: hears the domain, is not heard by it.

Source

pub fn audio_edge(&mut self, sender: ConnectionId, receiver: ConnectionId)

A single directed edge, for full generality.

Source

pub fn finish( self, observations: &BTreeMap<ConnectionId, ScopeSet>, ) -> Result<Rendered, BuildError>

Close the render, checking the three non-structural properties.

observations is what each attached connection observes of the shared view; it is needed for the overlay and audio checks, both of which are statements about who can see what.

§Errors

The first BuildError recorded during the render, or the first one the closing checks find.

Auto Trait Implementations§

§

impl<'a> Freeze for ShardBuilder<'a>

§

impl<'a> RefUnwindSafe for ShardBuilder<'a>

§

impl<'a> Send for ShardBuilder<'a>

§

impl<'a> Sync for ShardBuilder<'a>

§

impl<'a> Unpin for ShardBuilder<'a>

§

impl<'a> UnwindSafe for ShardBuilder<'a>

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.