Interface BabelNetworkMessageSerializer<T extends BabelMessage>

Type Parameters:
T - the concrete BabelMessage type handled by this serializer
All Superinterfaces:
BabelNetworkSerializer<T>
All Known Implementing Classes:
BabelMessageSerializer, BasicSignedBabelMessageSerializer, FullSignedBabelMessageSerializer

public interface BabelNetworkMessageSerializer<T extends BabelMessage> extends BabelNetworkSerializer<T>
Serializer contract for Babel IP network messages.

Extends BabelNetworkSerializer with a numeric identifier that is embedded in the wire frame immediately after the Babel magic number. The receiving side reads this identifier and looks up the matching deserializer in the SerializerRegistry, allowing heterogeneous message types to share the same channel.

Concrete implementations are generated at compile time by the MessageProcessor annotation processor for every record annotated with BabelIPMessage. Each generated class is registered as a service provider via @AutoService(BabelNetworkMessageSerializer.class).

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the unique numeric identifier for the message type handled by this serializer.

    Methods inherited from interface BabelNetworkSerializer

    deserialize, getEstimateSize, getEstimateSize, getObjectClass, serialize
    Modifier and Type
    Method
    Description
    deserialize(io.netty.buffer.ByteBuf in, NodeStore store)
    Reads an instance of T from the supplied buffer.
    default int
    Returns an estimated size in bytes for the given object.
    default int
    getEstimateSize(T object, @Nullable NodeStore store)
    Returns a size estimate to fit the entire object in a ByteBuf without needing resizes.
    Returns the class of objects handled by this serializer, used for registry lookup.
    void
    serialize(T object, io.netty.buffer.ByteBuf out, NodeStore store)
    Encodes object and appends the resulting bytes to out.
  • Method Details

    • getId

      int getId()
      Returns the unique numeric identifier for the message type handled by this serializer. The value corresponds to the id attribute of the BabelIPMessage annotation.
      Returns:
      the message type identifier