ShardCommand

Enum ShardCommand 

Source
pub enum ShardCommand {
    Attach {
        connection: ConnectionId,
        queue: Arc<OutboundQueue>,
        cursor: Arc<AtomicU64>,
        held: ShardView,
        ready: Option<Sender<()>>,
    },
    Detach {
        connection: ConnectionId,
        reason: String,
        handover: Option<Handover>,
    },
    Drained(ConnectionId),
    Requested {
        connection: ConnectionId,
        channel: ChannelId,
    },
    RequestedSelfState {
        connection: ConnectionId,
        self_mute: Option<bool>,
        self_deaf: Option<bool>,
    },
    QueriedPermissions {
        connection: ConnectionId,
        channel: ChannelId,
    },
    QueriedUserStats {
        connection: ConnectionId,
        target: SessionId,
    },
    InvokedAction {
        connection: ConnectionId,
        action: String,
        session: Option<SessionId>,
        channel: Option<ChannelId>,
    },
    Said {
        connection: ConnectionId,
        to: TextTarget,
        message: String,
    },
}
Expand description

A command for a shard’s task.

Variants§

§

Attach

Fields

§connection: ConnectionId
§queue: Arc<OutboundQueue>

Shared with the connection’s writer task, which is what lets a migration hand the same queue to the next shard.

§cursor: Arc<AtomicU64>

The cell the voice plane gates on. Owned by the runtime rather than by the shard, so a migration does not have to republish it.

§held: ShardView

What the client already holds. Empty for a fresh connection, and the previous shard’s composed view for a migration.

§ready: Option<Sender<()>>

Fired once the connection’s first transition has been accepted, so the handshake knows when it may send ServerSync.

§

Detach

Fields

§connection: ConnectionId
§reason: String
§handover: Option<Handover>

Set when the connection is moving to another shard rather than leaving. It receives the view the client still holds, and the teardown is skipped: the destination plans one transition from that view instead.

§

Drained(ConnectionId)

A connection’s queue drained: retry for that one alone, in O(1).

§

Requested

The client asked to enter a channel. Resolved against this connection’s own view and reported to the flavor, or refused.

Fields

§connection: ConnectionId
§channel: ChannelId
§

RequestedSelfState

The client asked to mute or deafen itself. Reported to the flavor, which alone decides what the view ends up saying.

Fields

§connection: ConnectionId
§self_mute: Option<bool>
§self_deaf: Option<bool>
§

QueriedPermissions

The client asked what it may do in a channel. Answered from the render, for that connection alone.

Fields

§connection: ConnectionId
§channel: ChannelId
§

QueriedUserStats

The client asked what the server publishes about a user. Answered only for a user this connection can actually see.

Fields

§connection: ConnectionId
§target: SessionId
§

InvokedAction

The client invoked a context action. Validated against what this connection was offered and what it can see, then reported to the flavor.

The wire identifier travels as it arrived: the gateway does not know which actions exist, and reading it back is part of the validation.

Fields

§connection: ConnectionId
§action: String
§

Said

The client sent a text message. Resolved against this connection’s own view and reported to the flavor, or refused.

The gateway has already checked the shape, the length and the rate; what is left is the only question it cannot answer, which is whether this connection may name that target at all.

Fields

§connection: ConnectionId
§message: String

Implementations§

Source§

impl ShardCommand

Source

pub fn attach( connection: ConnectionId, queue: Arc<OutboundQueue>, ) -> ShardCommand

Attach a connection that holds nothing yet: a fresh arrival.

Source

pub fn detach( connection: ConnectionId, reason: impl Into<String>, ) -> ShardCommand

Detach a connection that is leaving for good.

Trait Implementations§

Source§

impl Debug for ShardCommand

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.