pub enum Frame {
Send {
payload_type: String,
data: Value,
},
Select {
label: String,
},
End,
Error {
code: String,
detail: String,
},
}Expand description
One frame on the wire — exactly one operational step.
#[serde(tag = "kind", rename_all = "lowercase")] is intentional: the
kind discriminator is the closed catalog send | select | end | error. Anything else is malformed.
Variants§
Send
!A.S advance: the sender produces a value of type A (named by
the canonical payload string; the JSON data carries the value).
On the receiver side this triggers a try_recv(A) on its cursor.
Fields
Select
⊕{ℓᵢ:Sᵢ} advance: the chooser names a labelled branch. On the
receiver side this triggers a try_offer(ℓ) on its cursor (whose
type at this point is &{ℓᵢ:Sᵢ}).
End
end — the dialogue terminates. Both halves transition to End.
No further frames are accepted from either side; the carrier
(WebSocket) closes cleanly with code 1000 normal closure.
Error
Out-of-band protocol error — emitted by either side just before
closing the carrier with code 1002 protocol error. Carries a
short machine-readable code + a human detail message so the peer
can diagnose the divergence without re-running its analysis.
Fields
code: StringShort stable identifier — see ProtocolError::code.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn kind_tag(&self) -> &'static str
pub fn kind_tag(&self) -> &'static str
The fixed runtime tag of this frame’s kind, used in
ProtocolError::UnexpectedFrame for cursor / frame mismatch
diagnostics. Stable in both the wire (tag value) and the runtime
(matching the closed catalog).
Sourcepub fn to_wire(&self) -> String
pub fn to_wire(&self) -> String
Serialise to a JSON string, prefixed with the wire-version tag in
the outer envelope: every frame on the wire is one line of
{"v":1,"kind":"…",…} — the version is the first key so a
linewise log scan can reject pre-handshake junk without parsing.
We splice the version into the head of the serialised inner object
rather than building a serde_json::Map: the default Map sorts
keys alphabetically (BTreeMap-backed without preserve_order),
which would land "kind" before "v". The splice is total — the
inner serialisation is always a JSON object for this enum (every
variant has a kind tag), so the leading { is guaranteed.
Sourcepub fn from_wire(s: &str) -> Result<Frame, ProtocolError>
pub fn from_wire(s: &str) -> Result<Frame, ProtocolError>
Parse a wire string into a Frame. Validates the version tag and
the closed kind catalog; returns ProtocolError::MalformedFrame
on any divergence (including pre-1.0 shapes, unknown kind, missing
required fields).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Frame
impl<'de> Deserialize<'de> for Frame
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>,
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
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
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 more