Reply

Struct Reply 

Source
pub struct Reply { /* private fields */ }
Expand description

What a flavor said during one crate::shard::ShardLogic::observe.

Implementations§

Source§

impl Reply

Source

pub fn say(&mut self, to: ConnectionId, text: &str)

Tell a connection something, in the server’s own name.

Source

pub fn refuse(&mut self, to: ConnectionId, reason: &str)

Refuse, visibly.

The point is that the client learns something happened. A flavor that stays silent leaves the user pressing a button that does nothing, which is the state this type exists to end.

Source

pub fn relay(&mut self, from: ConnectionId, to: Audience, text: &str)

Deliver text to to, attributed to from.

The answer to a crate::shard::VoiceEvent::Said a flavor is willing to carry out, and the one place a client’s own words reach other clients. The flavor stays in charge of the audience: relaying somewhere other than where the message was aimed is a rewrite, not a workaround.

Two rules the shard applies when it expands this, both borrowed from elsewhere in the model rather than invented here:

  • The sender never receives its own message.
  • A recipient that cannot see from is skipped. That is the audio coupling rule - a receiver must see the sender - applied to text, and naming a session the recipient does not hold would break the view invariants anyway. Use Reply::announce for something everyone should read whoever said it.
Source

pub fn announce(&mut self, to: Audience, text: &str)

Deliver text to to, in the server’s own name.

Reply::say addressed to a group: no actor, so no recipient is skipped for not seeing one.

Source

pub fn switch(&mut self, connection: ConnectionId, to: ShardId)

Hand a connection to another shard.

Not a disconnect followed by a connect: the source hands over the view the client still holds and the destination plans one transition from it. What the flavor said in the same breath is delivered first, so a farewell reaches the socket before the move is asked for.

Source

pub fn is_empty(&self) -> bool

Source

pub fn drain(&mut self) -> BTreeMap<ConnectionId, Vec<Word>>

What was said, per connection, in the order it was said. Empties the reply.

Source

pub fn drain_spoken(&mut self) -> Vec<Spoken>

What was addressed to an audience, in the order it was said. Empties the reply.

Source

pub fn drain_effects(&mut self) -> Vec<Effect>

What the flavor asked the runtime for, in the order it asked. Empties the reply.

Trait Implementations§

Source§

impl Debug for Reply

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Reply

Source§

fn default() -> Reply

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Reply

§

impl RefUnwindSafe for Reply

§

impl Send for Reply

§

impl Sync for Reply

§

impl Unpin for Reply

§

impl UnwindSafe for Reply

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.