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>
impl<'a> ShardBuilder<'a>
pub fn new( ids: &'a SharedIds, shard: ShardId, connections: &'a [ConnectionId], ) -> ShardBuilder<'a>
Sourcepub fn connections(&self) -> &[ConnectionId]
pub fn connections(&self) -> &[ConnectionId]
The connections attached to this shard, for overlay loops.
Sourcepub fn root(&mut self, name: &str) -> ChannelRef
pub fn root(&mut self, name: &str) -> ChannelRef
The root of this shard’s tree: what every observer sees.
Sourcepub fn channel(
&mut self,
parent: ChannelRef,
key: ChannelKey,
name: &str,
narrow: Narrow,
) -> ChannelRef
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.
Sourcepub fn user(
&mut self,
channel: ChannelRef,
who: Occupant,
name: &str,
narrow: Narrow,
) -> UserRef
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.
pub fn channel_position(&mut self, channel: ChannelRef, position: i32)
pub fn channel_can_enter(&mut self, channel: ChannelRef, yes: bool)
Sourcepub fn channel_can_text(&mut self, channel: ChannelRef, yes: bool)
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.
Sourcepub fn channel_link(&mut self, a: ChannelRef, b: ChannelRef)
pub fn channel_link(&mut self, a: ChannelRef, b: ChannelRef)
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.
pub fn user_flags(&mut self, user: UserRef, flags: UserFlags)
Sourcepub fn private(
&mut self,
connection: ConnectionId,
build: impl FnOnce(&mut PrivateBuilder<'_>),
)
pub fn private( &mut self, connection: ConnectionId, build: impl FnOnce(&mut PrivateBuilder<'_>), )
Elements visible to this connection only.
Sourcepub fn audio_domain(&mut self, domain: DomainId, members: &[ConnectionId])
pub fn audio_domain(&mut self, domain: DomainId, members: &[ConnectionId])
A symmetric group: everyone in the domain hears everyone else.
Sourcepub fn audio_listen(&mut self, listener: ConnectionId, domain: DomainId)
pub fn audio_listen(&mut self, listener: ConnectionId, domain: DomainId)
A one-way exception: hears the domain, is not heard by it.
Sourcepub fn audio_edge(&mut self, sender: ConnectionId, receiver: ConnectionId)
pub fn audio_edge(&mut self, sender: ConnectionId, receiver: ConnectionId)
A single directed edge, for full generality.
Sourcepub fn finish(
self,
observations: &BTreeMap<ConnectionId, ScopeSet>,
) -> Result<Rendered, BuildError>
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.