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);
17 var wrapInPage =
false;
19 switch (reader.CurrentTokenType)
37 data = _dataSerializer.Deserialize(context, ref reader);
41 while (reader.Read() && reader.CurrentTokenType != endToken)
43 var fieldName = reader.GetString()!;
49 data = _dataSerializer.Deserialize(context, ref reader);
52 after = reader.GetString()!;
59 throw new SerializationException($
"No page data found while deserializing into {typeof(Page<T>)}");
61 return new Page<T>(data!, after);
64 public override void Serialize(
MappingContext context, Utf8FaunaWriter writer,
object? o)
66 DynamicSerializer.Singleton.Serialize(context, writer, o);
A class representing the mapping context to be used during serialization and deserialization.
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.