Document CultCache and CultNet public surface

This commit is contained in:
Meta Vens 2026-05-08 13:11:01 +01:00
commit 322cda12a6
11 changed files with 995 additions and 5 deletions

View file

@ -8,21 +8,33 @@ namespace GameCult.Networking
/// </summary>
public static class CultNetSchemaMessageSerialization
{
/// <summary>
/// Gets the serializer options used for CultNet schema-v0 messages.
/// </summary>
public static readonly MessagePackSerializerOptions Options =
MessagePackSerializerOptions.Standard.WithSecurity(MessagePackSecurity.UntrustedData);
/// <summary>
/// Serializes a typed CultNet schema message.
/// </summary>
public static byte[] Serialize<T>(T message) where T : ICultNetSchemaMessage
{
if (message == null) throw new ArgumentNullException(nameof(message));
return MessagePackSerializer.Serialize(message, Options);
}
/// <summary>
/// Deserializes a typed CultNet schema message.
/// </summary>
public static T Deserialize<T>(byte[] payload) where T : ICultNetSchemaMessage
{
if (payload == null) throw new ArgumentNullException(nameof(payload));
return MessagePackSerializer.Deserialize<T>(payload, Options);
}
/// <summary>
/// Deserializes a CultNet schema message by inspecting its schema version.
/// </summary>
public static ICultNetSchemaMessage Deserialize(byte[] payload)
{
if (payload == null) throw new ArgumentNullException(nameof(payload));
@ -54,7 +66,7 @@ namespace GameCult.Networking
};
}
[MessagePackObject]
[MessagePackObject(AllowPrivate = true)]
internal sealed class CultNetSchemaHeader
{
[Key("schemaVersion")] public string SchemaVersion { get; set; } = string.Empty;