6internal class PageSerializer<T> : BaseSerializer<Page<T>>
8 private readonly ISerializer<List<T>> _dataSerializer;
10 public PageSerializer(ISerializer<T> elemSerializer)
12 _dataSerializer =
new ListSerializer<T>(elemSerializer);
15 public override List<FaunaType> GetSupportedTypes() => [
FaunaType.Null,
FaunaType.Set];
19 bool wrapInPage =
false;
21 switch (reader.CurrentTokenType)
36 var data = _dataSerializer.
Deserialize(ctx, ref reader);
41 return reader.CurrentTokenType == TokenType.String
42 ? HandleUnmaterialized(ctx, ref reader, endToken)
43 : HandleMaterialized(ctx, ref reader, endToken);
48 string after = reader.GetString()!;
50 if (reader.CurrentTokenType != endToken)
52 throw UnexpectedToken(reader.CurrentTokenType);
65 string fieldName = reader.GetString()!;
71 data = _dataSerializer.Deserialize(ctx, ref reader);
74 after = reader.GetString()!;
77 }
while (reader.Read() && reader.CurrentTokenType != endToken);
79 return new Page<T>(data, after);
84 throw new NotImplementedException();
A class representing the mapping context to be used during serialization and deserialization.
new T Deserialize(MappingContext ctx, ref Utf8FaunaReader reader)
Consumes all or some of a Utf8FaunaReader and returns an instance of T .
object? ISerializer. Deserialize(MappingContext ctx, ref Utf8FaunaReader reader)
Consumes or partially consumes the provided reader and deserializes into a result.
void ISerializer. Serialize(MappingContext context, Utf8FaunaWriter writer, object? o)
Serializes the provided object onto the Utf8FaunaWriter
FaunaType
An enum representing possible Fauna types.
TokenType
Enumerates the types of tokens used in Fauna serialization.
record Page< T >(IReadOnlyList< T > Data, string? After)
Represents a page in a dataset for pagination.