Package anbxj
Interface Channel_MessageSerializer
- All Known Implementing Classes:
Channel_JavaFramedSerializer,Channel_ProtobufSerializer
public interface Channel_MessageSerializer
A protocol-specific serializer that converts logical protocol-level objects
to/from byte arrays. Implementations are generated by the AnBx compiler for
each protocol and are typically backed by Protocol Buffers.
Each protocol step that involves a Send or Receive is
assigned a unique step number. The serializer uses this number to select the
correct message schema, enabling strongly-typed, self-describing wire
formats that can be consumed by hand-written code in other languages (e.g.,
C++).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize(byte[] data, int step) Deserializes a byte array back into a logical protocol message object.byte[]Serializes a logical protocol message into a byte array.default voidsetSession(AnB_Session session) Injects the currentAnB_Sessioninto this serializer.
-
Method Details
-
serialize
Serializes a logical protocol message into a byte array.- Parameters:
message- the object to send; the concrete type depends on the protocol step (e.g.,String,Crypto_SealedPair,Object[]for tuples)step- the protocol step number (starting from 1), used to identify the message format- Returns:
- the serialized bytes, ready to be written to the network
- Throws:
IOException- if serialization fails
-
deserialize
Deserializes a byte array back into a logical protocol message object.- Parameters:
data- the raw bytes received from the networkstep- the expected protocol step number, used to identify the message format and recreate the appropriate object- Returns:
- the reconstructed protocol object (e.g.,
String,Crypto_SealedPair,Object[]) - Throws:
IOException- if deserialization failsClassNotFoundException- if a required class cannot be found (may occur when internal Java serialization is used inside cryptographic wrappers)
-
setSession
Injects the currentAnB_Sessioninto this serializer.The default implementation does nothing. Subclasses that require access to the session (e.g., for cryptographic operations during field extraction) should override this method and store the reference.
- Parameters:
session- the current session (must not benull)
-