Class MessagePackSizes
Exact-size MessagePack encoding math shared by MessagePackSerializer<TProtocol>, the built-in foreign-type formatters (AddressFormatter, ActorPathFormatter), and external hand-written IAkkaMessagePackFormatter<T> implementations.
Inherited Members
Namespace: Akka.Serialization.V2
Assembly: Akka.Serialization.V2.dll
Syntax
public static class MessagePackSizes
Remarks
Every method returns the exact number of bytes the corresponding MessagePack.MessagePackWriter operation produces, using the same encoding choices as the generated serializers. Formatters should compose these helpers when implementing SizeOf(T) so their results honor the exact-or-UnknownSize contract.
Methods
| Edit this page View SourceSizeOfActorRef(IActorRef?)
Returns the encoded size of an IActorRef written using the generated transport-aware serialized-path string convention.
Declaration
public static int SizeOfActorRef(IActorRef? actorRef)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorRef | The actor reference; NoSender and null encode as an empty string. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfArrayHeader(int)
Returns the encoded size of an array header with count elements.
Declaration
public static int SizeOfArrayHeader(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | The number of array elements. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfBinHeader(int)
Returns the encoded size of a bin header for a payload of byteCount bytes.
Declaration
public static int SizeOfBinHeader(int byteCount)
Parameters
| Type | Name | Description |
|---|---|---|
| int | byteCount | The binary payload length. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfBoolean(bool)
Returns the encoded size of a boolean value.
Declaration
public static int SizeOfBoolean(bool _)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | _ | The value; boolean encoding is always one byte. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfBytes(byte[]?)
Returns the encoded size of a binary payload, or the nil size when value is null.
Declaration
public static int SizeOfBytes(byte[]? value)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | value | The byte array whose bin-encoded size is being computed. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfDateTime(DateTime)
Returns the encoded size of a DateTime written using the generated two-element array convention of ticks plus kind.
Declaration
public static int SizeOfDateTime(DateTime value)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTime | value | The value whose encoded size is being computed. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfDateTimeOffset(DateTimeOffset)
Returns the encoded size of a DateTimeOffset written using the generated two-element array convention of ticks plus offset minutes.
Declaration
public static int SizeOfDateTimeOffset(DateTimeOffset value)
Parameters
| Type | Name | Description |
|---|---|---|
| DateTimeOffset | value | The value whose encoded size is being computed. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfDecimal(decimal)
Returns the encoded size of a decimal written using the generated four-element array-of-int32-bits convention.
Declaration
public static int SizeOfDecimal(decimal value)
Parameters
| Type | Name | Description |
|---|---|---|
| decimal | value | The value whose encoded size is being computed. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfDouble(double)
Returns the encoded size of a double value.
Declaration
public static int SizeOfDouble(double _)
Parameters
| Type | Name | Description |
|---|---|---|
| double | _ | The value; double encoding is always nine bytes. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfEnum(int)
Returns the encoded size of an enum value written using the generated int32 convention.
Declaration
public static int SizeOfEnum(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The enum value converted to its underlying int. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfGuid(Guid)
Returns the encoded size of a Guid written using the generated 16-byte bin convention.
Declaration
public static int SizeOfGuid(Guid _)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | _ | The value; Guid encoding is always a bin header plus sixteen bytes. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfInt32(int)
Returns the encoded size of a 32-bit integer value.
Declaration
public static int SizeOfInt32(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The value whose variable-length encoded size is being computed. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfInt64(long)
Returns the encoded size of a 64-bit integer value.
Declaration
public static int SizeOfInt64(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The value whose variable-length encoded size is being computed. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfMapHeader(int)
Returns the encoded size of a map header with count entries.
Declaration
public static int SizeOfMapHeader(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | The number of map entries. |
Returns
| Type | Description |
|---|---|
| int |
SizeOfNil()
Returns the encoded size of a MessagePack nil value.
Declaration
public static int SizeOfNil()
Returns
| Type | Description |
|---|---|
| int |
SizeOfString(string?)
Returns the encoded size of a string value, or the nil size when value is null.
Declaration
public static int SizeOfString(string? value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string whose UTF-8 encoded size is being computed. |
Returns
| Type | Description |
|---|---|
| int |
Edit this page