package com.cameleer.server.core.search;

import java.util.List;

/**
 * Paginated result envelope for search queries.
 *
 * @param data   the result items for the current page
 * @param total  total number of matching items across all pages
 * @param offset the offset used for this page
 * @param limit  the limit used for this page
 * @param <T>    the type of result items
 */
public record SearchResult<T>(
        List<T> data,
        long total,
        int offset,
        int limit
) {

    /**
     * Create an empty result with the given pagination parameters.
     */
    public static <T> SearchResult<T> empty(int offset, int limit) {
        return new SearchResult<>(List.of(), 0, offset, limit);
    }
}
