distribute/handshake
Types
Represents acceptance of a negotiated protocol with specific version and parameters.
pub type Accept {
Accept(
protocol: String,
version: Int,
params: List(#(String, String)),
)
}
Constructors
-
Accept( protocol: String, version: Int, params: List(#(String, String)), )
Message containing a list of capabilities for negotiation.
pub type CapabilitiesMsg {
CapabilitiesMsg(capabilities: List(Capability))
}
Constructors
-
CapabilitiesMsg(capabilities: List(Capability))
Represents a capability advertised during handshake negotiation.
Contains protocol name, supported version range (min/max), and optional metadata.
pub type Capability {
Capability(
protocol: String,
min: Int,
max: Int,
meta: List(#(String, String)),
)
}
Constructors
-
Capability( protocol: String, min: Int, max: Int, meta: List(#(String, String)), )
A tagged envelope containing a versioned payload for wire transmission.
pub type Envelope {
Envelope(tag: String, version: Int, payload: BitArray)
}
Constructors
-
Envelope(tag: String, version: Int, payload: BitArray)
Errors that can occur during handshake operations.
pub type HandshakeError {
InvalidEnvelope(String)
UnsupportedProtocol(String)
Timeout(String)
CryptoError(String)
}
Constructors
-
InvalidEnvelope(String) -
UnsupportedProtocol(String) -
Timeout(String) -
CryptoError(String)
Represents the initial Hello message sent when establishing a connection.
Contains the sending node’s identifier, metadata, and advertised capabilities.
pub type Hello {
Hello(
node_id: String,
node_info: List(#(String, String)),
capabilities: List(Capability),
)
}
Constructors
-
Hello( node_id: String, node_info: List(#(String, String)), capabilities: List(Capability), )
Message containing cryptographic key exchange payload.
pub type KeyExchangeMsg {
KeyExchangeMsg(payload: BitArray)
}
Constructors
-
KeyExchangeMsg(payload: BitArray)
Metadata about a cluster member after successful handshake.
Contains negotiated protocol versions and optional secure context for encryption.
pub type MemberMetadata {
MemberMetadata(
negotiated_versions: List(#(String, Int)),
secure_context: option.Option(provider.SecureContext),
)
}
Constructors
-
MemberMetadata( negotiated_versions: List(#(String, Int)), secure_context: option.Option(provider.SecureContext), )
Values
pub fn accept_encoder() -> fn(Accept) -> Result(
BitArray,
codec.EncodeError,
)
Creates an encoder for serializing Accept messages to binary format.
pub fn accept_schema() -> codec.Schema(Accept)
Returns the codec schema for Accept messages with envelope support.
pub fn accept_sized_decoder() -> fn(BitArray) -> Result(
#(Accept, BitArray),
codec.DecodeError,
)
Creates a sized decoder for deserializing Accept messages from binary format.
pub fn capabilities_encoder() -> fn(CapabilitiesMsg) -> Result(
BitArray,
codec.EncodeError,
)
Creates an encoder for serializing CapabilitiesMsg to binary format.
pub fn capabilities_schema() -> codec.Schema(CapabilitiesMsg)
Returns the codec schema for CapabilitiesMsg with envelope support.
pub fn capabilities_sized_decoder() -> fn(BitArray) -> Result(
#(CapabilitiesMsg, BitArray),
codec.DecodeError,
)
Creates a sized decoder for deserializing CapabilitiesMsg from binary format.
pub fn capability_encoder() -> fn(Capability) -> Result(
BitArray,
codec.EncodeError,
)
Creates an encoder for serializing Capability values to binary format.
pub fn capability_sized_decoder() -> fn(BitArray) -> Result(
#(Capability, BitArray),
codec.DecodeError,
)
Creates a sized decoder for deserializing Capability values from binary format.
pub fn decode_accept(
data: BitArray,
) -> Result(Accept, codec.DecodeError)
Decodes an Accept message from binary format, unwrapping the envelope.
pub fn decode_capabilities(
data: BitArray,
) -> Result(CapabilitiesMsg, codec.DecodeError)
Decodes a CapabilitiesMsg from binary format, unwrapping the envelope.
pub fn decode_hello(
data: BitArray,
) -> Result(Hello, codec.DecodeError)
Decodes a Hello message from binary format, unwrapping the envelope.
pub fn decode_keyexchange(
data: BitArray,
) -> Result(KeyExchangeMsg, codec.DecodeError)
Decodes a KeyExchangeMsg from binary format, unwrapping the envelope.
pub fn decode_reject(
data: BitArray,
) -> Result(Reject, codec.DecodeError)
Decodes a Reject message from binary format, unwrapping the envelope.
pub fn encode_accept(
a: Accept,
) -> Result(BitArray, codec.EncodeError)
Encodes an Accept message to binary format with envelope wrapper.
pub fn encode_capabilities(
m: CapabilitiesMsg,
) -> Result(BitArray, codec.EncodeError)
Encodes a CapabilitiesMsg to binary format with envelope wrapper.
pub fn encode_hello(
h: Hello,
) -> Result(BitArray, codec.EncodeError)
Encodes a Hello message to binary format with envelope wrapper.
pub fn encode_keyexchange(
k: KeyExchangeMsg,
) -> Result(BitArray, codec.EncodeError)
Encodes a KeyExchangeMsg to binary format with envelope wrapper.
pub fn encode_reject(
r: Reject,
) -> Result(BitArray, codec.EncodeError)
Encodes a Reject message to binary format with envelope wrapper.
pub fn hello_encoder() -> fn(Hello) -> Result(
BitArray,
codec.EncodeError,
)
Creates an encoder for serializing Hello messages to binary format.
pub fn hello_schema() -> codec.Schema(Hello)
Returns the codec schema for Hello messages with envelope support.
pub fn hello_sized_decoder() -> fn(BitArray) -> Result(
#(Hello, BitArray),
codec.DecodeError,
)
Creates a sized decoder for deserializing Hello messages from binary format.
pub fn keyexchange_encoder() -> fn(KeyExchangeMsg) -> Result(
BitArray,
codec.EncodeError,
)
Creates an encoder for serializing KeyExchangeMsg to binary format.
pub fn keyexchange_schema() -> codec.Schema(KeyExchangeMsg)
Returns the codec schema for KeyExchangeMsg with envelope support.
pub fn keyexchange_sized_decoder() -> fn(BitArray) -> Result(
#(KeyExchangeMsg, BitArray),
codec.DecodeError,
)
Creates a sized decoder for deserializing KeyExchangeMsg from binary format.
pub fn peek_envelope_tag(
data: BitArray,
) -> Result(#(String, Int), HandshakeError)
Peeks at the envelope tag and version without consuming the data.
Returns the tag string and version number if the envelope is valid.
pub fn reject_encoder() -> fn(Reject) -> Result(
BitArray,
codec.EncodeError,
)
Creates an encoder for serializing Reject messages to binary format.
pub fn reject_schema() -> codec.Schema(Reject)
Returns the codec schema for Reject messages with envelope support.
pub fn reject_sized_decoder() -> fn(BitArray) -> Result(
#(Reject, BitArray),
codec.DecodeError,
)
Creates a sized decoder for deserializing Reject messages from binary format.
pub fn unwrap_envelope(
data: BitArray,
) -> Result(#(String, Int, BitArray), HandshakeError)
Unwraps an envelope, extracting the tag, version, and payload.
Returns a tuple of (tag, version, payload) or an error if invalid.
pub fn wrap_envelope(
tag: String,
version: Int,
payload: BitArray,
) -> BitArray
Wraps a payload in an envelope with the given tag and version.
Returns the complete envelope as a BitArray ready for transmission.