Path: redb-route/redb.Route/Abstractions/IMessageSerializer.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Abstractions/IMessageSerializer.cs ---- namespace redb.Route.Abstractions; /// /// Defines a strategy for serializing and deserializing message bodies. /// Implementations handle specific formats (JSON, Protobuf, MessagePack, etc.). /// public interface IMessageSerializer { /// Content type this serializer handles (e.g., "application/json"). string ContentType { get; } /// /// All media types this serializer can handle, including structured-suffix aliases /// (e.g. application/json, application/vnd.api+json, application/problem+json). /// Default implementation returns a single-element list containing . /// Implementations override this to claim multiple media types in a single registration. /// /// /// Used by during Register so that one /// serializer instance covers all its aliases without repeated calls. /// IReadOnlyCollection MediaTypes => new[] { ContentType }; /// /// true for a format whose input is raw bytes rather than an object model (Base64, GZip, Zip): /// a byte[] body is the payload to wrap, not an already-marshalled result, so Marshal /// must not pass it through. Default false. /// bool WrapsBytes => false; /// Serializes a value to a byte array. /// Value type. /// Value to serialize. /// Serialized bytes. byte[] Serialize(T value); /// Deserializes a byte array to a typed value. /// Target type. /// Serialized bytes. /// Deserialized value. T? Deserialize(byte[] data); /// Deserializes a byte array to a typed value. /// Serialized bytes. /// Target type. /// Deserialized value. object? Deserialize(byte[] data, Type type); }