1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 15:53:00 +08:00
osu-lazer/osu.Game/Online/API/Requests/PaginationParameters.cs

39 lines
1.2 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
namespace osu.Game.Online.API.Requests
{
/// <summary>
/// Represents a pagination data used for <see cref="PaginatedAPIRequest{T}"/>.
/// </summary>
2022-04-19 07:48:34 +08:00
public readonly struct PaginationParameters
{
/// <summary>
/// The starting point of the request.
/// </summary>
public int Offset { get; }
/// <summary>
/// The maximum number of items to return in this request.
/// </summary>
public int Limit { get; }
2022-04-19 07:48:34 +08:00
public PaginationParameters(int offset, int limit)
{
Offset = offset;
Limit = limit;
}
2022-04-19 07:48:34 +08:00
public PaginationParameters(int limit)
: this(0, limit)
{
}
/// <summary>
2022-04-19 07:48:34 +08:00
/// Returns a <see cref="PaginationParameters"/> of the next number of items defined by <paramref name="limit"/> after this.
/// </summary>
/// <param name="limit">The limit of the next pagination.</param>
2022-04-19 07:48:34 +08:00
public PaginationParameters TakeNext(int limit) => new PaginationParameters(Offset + Limit, limit);
}
}