pub enum ServerReply {
Hello(ServerHello),
Retry(HelloRetryRequest),
Reject(ServerReject),
}std only.Expand description
A discriminated server handshake reply (T4.4).
The wire form is [kind: u8] ‖ borsh(body). The leading discriminant byte lets the
client dispatch the three possible replies explicitly, instead of the former
trial-deserialization that distinguished them by message size (a ServerReject is a
handful of bytes, a HelloRetryRequest tens, a ServerHello thousands — robust in
practice, but a same-size confusion was structurally possible). The discriminant is an
API-layer framing byte that sits outside the borsh message structs, so it does not
affect the frozen wire_vectors (which fix the bare message encodings).
Variants§
Hello(ServerHello)
Handshake succeeded — carries the signed ServerHello.
Retry(HelloRetryRequest)
DoS gate — carries a cookie / PoW HelloRetryRequest.
Reject(ServerReject)
Structural rejection (e.g. unknown version) — carries a ServerReject.
Implementations§
Source§impl ServerReply
impl ServerReply
Sourcepub fn to_wire(&self) -> Result<Vec<u8>, HandshakeError>
pub fn to_wire(&self) -> Result<Vec<u8>, HandshakeError>
Serialise to [kind: u8] ‖ borsh(body).
Sourcepub fn from_wire(bytes: &[u8]) -> Result<Self, HandshakeError>
pub fn from_wire(bytes: &[u8]) -> Result<Self, HandshakeError>
Parse [kind: u8] ‖ borsh(body) with explicit dispatch on the discriminant. An
empty input or an unknown kind byte is an error — never a silent misparse.
Trait Implementations§
Source§impl Clone for ServerReply
impl Clone for ServerReply
Source§fn clone(&self) -> ServerReply
fn clone(&self) -> ServerReply
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more