whiteoutlib 0.1.2

Read and write Blizzard game assets from Rust: models (MDX, M2, M3), textures (BLP, DDS, PNG, JPEG, BMP, TGA, TIFF, GIF) and archives (CASC, MPQ).
Documentation
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2026 Fernando Sahmkow

#pragma once

#include <cstddef>
#include <memory>

#include "../interfaces.h"

namespace whiteout::utils {

/// Basic HTTP handler with two platform backends:
///   * Windows  — WinHTTP
///   * Other    — libcurl (linked at build time)
///
/// Requests are dispatched asynchronously onto an internal thread pool;
/// each worker owns one backend handle and keeps its connection cache warm.
/// Thread-safe: multiple threads may call getAsync / getRangeAsync
/// concurrently.
///
/// @bind methods, extends=whiteout::interfaces::HttpHandler, java_package=whiteout.utils
class SimpleHttpHandler : public interfaces::HttpHandler {
public:
    /// Create a handler with @p nThreads I/O worker threads (default: 4).
    explicit SimpleHttpHandler(size_t nThreads = 4);

    ~SimpleHttpHandler() override;

    // Non-copyable, non-movable (PImpl).
    SimpleHttpHandler(const SimpleHttpHandler&) = delete;
    SimpleHttpHandler& operator=(const SimpleHttpHandler&) = delete;

    /// @bind — Reported handler capability flags.
    u32 capabilities() const noexcept override;

    /// @bind skip — std::function callback isn't auto-bindable
    void getAsync(const std::string& url, interfaces::HttpCallback callback) override;

    /// @bind skip — std::function callback isn't auto-bindable
    void getRangeAsync(const std::string& url, u64 start, u64 end,
                       interfaces::HttpCallback callback) override;

private:
    struct Impl;
    std::unique_ptr<Impl> m_impl;
};

} // namespace whiteout::utils