pub enum SessionMessage {
Attach {
peer: InstanceId,
session_id: SessionId,
as_role: ControlRole,
},
Detach {
peer: InstanceId,
session_id: SessionId,
},
YieldControl {
peer: InstanceId,
session_id: SessionId,
},
AcquireControl {
peer: InstanceId,
session_id: SessionId,
},
TriggerStaging {
session_id: SessionId,
},
HoldBlocks {
session_id: SessionId,
hold_hashes: Vec<SequenceHash>,
},
ReleaseBlocks {
session_id: SessionId,
release_hashes: Vec<SequenceHash>,
},
BlocksPulled {
session_id: SessionId,
pulled_hashes: Vec<SequenceHash>,
},
StateResponse {
session_id: SessionId,
state: SessionStateSnapshot,
},
BlocksStaged {
session_id: SessionId,
staged_blocks: Vec<BlockInfo>,
remaining: usize,
layer_range: Option<Range<usize>>,
},
Close {
session_id: SessionId,
},
Error {
session_id: SessionId,
message: String,
},
}Expand description
Unified session message protocol. Unified session message protocol.
Unified, bidirectional protocol that supports dynamic control transfer.
§Protocol Overview
- Connection:
Attach/Detachfor peer management - Control Transfer:
YieldControl/AcquireControlfor bidirectional role changes - Block Operations: Commands from controller to controllee
- State Sync: Responses from controllee to controller
- Lifecycle:
Close/Errorfor termination
Variants§
Attach
Attach to a session as a specific role.
Sent by a peer to establish the session relationship.
Fields
peer: InstanceIdThe instance ID of the attaching peer.
as_role: ControlRoleThe role this peer will assume (typically Controllee or Controller).
Detach
Detach from a session.
Graceful disconnection. The session may continue if other peers are attached.
Fields
peer: InstanceIdThe instance ID of the detaching peer.
YieldControl
Yield control to peer.
The sender transitions from Controller to Neutral.
The receiver (if in Controllee) can then AcquireControl or remain passive.
AcquireControl
Acquire control from peer.
The sender attempts to become Controller.
Valid when sender is Neutral or Controllee and peer is Neutral.
Fields
peer: InstanceIdThe instance ID of the peer acquiring control.
TriggerStaging
Trigger staging of blocks (e.g., G3→G2).
HoldBlocks
Request that specific blocks be held (kept alive).
Fields
hold_hashes: Vec<SequenceHash>Sequence hashes of blocks to hold.
ReleaseBlocks
Release specific blocks (they can now be evicted).
Fields
release_hashes: Vec<SequenceHash>Sequence hashes of blocks to release.
BlocksPulled
Notify that blocks have been pulled via RDMA.
The controllee can release these blocks from its hold.
Fields
pulled_hashes: Vec<SequenceHash>Sequence hashes of blocks that were pulled.
StateResponse
Full state snapshot.
Sent after attachment and periodically on state changes.
BlocksStaged
Notification that blocks have been staged.
This message supports layerwise transfer by optionally specifying
which layer range is ready. When layer_range is None, all layers
of the staged blocks are ready for transfer.
Fields
layer_range: Option<Range<usize>>Layer range that is ready for transfer.
None: All layers are ready (default behavior)Some(0..1): Only layer 0 is readySome(0..60): Layers 0-59 are ready
This enables layerwise streaming where the sender computes layer-by-layer and notifies the receiver as each layer completes.
Close
Close the session gracefully.
Error
Report an error.
Implementations§
Source§impl SessionMessage
impl SessionMessage
Sourcepub fn session_id(&self) -> SessionId
pub fn session_id(&self) -> SessionId
Extract the session ID from any message variant.
Sourcepub fn peer(&self) -> Option<InstanceId>
pub fn peer(&self) -> Option<InstanceId>
Extract the peer instance ID if present.
Sourcepub fn is_control_command(&self) -> bool
pub fn is_control_command(&self) -> bool
Check if this is a control command (sent by controller).
Sourcepub fn is_state_response(&self) -> bool
pub fn is_state_response(&self) -> bool
Check if this is a state response (sent by controllee).
Sourcepub fn variant_name(&self) -> &'static str
pub fn variant_name(&self) -> &'static str
Get the variant name as a string for logging.
Trait Implementations§
Source§impl Clone for SessionMessage
impl Clone for SessionMessage
Source§fn clone(&self) -> SessionMessage
fn clone(&self) -> SessionMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SessionMessage
impl Debug for SessionMessage
Source§impl<'de> Deserialize<'de> for SessionMessage
impl<'de> Deserialize<'de> for SessionMessage
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SessionMessage
impl RefUnwindSafe for SessionMessage
impl Send for SessionMessage
impl Sync for SessionMessage
impl Unpin for SessionMessage
impl UnsafeUnpin for SessionMessage
impl UnwindSafe for SessionMessage
Blanket Implementations§
impl<T> BlockMetadata for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);