mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-09-06 16:53:11 +02:00
16 lines
620 B
C#
16 lines
620 B
C#
using MemoryPack;
|
|
|
|
namespace Phantom.Utils.Rpc.New;
|
|
|
|
public static class Serialization {
|
|
private static readonly MemoryPackSerializerOptions SerializerOptions = MemoryPackSerializerOptions.Utf8;
|
|
|
|
public static ValueTask Serialize<T>(T value, Stream stream, CancellationToken cancellationToken) {
|
|
return MemoryPackSerializer.SerializeAsync(stream, value, SerializerOptions, cancellationToken);
|
|
}
|
|
|
|
public static async ValueTask<T> Deserialize<T>(Stream stream, CancellationToken cancellationToken) {
|
|
return (await MemoryPackSerializer.DeserializeAsync<T>(stream, SerializerOptions, cancellationToken))!;
|
|
}
|
|
}
|