Table of Contents

Struct ReadOnlyMemoryConverter

Namespace
DynaSharp.Serialization
Assembly
DynaSharp.dll

Converts ReadOnlyMemory<T> of byte to and from a binary value (B), which travels as base64.

public readonly struct ReadOnlyMemoryConverter : IDynamoDbConverter<ReadOnlyMemory<byte>>
Implements
Inherited Members

Remarks

A value read is backed by a new array that nothing else references, so keeping it is safe. Writing reads the memory without copying it. Empty binary values are valid, except in key attributes, which DynamoDB validates.

Explicit Interface Implementations

Read(ref DynamoDbReader, AttributeType)

Reads the attribute value the reader is positioned on.

static ReadOnlyMemory<byte> Read(ref DynamoDbReader reader, AttributeType type)

Parameters

reader DynamoDbReader

The reader, positioned on the value after ReadStartAttribute() or TryReadStartAttribute(out AttributeType). The caller reads the closing brace afterwards, so the converter must read the value completely (all elements of a list, map or set) and nothing more.

type AttributeType

The DynamoDB type of the value. Check it with Expect(AttributeType, AttributeType), which throws JsonException for types the converter does not support. Null is passed to the converter too, so it can map it to null where that makes sense.

Returns

ReadOnlyMemory<byte>

The value.

Exceptions

JsonException

type is not Binary, or the text is not valid base64.

Write(DynamoDbWriter, ReadOnlyMemory<byte>)

Writes a value as one complete attribute value, for example with WriteNumber<T>(T).

static void Write(DynamoDbWriter writer, ReadOnlyMemory<byte> value)

Parameters

writer DynamoDbWriter

The writer, positioned where a value is expected (after an attribute name, or inside a list). It is a ref struct, so it is never null and needs no check.

value ReadOnlyMemory<byte>

The value.