Class ProtobufSerializer
- Namespace
- ShapeShift.Protobuf
- Assembly
- ShapeShift.Protobuf.dll
Serializes PolyType-described object graphs to the protobuf-style binary encoding used by this package.
public record ProtobufSerializer : ShapeShiftSerializer<ProtobufEncoder, ProtobufDecoder>, IEquatable<ShapeShiftSerializer<ProtobufEncoder, ProtobufDecoder>>, IEquatable<ProtobufSerializer>
- Inheritance
-
ProtobufSerializer
- Implements
- Inherited Members
Methods
Deserialize<T>(ReadOnlySpan<byte>)
Deserializes a value from a protobuf-style binary payload.
public T? Deserialize<T>(ReadOnlySpan<byte> payload) where T : IShapeable<T>
Parameters
payloadReadOnlySpan<byte>The encoded bytes.
Returns
- T
The deserialized value.
Type Parameters
TThe value type.
Deserialize<T, TProvider>(ReadOnlySpan<byte>)
Deserializes a value from a protobuf-style binary payload using a specified shape provider.
public T? Deserialize<T, TProvider>(ReadOnlySpan<byte> payload) where TProvider : IShapeable<T>
Parameters
payloadReadOnlySpan<byte>The encoded bytes.
Returns
- T
The deserialized value.
Type Parameters
TThe value type.
TProviderThe type shape provider.
Serialize<T>(in T?)
Serializes a value as a protobuf-style binary payload.
public byte[] Serialize<T>(in T? value) where T : IShapeable<T>
Parameters
valueTThe value to serialize.
Returns
- byte[]
The binary payload.
Type Parameters
TThe value type.
Serialize<T, TProvider>(in T?)
Serializes a value as a protobuf-style binary payload using a specified shape provider.
public byte[] Serialize<T, TProvider>(in T? value) where TProvider : IShapeable<T>
Parameters
valueTThe value to serialize.
Returns
- byte[]
The binary payload.
Type Parameters
TThe value type.
TProviderThe shape provider.