6internal class PageDeserializer<T> : BaseDeserializer<Page<T>>
8 private IDeserializer<List<T>> _dataDeserializer;
10 public PageDeserializer(IDeserializer<T> elemDeserializer)
12 _dataDeserializer =
new ListDeserializer<T>(elemDeserializer);
17 var endToken = reader.CurrentTokenType
switch
20 TokenType.StartObject =>
TokenType.EndObject,
22 throw new SerializationException(
23 $
"Unexpected token while deserializing into {typeof(Page<T>)}: {other}"),
29 while (reader.Read() && reader.CurrentTokenType != endToken)
31 var fieldName = reader.GetString()!;
37 data = _dataDeserializer.Deserialize(context, ref reader);
40 after = reader.GetString()!;
46 throw new SerializationException($
"No page data found while deserializing into {typeof(Page<T>)}");
48 return new Page<T>(data!, after);
T Deserialize(MappingContext context, ref Utf8FaunaReader reader)
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.